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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]