2016-04-30 15:11:02 -04:00
|
|
|
#! /usr/bin/env bash
|
2021-05-01 17:52:13 -04:00
|
|
|
# EXPAT TEST SCRIPT FOR W3C XML TEST SUITE
|
|
|
|
#
|
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.
|
2021-05-01 17:52:13 -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.
|
2021-05-01 17:52:13 -04:00
|
|
|
#
|
2002-09-03 19:19:30 -04:00
|
|
|
# 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.
|
2021-05-01 17:52:13 -04:00
|
|
|
#
|
2002-09-03 19:19:30 -04:00
|
|
|
# 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.
|
2021-05-01 17:52:13 -04:00
|
|
|
#
|
|
|
|
# __ __ _
|
|
|
|
# ___\ \/ /_ __ __ _| |_
|
|
|
|
# / _ \\ /| '_ \ / _` | __|
|
|
|
|
# | __// \| |_) | (_| | |_
|
|
|
|
# \___/_/\_\ .__/ \__,_|\__|
|
|
|
|
# |_| XML parser
|
|
|
|
#
|
|
|
|
# Copyright (c) 2002-2004 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
|
|
|
|
# Copyright (c) 2002 Karl Waclawek <karl@waclawek.net>
|
|
|
|
# Copyright (c) 2008-2019 Sebastian Pipping <sebastian@pipping.org>
|
|
|
|
# Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
|
|
|
|
# Licensed under the MIT license:
|
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
# a copy of this software and associated documentation files (the
|
|
|
|
# "Software"), to deal in the Software without restriction, including
|
|
|
|
# without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
|
# persons to whom the Software is furnished to do so, subject to the
|
|
|
|
# following conditions:
|
|
|
|
#
|
|
|
|
# The above copyright notice and this permission notice shall be included
|
|
|
|
# in all copies or substantial portions of the Software.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
|
# NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
|
|
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
|
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
|
# USE OR OTHER DEALINGS IN THE SOFTWARE.
|
2002-09-03 19:19:30 -04:00
|
|
|
|
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"
|
2019-09-05 13:47:16 -04:00
|
|
|
if $XMLWF -p "$file" > /dev/null; 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
|
|
|
|
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
|
|
|
|
|
|
|
|
echo "Passed: $SUCCESS"
|
|
|
|
echo "Failed: $ERROR"
|