[libvirt] PATCH: Validate all test suite XML files against schema

Daniel P. Berrange berrange at redhat.com
Wed Jul 30 15:20:17 UTC 2008


After frequent prompting from John I've implemented a small test case to
validate all the domain XML files we have in the test suite against the
defined RNG schema. This showed one minor bug in the schema :-)

Daniel

diff -r c44225477420 docs/libvirt.rng
--- a/docs/libvirt.rng	Wed Jul 30 14:20:38 2008 +0100
+++ b/docs/libvirt.rng	Wed Jul 30 16:17:19 2008 +0100
@@ -141,6 +141,7 @@
       </attribute>
       <attribute name='machine'>
 	<choice>
+	  <value>xenfv</value>
 	  <value>pc</value>
 	  <value>isapc</value>
 	</choice>
diff -r c44225477420 tests/Makefile.am
--- a/tests/Makefile.am	Wed Jul 30 14:20:38 2008 +0100
+++ b/tests/Makefile.am	Wed Jul 30 16:17:19 2008 +0100
@@ -37,13 +37,14 @@
 	test-lib.sh	\
 	xmlrpcserver.py	\
 	qemuxml2argvdata \
-	nodeinfodata
+	nodeinfodata     \
+	domainschematest
 
 noinst_PROGRAMS = xmlrpctest xml2sexprtest sexpr2xmltest virshtest conftest \
 	reconnect xmconfigtest xencapstest qemuxml2argvtest qemuxml2xmltest \
         nodeinfotest statstest qparamtest
 
-test_scripts =
+test_scripts = domainschematest
 if WITH_LIBVIRTD
 test_scripts += \
 	test_conf.sh \
diff -r c44225477420 tests/domainschematest
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/domainschematest	Wed Jul 30 16:17:19 2008 +0100
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+test -z "$srcdir" && srcdir=`pwd`
+
+DOMAINDIRS="qemuxml2argvdata sexpr2xmldata xmconfigdata xml2sexprdata"
+
+n=0
+f=0
+for dir in $DOMAINDIRS
+do
+  XML=`find $dir -name '*.xml'`
+
+  for xml in $XML
+  do
+    n=`expr $n + 1`
+    printf "%4d) %-60s  " $n $xml
+    result=`xmllint --relaxng $srcdir/../docs/libvirt.rng --noout $xml 2>&1`
+    ret=$?
+    if test $ret = 0; then
+        echo "OK"
+    else
+        echo "FAILED"
+        echo $result
+        f=`expr $f + 1`
+    fi
+  done
+done
+echo "Validated $n files, $f failed"
+
+ret=0
+test $f != 0 && ret=255
+exit $ret


-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list