]> git.saurik.com Git - wxWidgets.git/blame - src/expat/tests/xmltest.sh
wxMessageBox off the main thread lost result code.
[wxWidgets.git] / src / expat / tests / xmltest.sh
CommitLineData
5e9f2524
VS
1#! /bin/sh
2
3# EXPAT TEST SCRIPT FOR W3C XML TEST SUITE
4
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.
8
11a3e7b6 9# To run this script, first set XMLWF below so that xmlwf can be
5e9f2524
VS
10# found, then set the output directory with OUTPUT.
11
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.
16
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.
22
23MYDIR="`dirname \"$0\"`"
24cd "$MYDIR"
25MYDIR="`pwd`"
26XMLWF="`dirname \"$MYDIR\"`/xmlwf/xmlwf"
27# XMLWF=/usr/local/bin/xmlwf
28TS="$MYDIR/XML-Test-Suite"
29# OUTPUT must terminate with the directory separator.
30OUTPUT="$TS/out/"
31# OUTPUT=/home/tmp/xml-testsuite-out/
32
33
11a3e7b6
VZ
34# RunXmlwfNotWF file reldir
35# reldir includes trailing slash
5e9f2524 36RunXmlwfNotWF() {
11a3e7b6
VZ
37 file="$1"
38 reldir="$2"
39 $XMLWF -p "$file" > outfile || return $?
5e9f2524
VS
40 read outdata < outfile
41 if test "$outdata" = "" ; then
11a3e7b6 42 echo "Expected not well-formed: $reldir$file"
5e9f2524
VS
43 return 1
44 else
45 return 0
46 fi
47}
48
11a3e7b6
VZ
49# RunXmlwfWF file reldir
50# reldir includes trailing slash
5e9f2524 51RunXmlwfWF() {
11a3e7b6
VZ
52 file="$1"
53 reldir="$2"
54 $XMLWF -p -d "$OUTPUT$reldir" "$file" > outfile || return $?
5e9f2524
VS
55 read outdata < outfile
56 if test "$outdata" = "" ; then
11a3e7b6
VZ
57 if [ -f "out/$file" ] ; then
58 diff -u "$OUTPUT$reldir$file" "out/$file" > outfile
5e9f2524 59 if [ -s outfile ] ; then
11a3e7b6
VZ
60 cp outfile "$OUTPUT$reldir$file.diff"
61 echo "Output differs: $reldir$file"
5e9f2524
VS
62 return 1
63 fi
64 fi
65 return 0
66 else
11a3e7b6 67 echo "In $reldir: $outdata"
5e9f2524
VS
68 return 1
69 fi
70}
71
72SUCCESS=0
73ERROR=0
74
11a3e7b6
VZ
75UpdateStatus() {
76 if [ "$1" -eq 0 ] ; then
77 SUCCESS=`expr $SUCCESS + 1`
78 else
79 ERROR=`expr $ERROR + 1`
80 fi
81}
82
5e9f2524
VS
83##########################
84# well-formed test cases #
85##########################
86
87cd "$TS/xmlconf"
11a3e7b6
VZ
88for 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
5e9f2524
VS
97 cd "$TS/xmlconf/$xmldir"
98 mkdir -p "$OUTPUT$xmldir"
99 for xmlfile in *.xml ; do
11a3e7b6
VZ
100 RunXmlwfWF "$xmlfile" "$xmldir/"
101 UpdateStatus $?
5e9f2524
VS
102 done
103 rm outfile
104done
105
106cd "$TS/xmlconf/oasis"
11a3e7b6 107mkdir -p "$OUTPUT"oasis
5e9f2524 108for xmlfile in *pass*.xml ; do
11a3e7b6
VZ
109 RunXmlwfWF "$xmlfile" "oasis/"
110 UpdateStatus $?
5e9f2524
VS
111done
112rm outfile
113
114##############################
115# not well-formed test cases #
116##############################
117
118cd "$TS/xmlconf"
11a3e7b6
VZ
119for 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
5e9f2524
VS
126 cd "$TS/xmlconf/$xmldir"
127 for xmlfile in *.xml ; do
11a3e7b6
VZ
128 RunXmlwfNotWF "$xmlfile" "$xmldir/"
129 UpdateStatus $?
5e9f2524
VS
130 done
131 rm outfile
132done
133
134cd "$TS/xmlconf/oasis"
135for xmlfile in *fail*.xml ; do
11a3e7b6
VZ
136 RunXmlwfNotWF "$xmlfile" "oasis/"
137 UpdateStatus $?
5e9f2524
VS
138done
139rm outfile
140
141echo "Passed: $SUCCESS"
142echo "Failed: $ERROR"