3 # EXPAT TEST SCRIPT FOR W3C XML TEST SUITE
5 # This script can be used to exercise Expat against the
6 # w3c.org xml test suite, available from
7 # http://www.w3.org/XML/Test/xmlts20020606.zip.
9 # To run this script, first set XMLWF below so that xmlwf can be
10 # found, then set the output directory with OUTPUT.
12 # The script lists all test cases where Expat shows a discrepancy
13 # from the expected result. Test cases where only the canonical
14 # output differs are prefixed with "Output differs:", and a diff file
15 # is generated in the appropriate subdirectory under $OUTPUT.
17 # If there are output files provided, the script will use
18 # output from xmlwf and compare the desired output against it.
19 # However, one has to take into account that the canonical output
20 # produced by xmlwf conforms to an older definition of canonical XML
21 # and does not generate notation declarations.
23 MYDIR
="`dirname \"$0\"`"
26 XMLWF
="`dirname \"$MYDIR\"`/xmlwf/xmlwf"
27 # XMLWF=/usr/local/bin/xmlwf
28 TS
="$MYDIR/XML-Test-Suite"
29 # OUTPUT must terminate with the directory separator.
31 # OUTPUT=/home/tmp/xml-testsuite-out/
34 # RunXmlwfNotWF file reldir
35 # reldir includes trailing slash
39 $XMLWF -p "$file" > outfile ||
return $?
40 read outdata
< outfile
41 if test "$outdata" = "" ; then
42 echo "Expected not well-formed: $reldir$file"
49 # RunXmlwfWF file reldir
50 # reldir includes trailing slash
54 $XMLWF -p -d "$OUTPUT$reldir" "$file" > outfile ||
return $?
55 read outdata
< outfile
56 if test "$outdata" = "" ; then
57 if [ -f "out/$file" ] ; then
58 diff -u "$OUTPUT$reldir$file" "out/$file" > outfile
59 if [ -s outfile
] ; then
60 cp outfile
"$OUTPUT$reldir$file.diff"
61 echo "Output differs: $reldir$file"
67 echo "In $reldir: $outdata"
76 if [ "$1" -eq 0 ] ; then
77 SUCCESS
=`expr $SUCCESS + 1`
79 ERROR
=`expr $ERROR + 1`
83 ##########################
84 # well-formed test cases #
85 ##########################
88 for xmldir
in ibm
/valid
/P
* \
90 xmltest
/valid
/ext-sa \
91 xmltest
/valid
/not-sa \
93 xmltest
/invalid
/not-sa \
97 cd "$TS/xmlconf/$xmldir"
98 mkdir
-p "$OUTPUT$xmldir"
99 for xmlfile
in *.xml
; do
100 RunXmlwfWF
"$xmlfile" "$xmldir/"
106 cd "$TS/xmlconf/oasis"
107 mkdir
-p "$OUTPUT"oasis
108 for xmlfile
in *pass
*.xml
; do
109 RunXmlwfWF
"$xmlfile" "oasis/"
114 ##############################
115 # not well-formed test cases #
116 ##############################
119 for xmldir
in ibm
/not-wf
/P
* \
122 xmltest
/not-wf
/ext-sa \
123 xmltest
/not-wf
/not-sa \
126 cd "$TS/xmlconf/$xmldir"
127 for xmlfile
in *.xml
; do
128 RunXmlwfNotWF
"$xmlfile" "$xmldir/"
134 cd "$TS/xmlconf/oasis"
135 for xmlfile
in *fail
*.xml
; do
136 RunXmlwfNotWF
"$xmlfile" "oasis/"
141 echo "Passed: $SUCCESS"
142 echo "Failed: $ERROR"