]> granicus.if.org Git - libexpat/commitdiff
Update to Karl's version of this script, and use the latest version of
authorFred L. Drake, Jr. <fdrake@users.sourceforge.net>
Tue, 3 Sep 2002 23:19:30 +0000 (23:19 +0000)
committerFred L. Drake, Jr. <fdrake@users.sourceforge.net>
Tue, 3 Sep 2002 23:19:30 +0000 (23:19 +0000)
the tests from the W3C.

expat/Makefile.in
expat/tests/.gitignore
expat/tests/xmltest.sh

index 12e2fc1db05857a93950208d7b311b966606997a..c3971cd06392861d94e4cc1b24c6cd614d1ed0e4 100644 (file)
@@ -148,13 +148,14 @@ tests/runtests.o: tests/runtests.c tests/chardata.h
 tests/runtests: tests/runtests.o tests/chardata.o $(LIBRARY)
        $(LINK_EXE) $^ -lcheck
 
-tests/xmltest.zip:
-       cd tests && wget ftp://ftp.jclark.com/pub/xml/xmltest.zip
+tests/xmlts.zip:
+       wget --output-document=tests/xmlts.zip \
+               http://www.w3.org/XML/Test/xmlts20020606.zip
 
-tests/xmltest: tests/xmltest.zip
-       cd tests && unzip -q xmltest.zip
+tests/XML-Test-Suite: tests/xmlts.zip
+       cd tests && unzip -q xmlts.zip
 
-run-xmltest: xmlwf/xmlwf tests/xmltest
+run-xmltest: xmlwf/xmlwf tests/XML-Test-Suite
        tests/xmltest.sh
 
 .SUFFIXES: .c .lo .o
index d0a3c96f98e27ab7f0671c8dc750684776507c07..4542fcf6b4a217f1f27e2d054251dc7ab81c387e 100644 (file)
@@ -1,5 +1,5 @@
 Makefile
 runtests
-xmltest
-xmltest.zip
+xmlts.zip
+XML-Test-Suite
 .libs
index 4be5a655743cb968975de5c648cae50fbadd267e..4a495055bd91ca5d48b2fca9f95f3372b1893ce5 100755 (executable)
 #! /bin/sh
 
-VERBOSE=''
+#   EXPAT TEST SCRIPT FOR W3C XML TEST SUITE
 
-if [ "$1" = '-v' -o "$1" = '--verbose' ] ; then
-    VERBOSE="$1"
-    shift
-fi
+# This script can be used to exercise Expat against the
+# w3c.org xml test suite, available from
+# http://www.w3.org/XML/Test/xmlts20020606.zip.
 
-if [ ! "$1" = '' ] ; then
-    ERRORS=0
-    if [ "$VERBOSE" ] ; then
-        OUTPUT="/tmp/$$.out"
+# To run this script, first set XMLWF so that xmlwf can be
+# found, then set the output directory with OUTPUT.
+
+# The script lists all test cases where Expat shows a discrepancy
+# from the expected result. Test cases where only the canonical
+# output differs are prefixed with "Output differs:", and a diff file
+# is generated in the appropriate subdirectory under $OUTPUT.
+
+# The script does not use "invalid" test cases for validating parsers.
+# If there are output files provided, the script will use
+# output from xmlwf and compare the desired output against it.
+# However, one has to take into account that the canonical output
+# produced by xmlwf conforms to an older definition of canonical XML
+# and does not generate notation declarations.
+
+MYDIR="`dirname \"$0\"`"
+cd "$MYDIR"
+MYDIR="`pwd`"
+XMLWF="`dirname \"$MYDIR\"`/xmlwf/xmlwf"
+# XMLWF=/usr/local/bin/xmlwf
+# XMLWF=f:/Libraries/XML/expat/xmlwf/release/xmlwf
+TS="$MYDIR/XML-Test-Suite"
+# OUTPUT must terminate with the directory separater.
+OUTPUT="$TS/out/"
+# OUTPUT=/home/tmp/xml-testsuite-out/
+# OUTPUT=f:/Libraries/XML/XML-Test-Suite/out/
+
+RunXmlwfNotWF() {
+  $XMLWF $1 $2 > outfile || return $?
+  read outdata < outfile
+  if test "$outdata" = "" ; then
+      echo "Well formed: $3$2"
+      return 1
+  else
+      return 0
+  fi 
+}
+
+RunXmlwfWF() {
+  $XMLWF $1 -d "$OUTPUT$3" $2 > outfile || return $?
+  read outdata < outfile 
+  if test "$outdata" = "" ; then 
+      if [ -f out/$2 ] ; then 
+          diff "$OUTPUT$3$2" out/$2 > outfile 
+          if [ -s outfile ] ; then 
+              cp outfile $OUTPUT$3${2}.diff 
+              echo "Output differs: $3$2"
+              return 1
+          fi 
+      fi 
+      return 0
+  else 
+      echo "In $3: $outdata"
+      return 1
+  fi 
+}
+
+SUCCESS=0
+ERROR=0
+
+cd "$TS/xmlconf"
+for xmldir in ibm/valid/P*/ \
+              xmltest/valid/ext-sa/ \
+              xmltest/valid/not-sa/ \
+              xmltest/valid/sa/ \
+              sun/valid/ ; do
+  cd "$TS/xmlconf/$xmldir"
+  mkdir -p "$OUTPUT$xmldir"
+  for xmlfile in *.xml ; do
+      if RunXmlwfWF -p "$xmlfile" "$xmldir" ; then
+          SUCCESS=`expr $SUCCESS + 1`
+      else
+          ERROR=`expr $ERROR + 1`
+      fi
+  done
+  rm outfile
+done
+
+cd "$TS/xmlconf/oasis"
+mkdir -p "$OUTPUT"oasis/
+for xmlfile in *pass*.xml ; do
+    if RunXmlwfWF -p "$xmlfile" "oasis/" ; then
+        SUCCESS=`expr $SUCCESS + 1`
     else
-        OUTPUT="/dev/null"
-    fi
-    while [ "$1" ] ; do
-        FILE="`basename \"$1\"`"
-        DIR="`dirname \"$1\"`"
-        DIR="`dirname \"$DIR\"`"
-        ../xmlwf/xmlwf -d /tmp "$DIR/$FILE"
-        diff -u "$DIR/out/$FILE" "/tmp/$FILE" >$OUTPUT
-        ERR=$?
-        rm "/tmp/$FILE"
-        if [ ! "$ERR" = 0 ] ; then
-            ERRORS=`expr $ERRORS + 1`
-            echo "$DIR/$FILE ... Error"
-            cat $OUTPUT
-        elif [ "$VERBOSE" ] ; then
-            echo "$DIR/$FILE ... Ok"
-        fi
-        shift
-    done
-    if [ "$VERBOSE" ] ; then
-        rm $OUTPUT
+        ERROR=`expr $ERROR + 1`
     fi
-    if [ ! "$ERRORS" = '0' ] ; then
-        echo "    Errors:  $ERRORS"
-        exit 1
-    fi
-else
-    SCRIPTDIR="`dirname \"$0\"`"
-    cd "$SCRIPTDIR"
-    find xmltest -name \*.xml | grep /out/ | xargs ./xmltest.sh $VERBOSE
-    if [ ! "$?" = "0" ] ; then
-        exit 1
+done
+rm outfile
+
+cd "$TS/xmlconf"
+for xmldir in ibm/not-wf/P*/ \
+              ibm/not-wf/misc/ \
+              xmltest/not-wf/ext-sa/ \
+              xmltest/not-wf/not-sa/ \
+              xmltest/not-wf/sa/ \
+              sun/not-wf/ ; do
+  cd "$TS/xmlconf/$xmldir"
+  for xmlfile in *.xml ; do
+      if RunXmlwfNotWF -p "$xmlfile" "$xmldir" ; then
+          SUCCESS=`expr $SUCCESS + 1`
+      else
+          ERROR=`expr $ERROR + 1`
+      fi
+  done
+  rm outfile
+done
+
+cd "$TS/xmlconf/oasis"
+for xmlfile in *fail*.xml ; do
+    if RunXmlwfNotWF -p "$xmlfile" "oasis/" ; then
+        SUCCESS=`expr $SUCCESS + 1`
+    else
+        ERROR=`expr $ERROR + 1`
     fi
-fi
+done
+rm outfile
+
+echo "Passed: $SUCCESS"
+echo "Failed: $ERROR"