summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@redhat.com>2006-08-29 22:27:07 +0000
committerDaniel Veillard <veillard@redhat.com>2006-08-29 22:27:07 +0000
commit3bbac7cdb670fb7e8b8fad25cfe4b23a8bf4a056 (patch)
tree900d74e5d8418835cfcfa949222e2ad7819da351 /tests
parentAdd handling of error HTTP 500 codes (diff)
downloadlibvirt-3bbac7cdb670fb7e8b8fad25cfe4b23a8bf4a056.tar.gz
libvirt-3bbac7cdb670fb7e8b8fad25cfe4b23a8bf4a056.tar.bz2
libvirt-3bbac7cdb670fb7e8b8fad25cfe4b23a8bf4a056.zip
* TODO libvirt.spec.in: update
* configure.in include/libvirt/virterror.h src/Makefile.am src/conf.c src/conf.h src/virterror.c src/xen_internal.c: adding a subset of Xen config file parser, and serializer * tests/Makefile.am tests/conftest.c tests/test_conf.sh tests/confdata/Makefile.am tests/confdata/fc4.conf tests/confdata/fc4.out: adding test program for config in and out Daniel
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am11
-rw-r--r--tests/confdata/Makefile.am2
-rw-r--r--tests/confdata/fc4.conf10
-rw-r--r--tests/confdata/fc4.out10
-rw-r--r--tests/conftest.c30
-rwxr-xr-xtests/test_conf.sh17
6 files changed, 77 insertions, 3 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ef5af6547..a95076cf4 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -17,11 +17,11 @@ LDADDS = \
@LIBXML_LIBS@ \
$(LIBVIRT)
-EXTRA_DIST = xmlrpcserver.py
+EXTRA_DIST = xmlrpcserver.py test_conf.sh
-noinst_PROGRAMS = xmlrpctest xml2sexprtest sexpr2xmltest virshtest
+noinst_PROGRAMS = xmlrpctest xml2sexprtest sexpr2xmltest virshtest conftest
-TESTS = xml2sexprtest sexpr2xmltest virshtest
+TESTS = xml2sexprtest sexpr2xmltest virshtest test_conf.sh
valgrind:
$(MAKE) check TESTS_ENVIRONMENT="valgrind --quiet"
@@ -54,5 +54,10 @@ virshtest_SOURCES = \
virshtest_LDFLAGS =
virshtest_LDADD = $(LDADDS)
+conftest_SOURCES = \
+ conftest.c
+conftest_LDFLAGS =
+conftest_LDADD = $(LDADDS)
+
$(LIBVIRT):
-@(cd $(top_builddir)/src && $(MAKE) MAKEFLAGS+=--silent)
diff --git a/tests/confdata/Makefile.am b/tests/confdata/Makefile.am
new file mode 100644
index 000000000..8393a6f2b
--- /dev/null
+++ b/tests/confdata/Makefile.am
@@ -0,0 +1,2 @@
+
+EXTRA_DIST = $(wildcard *.in) $(wildcard *.out)
diff --git a/tests/confdata/fc4.conf b/tests/confdata/fc4.conf
new file mode 100644
index 000000000..745a4c409
--- /dev/null
+++ b/tests/confdata/fc4.conf
@@ -0,0 +1,10 @@
+kernel="/boot/vmlinuz-2.6.15-1.2054_FC5xenU"
+ramdisk="/boot/initrd-2.6.15-1.2054_FC5xenU.img"
+memory=128 # should be enough
+name="fc4"
+vif = [ 'mac=aa:00:00:00:00:11, bridge=xenbr0' ]
+disk = ['file:/xen/fc4.img,sda1,w']
+root = "/dev/sda1"
+extra = "ro selinux=0 3"
+# just for testing ...
+tst = [ 1, 2, [ 3, 4 ], 5]
diff --git a/tests/confdata/fc4.out b/tests/confdata/fc4.out
new file mode 100644
index 000000000..1fad85ceb
--- /dev/null
+++ b/tests/confdata/fc4.out
@@ -0,0 +1,10 @@
+kernel = "/boot/vmlinuz-2.6.15-1.2054_FC5xenU"
+ramdisk = "/boot/initrd-2.6.15-1.2054_FC5xenU.img"
+memory = 128 # should be enough
+name = "fc4"
+vif = [ "mac=aa:00:00:00:00:11, bridge=xenbr0" ]
+disk = [ "file:/xen/fc4.img,sda1,w" ]
+root = "/dev/sda1"
+extra = "ro selinux=0 3"
+# just for testing ...
+tst = [ 1, 2, [ 3, 4 ], 5 ]
diff --git a/tests/conftest.c b/tests/conftest.c
new file mode 100644
index 000000000..16346a49b
--- /dev/null
+++ b/tests/conftest.c
@@ -0,0 +1,30 @@
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "conf.h"
+
+int main(int argc, char **argv) {
+ int ret;
+ virConfPtr conf;
+ int len = 10000;
+ char buffer[10000];
+
+ if (argc != 2) {
+ fprintf(stderr, "Usage: %s conf_file\n", argv[0]);
+ exit(1);
+ }
+
+ conf = virConfReadFile(argv[1]);
+ if (conf == NULL) {
+ fprintf(stderr, "Failed to process %s\n", argv[1]);
+ exit(2);
+ }
+ ret = virConfWriteMem(&buffer[0], &len, conf);
+ if (ret < 0) {
+ fprintf(stderr, "Failed to serialize %s back\n", argv[1]);
+ exit(3);
+ }
+ printf("%s", buffer);
+ virConfFree(conf);
+ exit(0);
+}
diff --git a/tests/test_conf.sh b/tests/test_conf.sh
new file mode 100755
index 000000000..b5a636633
--- /dev/null
+++ b/tests/test_conf.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+NOK=0
+for f in confdata/*.conf
+do
+ ./conftest $f > conftest.$$
+ outfile=`echo $f | sed s+\.conf+\.out+`
+ diff $outfile conftest.$$ > /dev/null
+ if [ $? != 0 ]
+ then
+ echo "$f FAILED"
+ NOK=1
+ else
+ echo "$f OK"
+ fi
+done
+rm -f conftest.$$
+exit $NOK