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 # Note: OUTPUT must terminate with the directory separator.
26 OUTPUT="$PWD/tests/out/"
29 MYDIR="`dirname \"$0\"`"
32 XMLWF="${1:-`dirname \"$MYDIR\"`/xmlwf/xmlwf}"
33 # Unicode-aware diff utility
34 DIFF="${MYDIR}/udiffer.py"
37 # RunXmlwfNotWF file reldir
38 # reldir includes trailing slash
42 if $XMLWF -p "$file" > /dev/null; then
43 echo "Expected not well-formed: $reldir$file"
50 # RunXmlwfWF file reldir
51 # reldir includes trailing slash
55 $XMLWF -p -N -d "$OUTPUT$reldir" "$file" > outfile || return $?
56 read outdata < outfile
57 if test "$outdata" = "" ; then
58 if [ -f "out/$file" ] ; then
59 $DIFF "$OUTPUT$reldir$file" "out/$file" > outfile
60 if [ -s outfile ] ; then
61 cp outfile "$OUTPUT$reldir$file.diff"
62 echo "Output differs: $reldir$file"
68 echo "In $reldir: $outdata"
77 if [ "$1" -eq 0 ] ; then
78 SUCCESS=`expr $SUCCESS + 1`
80 ERROR=`expr $ERROR + 1`
84 ##########################
85 # well-formed test cases #
86 ##########################
89 for xmldir in ibm/valid/P* \
91 xmltest/valid/ext-sa \
92 xmltest/valid/not-sa \
94 xmltest/invalid/not-sa \
98 cd "$TS/xmlconf/$xmldir"
99 mkdir -p "$OUTPUT$xmldir"
100 for xmlfile in $(ls -1 *.xml | sort -d) ; do
101 [[ -f "$xmlfile" ]] || continue
102 RunXmlwfWF "$xmlfile" "$xmldir/"
108 cd "$TS/xmlconf/oasis"
109 mkdir -p "$OUTPUT"oasis
110 for xmlfile in *pass*.xml ; do
111 RunXmlwfWF "$xmlfile" "oasis/"
116 ##############################
117 # not well-formed test cases #
118 ##############################
121 for xmldir in ibm/not-wf/P* \
124 xmltest/not-wf/ext-sa \
125 xmltest/not-wf/not-sa \
128 cd "$TS/xmlconf/$xmldir"
129 for xmlfile in *.xml ; do
130 RunXmlwfNotWF "$xmlfile" "$xmldir/"
135 cd "$TS/xmlconf/oasis"
136 for xmlfile in *fail*.xml ; do
137 RunXmlwfNotWF "$xmlfile" "oasis/"
141 echo "Passed: $SUCCESS"
142 echo "Failed: $ERROR"