Bring in expat 2.1.0 from vendor.
[AROS.git] / workbench / libs / expat / tests / xmltest.sh
blob793a5cc2819bb4cbc4714cf337e5783b8bdf75b2
1 #! /bin/sh
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\"`"
24 cd "$MYDIR"
25 MYDIR="`pwd`"
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.
30 OUTPUT="$TS/out/"
31 # OUTPUT=/home/tmp/xml-testsuite-out/
34 # RunXmlwfNotWF file reldir
35 # reldir includes trailing slash
36 RunXmlwfNotWF() {
37 file="$1"
38 reldir="$2"
39 $XMLWF -p "$file" > outfile || return $?
40 read outdata < outfile
41 if test "$outdata" = "" ; then
42 echo "Expected not well-formed: $reldir$file"
43 return 1
44 else
45 return 0
46 fi
49 # RunXmlwfWF file reldir
50 # reldir includes trailing slash
51 RunXmlwfWF() {
52 file="$1"
53 reldir="$2"
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"
62 return 1
63 fi
64 fi
65 return 0
66 else
67 echo "In $reldir: $outdata"
68 return 1
69 fi
72 SUCCESS=0
73 ERROR=0
75 UpdateStatus() {
76 if [ "$1" -eq 0 ] ; then
77 SUCCESS=`expr $SUCCESS + 1`
78 else
79 ERROR=`expr $ERROR + 1`
83 ##########################
84 # well-formed test cases #
85 ##########################
87 cd "$TS/xmlconf"
88 for xmldir in ibm/valid/P* \
89 ibm/invalid/P* \
90 xmltest/valid/ext-sa \
91 xmltest/valid/not-sa \
92 xmltest/invalid \
93 xmltest/invalid/not-sa \
94 xmltest/valid/sa \
95 sun/valid \
96 sun/invalid ; do
97 cd "$TS/xmlconf/$xmldir"
98 mkdir -p "$OUTPUT$xmldir"
99 for xmlfile in *.xml ; do
100 RunXmlwfWF "$xmlfile" "$xmldir/"
101 UpdateStatus $?
102 done
103 rm outfile
104 done
106 cd "$TS/xmlconf/oasis"
107 mkdir -p "$OUTPUT"oasis
108 for xmlfile in *pass*.xml ; do
109 RunXmlwfWF "$xmlfile" "oasis/"
110 UpdateStatus $?
111 done
112 rm outfile
114 ##############################
115 # not well-formed test cases #
116 ##############################
118 cd "$TS/xmlconf"
119 for xmldir in ibm/not-wf/P* \
120 ibm/not-wf/p28a \
121 ibm/not-wf/misc \
122 xmltest/not-wf/ext-sa \
123 xmltest/not-wf/not-sa \
124 xmltest/not-wf/sa \
125 sun/not-wf ; do
126 cd "$TS/xmlconf/$xmldir"
127 for xmlfile in *.xml ; do
128 RunXmlwfNotWF "$xmlfile" "$xmldir/"
129 UpdateStatus $?
130 done
131 rm outfile
132 done
134 cd "$TS/xmlconf/oasis"
135 for xmlfile in *fail*.xml ; do
136 RunXmlwfNotWF "$xmlfile" "oasis/"
137 UpdateStatus $?
138 done
139 rm outfile
141 echo "Passed: $SUCCESS"
142 echo "Failed: $ERROR"