[PATCH 3/3] schematestutils: Add check_schema_quick

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

 



We have hundreds of XML files.
Pass multiple of them on xmllint command line to avoid spawning
a process for every single one.

If any of them fails validation, or VIR_TEST_EXPENSIVE was set to 1,
fall back to the file-by-file checking.
---
 tests/schematestutils.sh | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/tests/schematestutils.sh b/tests/schematestutils.sh
index 498b7ec..81a1006 100644
--- a/tests/schematestutils.sh
+++ b/tests/schematestutils.sh
@@ -6,10 +6,19 @@ check_schema () {
 
 DIRS=$1
 SCHEMA="$abs_top_srcdir/docs/schemas/$2"
+SKIP_EXPENSIVE=0
 
 test_intro $this_test
 
-check_schema_by_one
+if test "$VIR_TEST_EXPENSIVE" != 1; then
+  check_schema_quick
+  test $f == 0 && SKIP_EXPENSIVE=1
+fi
+
+if test $SKIP_EXPENSIVE != 1; then
+  check_schema_by_one
+fi
+
 test_final $n $f
 
 ret=0
@@ -18,6 +27,28 @@ exit $ret
 
 }
 
+check_schema_quick () {
+  f=0
+  ABSDIRS=""
+  for dir in $DIRS; do
+    ABSDIRS="$ABSDIRS $abs_srcdir/$dir"
+  done
+  VALIDXMLS=`find $ABSDIRS -not -name '*-invalid.xml' -name '*.xml'` || exit 1
+  INVALIDXMLS=`find $ABSDIRS -name '*-invalid.xml'` || exit 1
+
+  n=`echo "$VALIDXMLS" | wc -l`
+  result=`echo "$VALIDXMLS" | xargs xmllint --relaxng $SCHEMA --noout 2>&1`
+  ret=$?
+  if test "$ret" != 0 ; then
+    f=`expr $f + 1`
+  fi
+
+  for xml in `echo "$INVALIDXMLS" | sort`
+  do
+    check_one_file
+  done
+}
+
 check_schema_by_one () {
 
 for dir in $DIRS
-- 
2.7.3

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