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/
34 # Unicode-aware diff utility
38 # RunXmlwfNotWF file reldir
39 # reldir includes trailing slash
43 $XMLWF -p "$file" > outfile || return $?
44 read outdata < outfile
45 if test "$outdata" = "" ; then
46 echo "Expected not well-formed: $reldir$file"
53 # RunXmlwfWF file reldir
54 # reldir includes trailing slash
58 $XMLWF -p -N -d "$OUTPUT$reldir" "$file" > outfile || return $?
59 read outdata < outfile
60 if test "$outdata" = "" ; then
61 if [ -f "out/$file" ] ; then
62 $DIFF "$OUTPUT$reldir$file" "out/$file" > outfile
63 if [ -s outfile ] ; then
64 cp outfile "$OUTPUT$reldir$file.diff"
65 echo "Output differs: $reldir$file"
71 echo "In $reldir: $outdata"
80 if [ "$1" -eq 0 ] ; then
81 SUCCESS=`expr $SUCCESS + 1`
83 ERROR=`expr $ERROR + 1`
87 ##########################
88 # well-formed test cases #
89 ##########################
92 for xmldir in ibm/valid/P* \
94 xmltest/valid/ext-sa \
95 xmltest/valid/not-sa \
97 xmltest/invalid/not-sa \
101 cd "$TS/xmlconf/$xmldir"
102 mkdir -p "$OUTPUT$xmldir"
103 for xmlfile in $(ls -1 *.xml | sort -d) ; do
104 [[ -f "$xmlfile" ]] || continue
105 RunXmlwfWF "$xmlfile" "$xmldir/"
111 cd "$TS/xmlconf/oasis"
112 mkdir -p "$OUTPUT"oasis
113 for xmlfile in *pass*.xml ; do
114 RunXmlwfWF "$xmlfile" "oasis/"
119 ##############################
120 # not well-formed test cases #
121 ##############################
124 for xmldir in ibm/not-wf/P* \
127 xmltest/not-wf/ext-sa \
128 xmltest/not-wf/not-sa \
131 cd "$TS/xmlconf/$xmldir"
132 for xmlfile in *.xml ; do
133 RunXmlwfNotWF "$xmlfile" "$xmldir/"
139 cd "$TS/xmlconf/oasis"
140 for xmlfile in *fail*.xml ; do
141 RunXmlwfNotWF "$xmlfile" "oasis/"
146 echo "Passed: $SUCCESS"
147 echo "Failed: $ERROR"