]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/expat/tests/xmltest.sh
missing commit
[wxWidgets.git] / src / expat / tests / xmltest.sh
... / ...
CommitLineData
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
9# To run this script, first set XMLWF so that xmlwf can be
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
34RunXmlwfNotWF() {
35 $XMLWF $1 $2 > outfile || return $?
36 read outdata < outfile
37 if test "$outdata" = "" ; then
38 echo "Well formed: $3$2"
39 return 1
40 else
41 return 0
42 fi
43}
44
45RunXmlwfWF() {
46 $XMLWF $1 -d "$OUTPUT$3" $2 > outfile || return $?
47 read outdata < outfile
48 if test "$outdata" = "" ; then
49 if [ -f out/$2 ] ; then
50 diff "$OUTPUT$3$2" out/$2 > outfile
51 if [ -s outfile ] ; then
52 cp outfile $OUTPUT$3${2}.diff
53 echo "Output differs: $3$2"
54 return 1
55 fi
56 fi
57 return 0
58 else
59 echo "In $3: $outdata"
60 return 1
61 fi
62}
63
64SUCCESS=0
65ERROR=0
66
67##########################
68# well-formed test cases #
69##########################
70
71cd "$TS/xmlconf"
72for xmldir in ibm/valid/P*/ \
73 ibm/invalid/P*/ \
74 xmltest/valid/ext-sa/ \
75 xmltest/valid/not-sa/ \
76 xmltest/invalid/ \
77 xmltest/invalid/not-sa/ \
78 xmltest/valid/sa/ \
79 sun/valid/ \
80 sun/invalid/ ; do
81 cd "$TS/xmlconf/$xmldir"
82 mkdir -p "$OUTPUT$xmldir"
83 for xmlfile in *.xml ; do
84 if RunXmlwfWF -p "$xmlfile" "$xmldir" ; then
85 SUCCESS=`expr $SUCCESS + 1`
86 else
87 ERROR=`expr $ERROR + 1`
88 fi
89 done
90 rm outfile
91done
92
93cd "$TS/xmlconf/oasis"
94mkdir -p "$OUTPUT"oasis/
95for xmlfile in *pass*.xml ; do
96 if RunXmlwfWF -p "$xmlfile" "oasis/" ; then
97 SUCCESS=`expr $SUCCESS + 1`
98 else
99 ERROR=`expr $ERROR + 1`
100 fi
101done
102rm outfile
103
104##############################
105# not well-formed test cases #
106##############################
107
108cd "$TS/xmlconf"
109for xmldir in ibm/not-wf/P*/ \
110 ibm/not-wf/misc/ \
111 xmltest/not-wf/ext-sa/ \
112 xmltest/not-wf/not-sa/ \
113 xmltest/not-wf/sa/ \
114 sun/not-wf/ ; do
115 cd "$TS/xmlconf/$xmldir"
116 for xmlfile in *.xml ; do
117 if RunXmlwfNotWF -p "$xmlfile" "$xmldir" ; then
118 SUCCESS=`expr $SUCCESS + 1`
119 else
120 ERROR=`expr $ERROR + 1`
121 fi
122 done
123 rm outfile
124done
125
126cd "$TS/xmlconf/oasis"
127for xmlfile in *fail*.xml ; do
128 if RunXmlwfNotWF -p "$xmlfile" "oasis/" ; then
129 SUCCESS=`expr $SUCCESS + 1`
130 else
131 ERROR=`expr $ERROR + 1`
132 fi
133done
134rm outfile
135
136echo "Passed: $SUCCESS"
137echo "Failed: $ERROR"