172
|
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 |
|
|
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/
|
|
32 |
|
|
33 |
|
|
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 well-formed: $reldir$file"
|
|
43 |
return 1
|
|
44 |
else
|
|
45 |
return 0
|
|
46 |
fi
|
|
47 |
}
|
|
48 |
|
|
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 "$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
|
|
70 |
}
|
|
71 |
|
|
72 |
SUCCESS=0
|
|
73 |
ERROR=0
|
|
74 |
|
|
75 |
UpdateStatus() {
|
|
76 |
if [ "$1" -eq 0 ] ; then
|
|
77 |
SUCCESS=`expr $SUCCESS + 1`
|
|
78 |
else
|
|
79 |
ERROR=`expr $ERROR + 1`
|
|
80 |
fi
|
|
81 |
}
|
|
82 |
|
|
83 |
##########################
|
|
84 |
# well-formed test cases #
|
|
85 |
##########################
|
|
86 |
|
|
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
|
|
105 |
|
|
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
|
|
113 |
|
|
114 |
##############################
|
|
115 |
# not well-formed test cases #
|
|
116 |
##############################
|
|
117 |
|
|
118 |
cd "$TS/xmlconf"
|
|
119 |
for xmldir in ibm/not-wf/P* \
|
|
120 |
ibm/not-wf/misc \
|
|
121 |
xmltest/not-wf/ext-sa \
|
|
122 |
xmltest/not-wf/not-sa \
|
|
123 |
xmltest/not-wf/sa \
|
|
124 |
sun/not-wf ; do
|
|
125 |
cd "$TS/xmlconf/$xmldir"
|
|
126 |
for xmlfile in *.xml ; do
|
|
127 |
RunXmlwfNotWF "$xmlfile" "$xmldir/"
|
|
128 |
UpdateStatus $?
|
|
129 |
done
|
|
130 |
rm outfile
|
|
131 |
done
|
|
132 |
|
|
133 |
cd "$TS/xmlconf/oasis"
|
|
134 |
for xmlfile in *fail*.xml ; do
|
|
135 |
RunXmlwfNotWF "$xmlfile" "oasis/"
|
|
136 |
UpdateStatus $?
|
|
137 |
done
|
|
138 |
rm outfile
|
|
139 |
|
|
140 |
echo "Passed: $SUCCESS"
|
|
141 |
echo "Failed: $ERROR"
|