mirror of
https://github.com/libexpat/libexpat.git
synced 2025-04-15 00:38:15 +00:00
Update to Karl's version of this script, and use the latest version of
the tests from the W3C.
This commit is contained in:
parent
c6160c2aee
commit
8875cf76db
3 changed files with 128 additions and 48 deletions
|
@ -148,13 +148,14 @@ tests/runtests.o: tests/runtests.c tests/chardata.h
|
|||
tests/runtests: tests/runtests.o tests/chardata.o $(LIBRARY)
|
||||
$(LINK_EXE) $^ -lcheck
|
||||
|
||||
tests/xmltest.zip:
|
||||
cd tests && wget ftp://ftp.jclark.com/pub/xml/xmltest.zip
|
||||
tests/xmlts.zip:
|
||||
wget --output-document=tests/xmlts.zip \
|
||||
http://www.w3.org/XML/Test/xmlts20020606.zip
|
||||
|
||||
tests/xmltest: tests/xmltest.zip
|
||||
cd tests && unzip -q xmltest.zip
|
||||
tests/XML-Test-Suite: tests/xmlts.zip
|
||||
cd tests && unzip -q xmlts.zip
|
||||
|
||||
run-xmltest: xmlwf/xmlwf tests/xmltest
|
||||
run-xmltest: xmlwf/xmlwf tests/XML-Test-Suite
|
||||
tests/xmltest.sh
|
||||
|
||||
.SUFFIXES: .c .lo .o
|
||||
|
|
4
expat/tests/.gitignore
vendored
4
expat/tests/.gitignore
vendored
|
@ -1,5 +1,5 @@
|
|||
Makefile
|
||||
runtests
|
||||
xmltest
|
||||
xmltest.zip
|
||||
xmlts.zip
|
||||
XML-Test-Suite
|
||||
.libs
|
||||
|
|
|
@ -1,48 +1,127 @@
|
|||
#! /bin/sh
|
||||
|
||||
VERBOSE=''
|
||||
# EXPAT TEST SCRIPT FOR W3C XML TEST SUITE
|
||||
|
||||
if [ "$1" = '-v' -o "$1" = '--verbose' ] ; then
|
||||
VERBOSE="$1"
|
||||
shift
|
||||
fi
|
||||
# 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.
|
||||
|
||||
if [ ! "$1" = '' ] ; then
|
||||
ERRORS=0
|
||||
if [ "$VERBOSE" ] ; then
|
||||
OUTPUT="/tmp/$$.out"
|
||||
# To run this script, first set XMLWF so that xmlwf can be
|
||||
# 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.
|
||||
|
||||
# The script does not use "invalid" test cases for validating parsers.
|
||||
# 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.
|
||||
|
||||
MYDIR="`dirname \"$0\"`"
|
||||
cd "$MYDIR"
|
||||
MYDIR="`pwd`"
|
||||
XMLWF="`dirname \"$MYDIR\"`/xmlwf/xmlwf"
|
||||
# XMLWF=/usr/local/bin/xmlwf
|
||||
# XMLWF=f:/Libraries/XML/expat/xmlwf/release/xmlwf
|
||||
TS="$MYDIR/XML-Test-Suite"
|
||||
# OUTPUT must terminate with the directory separater.
|
||||
OUTPUT="$TS/out/"
|
||||
# OUTPUT=/home/tmp/xml-testsuite-out/
|
||||
# OUTPUT=f:/Libraries/XML/XML-Test-Suite/out/
|
||||
|
||||
RunXmlwfNotWF() {
|
||||
$XMLWF $1 $2 > outfile || return $?
|
||||
read outdata < outfile
|
||||
if test "$outdata" = "" ; then
|
||||
echo "Well formed: $3$2"
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
RunXmlwfWF() {
|
||||
$XMLWF $1 -d "$OUTPUT$3" $2 > outfile || return $?
|
||||
read outdata < outfile
|
||||
if test "$outdata" = "" ; then
|
||||
if [ -f out/$2 ] ; then
|
||||
diff "$OUTPUT$3$2" out/$2 > outfile
|
||||
if [ -s outfile ] ; then
|
||||
cp outfile $OUTPUT$3${2}.diff
|
||||
echo "Output differs: $3$2"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
else
|
||||
echo "In $3: $outdata"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
SUCCESS=0
|
||||
ERROR=0
|
||||
|
||||
cd "$TS/xmlconf"
|
||||
for xmldir in ibm/valid/P*/ \
|
||||
xmltest/valid/ext-sa/ \
|
||||
xmltest/valid/not-sa/ \
|
||||
xmltest/valid/sa/ \
|
||||
sun/valid/ ; do
|
||||
cd "$TS/xmlconf/$xmldir"
|
||||
mkdir -p "$OUTPUT$xmldir"
|
||||
for xmlfile in *.xml ; do
|
||||
if RunXmlwfWF -p "$xmlfile" "$xmldir" ; then
|
||||
SUCCESS=`expr $SUCCESS + 1`
|
||||
else
|
||||
ERROR=`expr $ERROR + 1`
|
||||
fi
|
||||
done
|
||||
rm outfile
|
||||
done
|
||||
|
||||
cd "$TS/xmlconf/oasis"
|
||||
mkdir -p "$OUTPUT"oasis/
|
||||
for xmlfile in *pass*.xml ; do
|
||||
if RunXmlwfWF -p "$xmlfile" "oasis/" ; then
|
||||
SUCCESS=`expr $SUCCESS + 1`
|
||||
else
|
||||
OUTPUT="/dev/null"
|
||||
ERROR=`expr $ERROR + 1`
|
||||
fi
|
||||
while [ "$1" ] ; do
|
||||
FILE="`basename \"$1\"`"
|
||||
DIR="`dirname \"$1\"`"
|
||||
DIR="`dirname \"$DIR\"`"
|
||||
../xmlwf/xmlwf -d /tmp "$DIR/$FILE"
|
||||
diff -u "$DIR/out/$FILE" "/tmp/$FILE" >$OUTPUT
|
||||
ERR=$?
|
||||
rm "/tmp/$FILE"
|
||||
if [ ! "$ERR" = 0 ] ; then
|
||||
ERRORS=`expr $ERRORS + 1`
|
||||
echo "$DIR/$FILE ... Error"
|
||||
cat $OUTPUT
|
||||
elif [ "$VERBOSE" ] ; then
|
||||
echo "$DIR/$FILE ... Ok"
|
||||
fi
|
||||
shift
|
||||
done
|
||||
if [ "$VERBOSE" ] ; then
|
||||
rm $OUTPUT
|
||||
done
|
||||
rm outfile
|
||||
|
||||
cd "$TS/xmlconf"
|
||||
for xmldir in ibm/not-wf/P*/ \
|
||||
ibm/not-wf/misc/ \
|
||||
xmltest/not-wf/ext-sa/ \
|
||||
xmltest/not-wf/not-sa/ \
|
||||
xmltest/not-wf/sa/ \
|
||||
sun/not-wf/ ; do
|
||||
cd "$TS/xmlconf/$xmldir"
|
||||
for xmlfile in *.xml ; do
|
||||
if RunXmlwfNotWF -p "$xmlfile" "$xmldir" ; then
|
||||
SUCCESS=`expr $SUCCESS + 1`
|
||||
else
|
||||
ERROR=`expr $ERROR + 1`
|
||||
fi
|
||||
done
|
||||
rm outfile
|
||||
done
|
||||
|
||||
cd "$TS/xmlconf/oasis"
|
||||
for xmlfile in *fail*.xml ; do
|
||||
if RunXmlwfNotWF -p "$xmlfile" "oasis/" ; then
|
||||
SUCCESS=`expr $SUCCESS + 1`
|
||||
else
|
||||
ERROR=`expr $ERROR + 1`
|
||||
fi
|
||||
if [ ! "$ERRORS" = '0' ] ; then
|
||||
echo " Errors: $ERRORS"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
SCRIPTDIR="`dirname \"$0\"`"
|
||||
cd "$SCRIPTDIR"
|
||||
find xmltest -name \*.xml | grep /out/ | xargs ./xmltest.sh $VERBOSE
|
||||
if [ ! "$?" = "0" ] ; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
rm outfile
|
||||
|
||||
echo "Passed: $SUCCESS"
|
||||
echo "Failed: $ERROR"
|
||||
|
|
Loading…
Add table
Reference in a new issue