* 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
This commit is contained in:
Daniel Veillard
2006-08-29 22:27:07 +00:00
parent 55bf738483
commit 3bbac7cdb6
16 changed files with 1087 additions and 9 deletions

View File

@@ -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)

View File

@@ -0,0 +1,2 @@
EXTRA_DIST = $(wildcard *.in) $(wildcard *.out)

10
tests/confdata/fc4.conf Normal file
View File

@@ -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]

10
tests/confdata/fc4.out Normal file
View File

@@ -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 ]

30
tests/conftest.c Normal file
View File

@@ -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);
}

17
tests/test_conf.sh Executable file
View File

@@ -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