Refactoring some of the code in RunTest
This commit is contained in:
parent
3ab47d70b0
commit
3934d4b4fc
182
RunTest
182
RunTest
|
@ -114,6 +114,35 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# ------ Function to check results of a test -------
|
||||||
|
|
||||||
|
# This function is called with three parameters:
|
||||||
|
#
|
||||||
|
# $1 the value of $? after a call to pcre2test
|
||||||
|
# $2 the suffix of the output file to compare with
|
||||||
|
# $3 the $opt value (empty, -jit, or -dfa)
|
||||||
|
|
||||||
|
function checkresult()
|
||||||
|
{
|
||||||
|
if [ $1 -ne 0 ] ; then
|
||||||
|
echo "** pcre2test failed - check testtry"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
case "$3" in
|
||||||
|
-jit) with=" with JIT";;
|
||||||
|
-dfa) with=" with DFA";;
|
||||||
|
*) with="";;
|
||||||
|
esac
|
||||||
|
$cf $testdata/testoutput$2 testtry
|
||||||
|
if [ $? != 0 ] ; then
|
||||||
|
echo ""
|
||||||
|
echo "** Test $2 failed$with"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo " OK$with"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# ------ Special EBCDIC Test -------
|
# ------ Special EBCDIC Test -------
|
||||||
|
|
||||||
if [ $# -eq 1 -a "$1" = "ebcdic" ]; then
|
if [ $# -eq 1 -a "$1" = "ebcdic" ]; then
|
||||||
|
@ -123,19 +152,10 @@ if [ $# -eq 1 -a "$1" = "ebcdic" ]; then
|
||||||
echo "Cannot run EBCDIC tests: EBCDIC support not compiled"
|
echo "Cannot run EBCDIC tests: EBCDIC support not compiled"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for opt in "" "-dfa"; do
|
for opt in "" "-dfa"; do
|
||||||
./pcre2test -q $opt $testdata/testinputEBC >testtry
|
./pcre2test -q $opt $testdata/testinputEBC >testtry
|
||||||
if [ $? = 0 ] ; then
|
checkresult $? EBC "$opt"
|
||||||
$cf $testdata/testoutputEBC testtry
|
|
||||||
if [ $? != 0 ] ; then exit 1; fi
|
|
||||||
else exit 1
|
|
||||||
fi
|
|
||||||
if [ "$opt" = "-dfa" ] ; then echo " OK using DFA"
|
|
||||||
else echo " OK"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -371,14 +391,7 @@ if [ $do1 = yes ] ; then
|
||||||
echo $title1
|
echo $title1
|
||||||
for opt in "" $jitopt; do
|
for opt in "" $jitopt; do
|
||||||
$sim $valgrind ./pcre2test -q $bmode $opt $testdata/testinput1 testtry
|
$sim $valgrind ./pcre2test -q $bmode $opt $testdata/testinput1 testtry
|
||||||
if [ $? = 0 ] ; then
|
checkresult $? 1 "$opt"
|
||||||
$cf $testdata/testoutput1 testtry
|
|
||||||
if [ $? != 0 ] ; then exit 1; fi
|
|
||||||
else exit 1
|
|
||||||
fi
|
|
||||||
if [ "$opt" = "-jit" ] ; then echo " OK with JIT"
|
|
||||||
else echo " OK"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -389,8 +402,7 @@ if [ $do2 = yes ] ; then
|
||||||
for opt in "" $jitopt; do
|
for opt in "" $jitopt; do
|
||||||
$sim $valgrind ./pcre2test -q $bmode $opt $testdata/testinput2 testtry
|
$sim $valgrind ./pcre2test -q $bmode $opt $testdata/testinput2 testtry
|
||||||
if [ $? = 0 ] ; then
|
if [ $? = 0 ] ; then
|
||||||
$cf $testdata/testoutput2 testtry
|
checkresult $? 2 "$opt"
|
||||||
if [ $? != 0 ] ; then exit 1; fi
|
|
||||||
else
|
else
|
||||||
echo " "
|
echo " "
|
||||||
echo "** Test 2 requires a lot of stack. If it has crashed with a"
|
echo "** Test 2 requires a lot of stack. If it has crashed with a"
|
||||||
|
@ -400,9 +412,6 @@ if [ $do2 = yes ] ; then
|
||||||
echo " "
|
echo " "
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [ "$opt" = "-jit" ] ; then echo " OK with JIT"
|
|
||||||
else echo " OK"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -451,15 +460,17 @@ if [ $do3 = yes ] ; then
|
||||||
for opt in "" $jitopt; do
|
for opt in "" $jitopt; do
|
||||||
$sim $valgrind ./pcre2test -q $bmode $opt $infile testtry
|
$sim $valgrind ./pcre2test -q $bmode $opt $infile testtry
|
||||||
if [ $? = 0 ] ; then
|
if [ $? = 0 ] ; then
|
||||||
|
case "$opt" in
|
||||||
|
-jit) with=" with JIT";;
|
||||||
|
*) with="";;
|
||||||
|
esac
|
||||||
if $cf $outfile testtry >teststdout || \
|
if $cf $outfile testtry >teststdout || \
|
||||||
$cf $outfile2 testtry >teststdout || \
|
$cf $outfile2 testtry >teststdout || \
|
||||||
$cf $outfile3 testtry >teststdout
|
$cf $outfile3 testtry >teststdout
|
||||||
then
|
then
|
||||||
if [ "$opt" = "-jit" ] ; then echo " OK with JIT"
|
echo " OK$with"
|
||||||
else echo " OK"
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
echo "** Locale test did not run successfully. The output did not match"
|
echo "** Locale test did not run successfully$with. The output did not match"
|
||||||
echo " $outfile, $outfile2 or $outfile3."
|
echo " $outfile, $outfile2 or $outfile3."
|
||||||
echo " This may mean that there is a problem with the locale settings rather"
|
echo " This may mean that there is a problem with the locale settings rather"
|
||||||
echo " than a bug in PCRE2."
|
echo " than a bug in PCRE2."
|
||||||
|
@ -485,14 +496,7 @@ if [ $do4 = yes ] ; then
|
||||||
else
|
else
|
||||||
for opt in "" $jitopt; do
|
for opt in "" $jitopt; do
|
||||||
$sim $valgrind ./pcre2test -q $bmode $opt $testdata/testinput4 testtry
|
$sim $valgrind ./pcre2test -q $bmode $opt $testdata/testinput4 testtry
|
||||||
if [ $? = 0 ] ; then
|
checkresult $? 4 "$opt"
|
||||||
$cf $testdata/testoutput4 testtry
|
|
||||||
if [ $? != 0 ] ; then exit 1; fi
|
|
||||||
else exit 1
|
|
||||||
fi
|
|
||||||
if [ "$opt" = "-jit" ] ; then echo " OK with JIT"
|
|
||||||
else echo " OK"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -504,14 +508,7 @@ if [ $do5 = yes ] ; then
|
||||||
else
|
else
|
||||||
for opt in "" $jitopt; do
|
for opt in "" $jitopt; do
|
||||||
$sim $valgrind ./pcre2test -q $bmode $opt $testdata/testinput5 testtry
|
$sim $valgrind ./pcre2test -q $bmode $opt $testdata/testinput5 testtry
|
||||||
if [ $? = 0 ] ; then
|
checkresult $? 5 "$opt"
|
||||||
$cf $testdata/testoutput5 testtry
|
|
||||||
if [ $? != 0 ] ; then exit 1; fi
|
|
||||||
else exit 1
|
|
||||||
fi
|
|
||||||
if [ "$opt" = "-jit" ] ; then echo " OK with JIT"
|
|
||||||
else echo " OK"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -521,12 +518,7 @@ fi
|
||||||
if [ $do6 = yes ] ; then
|
if [ $do6 = yes ] ; then
|
||||||
echo $title6
|
echo $title6
|
||||||
$sim $valgrind ./pcre2test -q $bmode $testdata/testinput6 testtry
|
$sim $valgrind ./pcre2test -q $bmode $testdata/testinput6 testtry
|
||||||
if [ $? = 0 ] ; then
|
checkresult $? 6 ""
|
||||||
$cf $testdata/testoutput6 testtry
|
|
||||||
if [ $? != 0 ] ; then exit 1; fi
|
|
||||||
else exit 1
|
|
||||||
fi
|
|
||||||
echo " OK"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $do7 = yes ] ; then
|
if [ $do7 = yes ] ; then
|
||||||
|
@ -535,12 +527,7 @@ if [ $do7 = yes ] ; then
|
||||||
echo " Skipped because UTF-$bits support is not available"
|
echo " Skipped because UTF-$bits support is not available"
|
||||||
else
|
else
|
||||||
$sim $valgrind ./pcre2test -q $bmode $opt $testdata/testinput7 testtry
|
$sim $valgrind ./pcre2test -q $bmode $opt $testdata/testinput7 testtry
|
||||||
if [ $? = 0 ] ; then
|
checkresult $? 7 ""
|
||||||
$cf $testdata/testoutput7 testtry
|
|
||||||
if [ $? != 0 ] ; then exit 1; fi
|
|
||||||
else exit 1
|
|
||||||
fi
|
|
||||||
echo " OK"
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -560,12 +547,7 @@ if [ $do8 = yes ] ; then
|
||||||
echo " Skipped because UTF-$bits support is not available"
|
echo " Skipped because UTF-$bits support is not available"
|
||||||
else
|
else
|
||||||
$sim $valgrind ./pcre2test -q $bmode $testdata/testinput8 testtry
|
$sim $valgrind ./pcre2test -q $bmode $testdata/testinput8 testtry
|
||||||
if [ $? = 0 ] ; then
|
checkresult $? 8-$bits ""
|
||||||
$cf $testdata/testoutput8-$bits testtry
|
|
||||||
if [ $? != 0 ] ; then exit 1; fi
|
|
||||||
else exit 1
|
|
||||||
fi
|
|
||||||
echo " OK"
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -578,14 +560,7 @@ if [ "$do9" = yes ] ; then
|
||||||
else
|
else
|
||||||
for opt in "" $jitopt; do
|
for opt in "" $jitopt; do
|
||||||
$sim $valgrind ./pcre2test -q $bmode $opt $testdata/testinput9 testtry
|
$sim $valgrind ./pcre2test -q $bmode $opt $testdata/testinput9 testtry
|
||||||
if [ $? = 0 ] ; then
|
checkresult $? 9 "$opt"
|
||||||
$cf $testdata/testoutput9 testtry
|
|
||||||
if [ $? != 0 ] ; then exit 1; fi
|
|
||||||
else exit 1
|
|
||||||
fi
|
|
||||||
if [ "$opt" = "-jit" ] ; then echo " OK with JIT"
|
|
||||||
else echo " OK"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -601,14 +576,7 @@ if [ "$do10" = yes ] ; then
|
||||||
else
|
else
|
||||||
for opt in "" $jitopt; do
|
for opt in "" $jitopt; do
|
||||||
$sim $valgrind ./pcre2test -q $bmode $opt $testdata/testinput10 testtry
|
$sim $valgrind ./pcre2test -q $bmode $opt $testdata/testinput10 testtry
|
||||||
if [ $? = 0 ] ; then
|
checkresult $? 10 "$opt"
|
||||||
$cf $testdata/testoutput10 testtry
|
|
||||||
if [ $? != 0 ] ; then exit 1; fi
|
|
||||||
else exit 1
|
|
||||||
fi
|
|
||||||
if [ "$opt" = "-jit" ] ; then echo " OK with JIT"
|
|
||||||
else echo " OK"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -622,14 +590,7 @@ if [ $do11 = yes ] ; then
|
||||||
else
|
else
|
||||||
for opt in "" $jitopt; do
|
for opt in "" $jitopt; do
|
||||||
$sim $valgrind ./pcre2test -q $bmode $opt $testdata/testinput11 testtry
|
$sim $valgrind ./pcre2test -q $bmode $opt $testdata/testinput11 testtry
|
||||||
if [ $? = 0 ] ; then
|
checkresult $? 11-$bits "$opt"
|
||||||
$cf $testdata/testoutput11-$bits testtry
|
|
||||||
if [ $? != 0 ] ; then exit 1; fi
|
|
||||||
else exit 1
|
|
||||||
fi
|
|
||||||
if [ "$opt" = "-jit" ] ; then echo " OK with JIT"
|
|
||||||
else echo " OK"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -646,14 +607,7 @@ if [ $do12 = yes ] ; then
|
||||||
else
|
else
|
||||||
for opt in "" $jitopt; do
|
for opt in "" $jitopt; do
|
||||||
$sim $valgrind ./pcre2test -q $bmode $opt $testdata/testinput12 testtry
|
$sim $valgrind ./pcre2test -q $bmode $opt $testdata/testinput12 testtry
|
||||||
if [ $? = 0 ] ; then
|
checkresult $? 12-$bits "$opt"
|
||||||
$cf $testdata/testoutput12-$bits testtry
|
|
||||||
if [ $? != 0 ] ; then exit 1; fi
|
|
||||||
else exit 1
|
|
||||||
fi
|
|
||||||
if [ "$opt" = "-jit" ] ; then echo " OK with JIT"
|
|
||||||
else echo " OK"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -666,12 +620,7 @@ if [ $do13 = yes ] ; then
|
||||||
echo " Skipped when running 8-bit tests"
|
echo " Skipped when running 8-bit tests"
|
||||||
else
|
else
|
||||||
$sim $valgrind ./pcre2test -q $bmode $testdata/testinput13 testtry
|
$sim $valgrind ./pcre2test -q $bmode $testdata/testinput13 testtry
|
||||||
if [ $? = 0 ] ; then
|
checkresult $? 13 ""
|
||||||
$cf $testdata/testoutput13 testtry
|
|
||||||
if [ $? != 0 ] ; then exit 1; fi
|
|
||||||
else exit 1
|
|
||||||
fi
|
|
||||||
echo " OK"
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -680,12 +629,7 @@ fi
|
||||||
if [ $do14 = yes ] ; then
|
if [ $do14 = yes ] ; then
|
||||||
echo $title14
|
echo $title14
|
||||||
$sim $valgrind ./pcre2test -q $bmode $testdata/testinput14 testtry
|
$sim $valgrind ./pcre2test -q $bmode $testdata/testinput14 testtry
|
||||||
if [ $? = 0 ] ; then
|
checkresult $? 14 ""
|
||||||
$cf $testdata/testoutput14 testtry
|
|
||||||
if [ $? != 0 ] ; then exit 1; fi
|
|
||||||
else exit 1
|
|
||||||
fi
|
|
||||||
echo " OK"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Test JIT-specific features when JIT is not available
|
# Test JIT-specific features when JIT is not available
|
||||||
|
@ -696,12 +640,7 @@ if [ $do15 = yes ] ; then
|
||||||
echo " Skipped because JIT is available"
|
echo " Skipped because JIT is available"
|
||||||
else
|
else
|
||||||
$sim $valgrind ./pcre2test -q $bmode $testdata/testinput15 testtry
|
$sim $valgrind ./pcre2test -q $bmode $testdata/testinput15 testtry
|
||||||
if [ $? = 0 ] ; then
|
checkresult $? 15 ""
|
||||||
$cf $testdata/testoutput15 testtry
|
|
||||||
if [ $? != 0 ] ; then exit 1; fi
|
|
||||||
else exit 1
|
|
||||||
fi
|
|
||||||
echo " OK"
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -713,12 +652,7 @@ if [ $do16 = yes ] ; then
|
||||||
echo " Skipped because JIT is not available or not usable"
|
echo " Skipped because JIT is not available or not usable"
|
||||||
else
|
else
|
||||||
$sim $valgrind ./pcre2test -q $bmode $testdata/testinput16 testtry
|
$sim $valgrind ./pcre2test -q $bmode $testdata/testinput16 testtry
|
||||||
if [ $? = 0 ] ; then
|
checkresult $? 16 ""
|
||||||
$cf $testdata/testoutput16 testtry
|
|
||||||
if [ $? != 0 ] ; then exit 1; fi
|
|
||||||
else exit 1
|
|
||||||
fi
|
|
||||||
echo " OK"
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -730,12 +664,7 @@ if [ $do17 = yes ] ; then
|
||||||
echo " Skipped when running 16/32-bit tests"
|
echo " Skipped when running 16/32-bit tests"
|
||||||
else
|
else
|
||||||
$sim $valgrind ./pcre2test -q $bmode $testdata/testinput17 testtry
|
$sim $valgrind ./pcre2test -q $bmode $testdata/testinput17 testtry
|
||||||
if [ $? = 0 ] ; then
|
checkresult $? 17 ""
|
||||||
$cf $testdata/testoutput17 testtry
|
|
||||||
if [ $? != 0 ] ; then exit 1; fi
|
|
||||||
else exit 1
|
|
||||||
fi
|
|
||||||
echo " OK"
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -749,12 +678,7 @@ if [ $do18 = yes ] ; then
|
||||||
echo " Skipped because UTF-$bits support is not available"
|
echo " Skipped because UTF-$bits support is not available"
|
||||||
else
|
else
|
||||||
$sim $valgrind ./pcre2test -q $bmode $testdata/testinput18 testtry
|
$sim $valgrind ./pcre2test -q $bmode $testdata/testinput18 testtry
|
||||||
if [ $? = 0 ] ; then
|
checkresult $? 18 ""
|
||||||
$cf $testdata/testoutput18 testtry
|
|
||||||
if [ $? != 0 ] ; then exit 1; fi
|
|
||||||
else exit 1
|
|
||||||
fi
|
|
||||||
echo " OK"
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue