2016-04-30 15:11:02 -04:00
|
|
|
#! /usr/bin/env bash
|
2002-04-29 17:31:18 -04:00
|
|
|
|
2002-09-03 19:19:30 -04:00
|
|
|
# EXPAT TEST SCRIPT FOR W3C XML TEST SUITE
|
2002-04-29 17:31:18 -04:00
|
|
|
|
2002-09-03 19:19:30 -04:00
|
|
|
# This script can be used to exercise Expat against the
|
|
|
|
# w3c.org xml test suite, available from
|
|
|
|
# http://www.w3.org/XML/Test/xmlts20020606.zip.
|
2002-04-29 17:31:18 -04:00
|
|
|
|
2008-08-03 14:19:12 -04:00
|
|
|
# To run this script, first set XMLWF below so that xmlwf can be
|
2002-09-03 19:19:30 -04:00
|
|
|
# found, then set the output directory with OUTPUT.
|
|
|
|
|
|
|
|
# The script lists all test cases where Expat shows a discrepancy
|
|
|
|
# from the expected result. Test cases where only the canonical
|
|
|
|
# output differs are prefixed with "Output differs:", and a diff file
|
|
|
|
# is generated in the appropriate subdirectory under $OUTPUT.
|
|
|
|
|
|
|
|
# If there are output files provided, the script will use
|
|
|
|
# output from xmlwf and compare the desired output against it.
|
|
|
|
# However, one has to take into account that the canonical output
|
|
|
|
# produced by xmlwf conforms to an older definition of canonical XML
|
|
|
|
# and does not generate notation declarations.
|
|
|
|
|
2016-04-30 15:11:02 -04:00
|
|
|
shopt -s nullglob
|
|
|
|
|
2019-08-10 18:57:18 -04:00
|
|
|
# Note: OUTPUT must terminate with the directory separator.
|
|
|
|
OUTPUT="$PWD/tests/out/"
|
|
|
|
TS="$PWD/tests/"
|
|
|
|
|
2002-09-03 19:19:30 -04:00
|
|
|
MYDIR="`dirname \"$0\"`"
|
|
|
|
cd "$MYDIR"
|
|
|
|
MYDIR="`pwd`"
|
2017-06-14 16:36:51 -04:00
|
|
|
XMLWF="${1:-`dirname \"$MYDIR\"`/xmlwf/xmlwf}"
|
2017-08-29 13:21:30 -04:00
|
|
|
# Unicode-aware diff utility
|
2019-08-10 18:57:18 -04:00
|
|
|
DIFF="${MYDIR}/udiffer.py"
|
2002-09-03 23:04:44 -04:00
|
|
|
|
2002-09-03 19:19:30 -04:00
|
|
|
|
2004-09-29 22:34:48 -04:00
|
|
|
# RunXmlwfNotWF file reldir
|
|
|
|
# reldir includes trailing slash
|
2002-09-03 19:19:30 -04:00
|
|
|
RunXmlwfNotWF() {
|
2004-09-29 22:34:48 -04:00
|
|
|
file="$1"
|
|
|
|
reldir="$2"
|
|
|
|
$XMLWF -p "$file" > outfile || return $?
|
2002-09-03 19:19:30 -04:00
|
|
|
read outdata < outfile
|
|
|
|
if test "$outdata" = "" ; then
|
2008-08-03 14:19:12 -04:00
|
|
|
echo "Expected not well-formed: $reldir$file"
|
2002-09-03 19:19:30 -04:00
|
|
|
return 1
|
|
|
|
else
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2004-09-29 22:34:48 -04:00
|
|
|
# RunXmlwfWF file reldir
|
|
|
|
# reldir includes trailing slash
|
2002-09-03 19:19:30 -04:00
|
|
|
RunXmlwfWF() {
|
2004-09-29 22:34:48 -04:00
|
|
|
file="$1"
|
|
|
|
reldir="$2"
|
2017-08-02 11:09:13 -04:00
|
|
|
$XMLWF -p -N -d "$OUTPUT$reldir" "$file" > outfile || return $?
|
2002-09-03 19:19:30 -04:00
|
|
|
read outdata < outfile
|
|
|
|
if test "$outdata" = "" ; then
|
2004-09-29 22:34:48 -04:00
|
|
|
if [ -f "out/$file" ] ; then
|
2017-08-29 13:21:30 -04:00
|
|
|
$DIFF "$OUTPUT$reldir$file" "out/$file" > outfile
|
2002-09-03 19:19:30 -04:00
|
|
|
if [ -s outfile ] ; then
|
2004-09-29 22:34:48 -04:00
|
|
|
cp outfile "$OUTPUT$reldir$file.diff"
|
|
|
|
echo "Output differs: $reldir$file"
|
2002-09-03 19:19:30 -04:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
else
|
2004-09-29 22:34:48 -04:00
|
|
|
echo "In $reldir: $outdata"
|
2002-09-03 19:19:30 -04:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
SUCCESS=0
|
|
|
|
ERROR=0
|
|
|
|
|
2004-09-29 22:34:48 -04:00
|
|
|
UpdateStatus() {
|
|
|
|
if [ "$1" -eq 0 ] ; then
|
|
|
|
SUCCESS=`expr $SUCCESS + 1`
|
|
|
|
else
|
|
|
|
ERROR=`expr $ERROR + 1`
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2002-09-03 23:04:44 -04:00
|
|
|
##########################
|
|
|
|
# well-formed test cases #
|
|
|
|
##########################
|
|
|
|
|
2002-09-03 19:19:30 -04:00
|
|
|
cd "$TS/xmlconf"
|
2004-09-29 22:34:48 -04:00
|
|
|
for xmldir in ibm/valid/P* \
|
|
|
|
ibm/invalid/P* \
|
|
|
|
xmltest/valid/ext-sa \
|
|
|
|
xmltest/valid/not-sa \
|
|
|
|
xmltest/invalid \
|
|
|
|
xmltest/invalid/not-sa \
|
|
|
|
xmltest/valid/sa \
|
|
|
|
sun/valid \
|
|
|
|
sun/invalid ; do
|
2002-09-03 19:19:30 -04:00
|
|
|
cd "$TS/xmlconf/$xmldir"
|
|
|
|
mkdir -p "$OUTPUT$xmldir"
|
2017-03-13 16:20:56 -04:00
|
|
|
for xmlfile in $(ls -1 *.xml | sort -d) ; do
|
|
|
|
[[ -f "$xmlfile" ]] || continue
|
2004-09-29 22:34:48 -04:00
|
|
|
RunXmlwfWF "$xmlfile" "$xmldir/"
|
|
|
|
UpdateStatus $?
|
2002-09-03 19:19:30 -04:00
|
|
|
done
|
2016-04-30 15:11:02 -04:00
|
|
|
rm -f outfile
|
2002-09-03 19:19:30 -04:00
|
|
|
done
|
|
|
|
|
|
|
|
cd "$TS/xmlconf/oasis"
|
2004-09-29 22:34:48 -04:00
|
|
|
mkdir -p "$OUTPUT"oasis
|
2002-09-03 19:19:30 -04:00
|
|
|
for xmlfile in *pass*.xml ; do
|
2004-09-29 22:34:48 -04:00
|
|
|
RunXmlwfWF "$xmlfile" "oasis/"
|
|
|
|
UpdateStatus $?
|
2002-09-03 19:19:30 -04:00
|
|
|
done
|
|
|
|
rm outfile
|
|
|
|
|
2002-09-03 23:04:44 -04:00
|
|
|
##############################
|
|
|
|
# not well-formed test cases #
|
|
|
|
##############################
|
|
|
|
|
2002-09-03 19:19:30 -04:00
|
|
|
cd "$TS/xmlconf"
|
2004-09-29 22:34:48 -04:00
|
|
|
for xmldir in ibm/not-wf/P* \
|
2008-08-03 14:19:12 -04:00
|
|
|
ibm/not-wf/p28a \
|
2004-09-29 22:34:48 -04:00
|
|
|
ibm/not-wf/misc \
|
|
|
|
xmltest/not-wf/ext-sa \
|
|
|
|
xmltest/not-wf/not-sa \
|
|
|
|
xmltest/not-wf/sa \
|
|
|
|
sun/not-wf ; do
|
2002-09-03 19:19:30 -04:00
|
|
|
cd "$TS/xmlconf/$xmldir"
|
|
|
|
for xmlfile in *.xml ; do
|
2004-09-29 22:34:48 -04:00
|
|
|
RunXmlwfNotWF "$xmlfile" "$xmldir/"
|
|
|
|
UpdateStatus $?
|
2002-09-03 19:19:30 -04:00
|
|
|
done
|
|
|
|
rm outfile
|
|
|
|
done
|
|
|
|
|
|
|
|
cd "$TS/xmlconf/oasis"
|
|
|
|
for xmlfile in *fail*.xml ; do
|
2004-09-29 22:34:48 -04:00
|
|
|
RunXmlwfNotWF "$xmlfile" "oasis/"
|
|
|
|
UpdateStatus $?
|
2002-09-03 19:19:30 -04:00
|
|
|
done
|
|
|
|
rm outfile
|
|
|
|
|
|
|
|
echo "Passed: $SUCCESS"
|
|
|
|
echo "Failed: $ERROR"
|