Pino Toscano
2017-Feb-24 10:45 UTC
[Libguestfs] [PATCH] inspector: validate resulting XML files
Run xmllint to validate the XML output files of virt-inspector, so the schema is checked against actual output of virt-inspector. --- inspector/test-virt-inspector.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/inspector/test-virt-inspector.sh b/inspector/test-virt-inspector.sh index 2f55cdc..33d749c 100755 --- a/inspector/test-virt-inspector.sh +++ b/inspector/test-virt-inspector.sh @@ -30,6 +30,8 @@ for f in ../test-data/phony-guests/{debian,fedora,ubuntu,archlinux,coreos,window if [ -s "$f" ]; then b=$(basename "$f" .xml) $VG virt-inspector --format=raw -a "$f" > "actual-$b.xml" + # Check the generated output validate the schema. + xmllint --noout --relaxng $srcdir/virt-inspector.rng "actual-$b.xml" # This 'diff' command will fail (because of -e option) if there # are any differences. diff -ur $diff_ignore "expected-$b.xml" "actual-$b.xml" -- 2.9.3
Richard W.M. Jones
2017-Feb-24 13:00 UTC
Re: [Libguestfs] [PATCH] inspector: validate resulting XML files
On Fri, Feb 24, 2017 at 11:45:49AM +0100, Pino Toscano wrote:> Run xmllint to validate the XML output files of virt-inspector, so the > schema is checked against actual output of virt-inspector. > --- > inspector/test-virt-inspector.sh | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/inspector/test-virt-inspector.sh b/inspector/test-virt-inspector.sh > index 2f55cdc..33d749c 100755 > --- a/inspector/test-virt-inspector.sh > +++ b/inspector/test-virt-inspector.sh > @@ -30,6 +30,8 @@ for f in ../test-data/phony-guests/{debian,fedora,ubuntu,archlinux,coreos,window > if [ -s "$f" ]; then > b=$(basename "$f" .xml) > $VG virt-inspector --format=raw -a "$f" > "actual-$b.xml" > + # Check the generated output validate the schema. > + xmllint --noout --relaxng $srcdir/virt-inspector.rng "actual-$b.xml"This should use @XMLLINT@ (and consequently the test will have to be generated by configure), and it should also add a skip: skip_unless @XMLLINT@ --version Rich.> # This 'diff' command will fail (because of -e option) if there > # are any differences. > diff -ur $diff_ignore "expected-$b.xml" "actual-$b.xml" > -- > 2.9.3 > > _______________________________________________ > Libguestfs mailing list > Libguestfs@redhat.com > https://www.redhat.com/mailman/listinfo/libguestfs-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v