mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
* 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:
@@ -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)
|
||||
|
||||
2
tests/confdata/Makefile.am
Normal file
2
tests/confdata/Makefile.am
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
EXTRA_DIST = $(wildcard *.in) $(wildcard *.out)
|
||||
10
tests/confdata/fc4.conf
Normal file
10
tests/confdata/fc4.conf
Normal 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
10
tests/confdata/fc4.out
Normal 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
30
tests/conftest.c
Normal 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
17
tests/test_conf.sh
Executable 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
|
||||
Reference in New Issue
Block a user