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.
25 MYDIR="`dirname \"$0\"`"
28 XMLWF="${1:-`dirname \"$MYDIR\"`/xmlwf/xmlwf}"
29 # XMLWF=/usr/local/bin/xmlwf
31 # OUTPUT must terminate with the directory separator.
33 # OUTPUT=/home/tmp/xml-testsuite-out/
36 # RunXmlwfNotWF file reldir
37 # reldir includes trailing slash
41 $XMLWF -p "$file" > outfile || return $?
42 read outdata < outfile
43 if test "$outdata" = "" ; then
44 echo "Expected not well-formed: $reldir$file"
51 # RunXmlwfWF file reldir
52 # reldir includes trailing slash
56 $XMLWF -p -d "$OUTPUT$reldir" "$file" > outfile || return $?
57 read outdata < outfile
58 if test "$outdata" = "" ; then
59 if [ -f "out/$file" ] ; then
60 diff -u "$OUTPUT$reldir$file" "out/$file" > outfile
61 if [ -s outfile ] ; then
62 cp outfile "$OUTPUT$reldir$file.diff"
63 echo "Output differs: $reldir$file"
69 echo "In $reldir: $outdata"
78 if [ "$1" -eq 0 ] ; then
79 SUCCESS=`expr $SUCCESS + 1`
81 ERROR=`expr $ERROR + 1`
85 ##########################
86 # well-formed test cases #
87 ##########################
90 for xmldir in ibm/valid/P* \
92 xmltest/valid/ext-sa \
93 xmltest/valid/not-sa \
95 xmltest/invalid/not-sa \
99 cd "$TS/xmlconf/$xmldir"
100 mkdir -p "$OUTPUT$xmldir"
101 for xmlfile in $(ls -1 *.xml | sort -d) ; do
102 [[ -f "$xmlfile" ]] || continue
103 RunXmlwfWF "$xmlfile" "$xmldir/"
109 cd "$TS/xmlconf/oasis"
110 mkdir -p "$OUTPUT"oasis
111 for xmlfile in *pass*.xml ; do
112 RunXmlwfWF "$xmlfile" "oasis/"
117 ##############################
118 # not well-formed test cases #
119 ##############################
122 for xmldir in ibm/not-wf/P* \
125 xmltest/not-wf/ext-sa \
126 xmltest/not-wf/not-sa \
129 cd "$TS/xmlconf/$xmldir"
130 for xmlfile in *.xml ; do
131 RunXmlwfNotWF "$xmlfile" "$xmldir/"
137 cd "$TS/xmlconf/oasis"
138 for xmlfile in *fail*.xml ; do
139 RunXmlwfNotWF "$xmlfile" "oasis/"
144 echo "Passed: $SUCCESS"
145 echo "Failed: $ERROR"