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 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\"`"
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.
31
# OUTPUT=/home/tmp/xml-testsuite-out/
35
$XMLWF $1 $2 > outfile || return $?
36
read outdata < outfile
37
if test "$outdata" = "" ; then
38
echo "Well formed: $3$2"
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"
59
echo "In $3: $outdata"
67
##########################
68
# well-formed test cases #
69
##########################
72
for xmldir in ibm/valid/P*/ \
74
xmltest/valid/ext-sa/ \
75
xmltest/valid/not-sa/ \
77
xmltest/invalid/not-sa/ \
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`
87
ERROR=`expr $ERROR + 1`
93
cd "$TS/xmlconf/oasis"
94
mkdir -p "$OUTPUT"oasis/
95
for xmlfile in *pass*.xml ; do
96
if RunXmlwfWF -p "$xmlfile" "oasis/" ; then
97
SUCCESS=`expr $SUCCESS + 1`
99
ERROR=`expr $ERROR + 1`
104
##############################
105
# not well-formed test cases #
106
##############################
109
for xmldir in ibm/not-wf/P*/ \
111
xmltest/not-wf/ext-sa/ \
112
xmltest/not-wf/not-sa/ \
115
cd "$TS/xmlconf/$xmldir"
116
for xmlfile in *.xml ; do
117
if RunXmlwfNotWF -p "$xmlfile" "$xmldir" ; then
118
SUCCESS=`expr $SUCCESS + 1`
120
ERROR=`expr $ERROR + 1`
126
cd "$TS/xmlconf/oasis"
127
for xmlfile in *fail*.xml ; do
128
if RunXmlwfNotWF -p "$xmlfile" "oasis/" ; then
129
SUCCESS=`expr $SUCCESS + 1`
131
ERROR=`expr $ERROR + 1`
136
echo "Passed: $SUCCESS"
137
echo "Failed: $ERROR"