expat/tests .cvsignore,1.3,1.4 xmltest.sh,1.1,1.2

"Fred L. Drake" <[email protected]>
Newsgroups gmane.text.xml.expat.cvs
Message-ID <[email protected]>
Update of /cvsroot/expat/expat/tests
In directory usw-pr-cvs1:/tmp/cvs-serv2833/tests

Modified Files:
	.cvsignore xmltest.sh 
Log Message:
Update to Karl's version of this script, and use the latest version of
the tests from the W3C.


Index: .cvsignore
===================================================================
RCS file: /cvsroot/expat/expat/tests/.cvsignore,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- .cvsignore	29 Apr 2002 21:31:18 -0000	1.3
+++ .cvsignore	3 Sep 2002 23:19:30 -0000	1.4
@@ -1,5 +1,5 @@
 Makefile
 runtests
-xmltest
-xmltest.zip
+xmlts.zip
+XML-Test-Suite
 .libs

Index: xmltest.sh
===================================================================
RCS file: /cvsroot/expat/expat/tests/xmltest.sh,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- xmltest.sh	29 Apr 2002 21:31:18 -0000	1.1
+++ xmltest.sh	3 Sep 2002 23:19:30 -0000	1.2
@@ -1,48 +1,127 @@
 #! /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
-    fi
-    if [ ! "$ERRORS" = '0' ] ; then
-        echo "    Errors:  $ERRORS"
-        exit 1
+        ERROR=`expr $ERROR + 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"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.