| 1 |
#! /bin/sh |
#! /bin/sh |
| 2 |
|
|
| 3 |
# Run PCRE tests |
# Run PCRE tests. |
| 4 |
|
|
|
cf="diff -u" |
|
| 5 |
valgrind= |
valgrind= |
|
testdata=testdata |
|
| 6 |
|
|
| 7 |
|
# Set up a suitable "diff" command for comparison. Some systems |
| 8 |
|
# have a diff that lacks a -u option. Try to deal with this. |
| 9 |
|
|
| 10 |
|
if diff -u /dev/null /dev/null; then cf="diff -u"; else cf="diff"; fi |
| 11 |
|
|
| 12 |
|
# Find the test data |
| 13 |
|
|
| 14 |
|
testdata=testdata |
| 15 |
if [ -n "$srcdir" -a -d "$srcdir" ] ; then |
if [ -n "$srcdir" -a -d "$srcdir" ] ; then |
| 16 |
testdata="$srcdir/testdata" |
testdata="$srcdir/testdata" |
| 17 |
fi |
fi |
| 43 |
do7=no |
do7=no |
| 44 |
do8=no |
do8=no |
| 45 |
do9=no |
do9=no |
| 46 |
|
do10=no |
| 47 |
|
|
| 48 |
while [ $# -gt 0 ] ; do |
while [ $# -gt 0 ] ; do |
| 49 |
case $1 in |
case $1 in |
| 56 |
7) do7=yes;; |
7) do7=yes;; |
| 57 |
8) do8=yes;; |
8) do8=yes;; |
| 58 |
9) do9=yes;; |
9) do9=yes;; |
| 59 |
valgrind) valgrind="valgrind -q";; |
10) do10=yes;; |
| 60 |
|
valgrind) valgrind="valgrind -q";; |
| 61 |
*) echo "Unknown test number $1"; exit 1;; |
*) echo "Unknown test number $1"; exit 1;; |
| 62 |
esac |
esac |
| 63 |
shift |
shift |
| 64 |
done |
done |
| 65 |
|
|
|
if [ "$link_size" != "2" ] ; then |
|
|
if [ $do2 = yes ] ; then |
|
|
echo "Can't run test 2 with an internal link size other than 2" |
|
|
exit 1 |
|
|
fi |
|
|
if [ $do5 = yes ] ; then |
|
|
echo "Can't run test 5 with an internal link size other than 2" |
|
|
exit 1 |
|
|
fi |
|
|
if [ $do6 = yes ] ; then |
|
|
echo "Can't run test 6 with an internal link size other than 2" |
|
|
exit 1 |
|
|
fi |
|
|
fi |
|
|
|
|
| 66 |
if [ $utf8 -eq 0 ] ; then |
if [ $utf8 -eq 0 ] ; then |
| 67 |
if [ $do4 = yes ] ; then |
if [ $do4 = yes ] ; then |
| 68 |
echo "Can't run test 4 because UTF-8 support is not configured" |
echo "Can't run test 4 because UTF-8 support is not configured" |
| 72 |
echo "Can't run test 5 because UTF-8 support is not configured" |
echo "Can't run test 5 because UTF-8 support is not configured" |
| 73 |
exit 1 |
exit 1 |
| 74 |
fi |
fi |
|
if [ $do6 = yes ] ; then |
|
|
echo "Can't run test 6 because UTF-8 support is not configured" |
|
|
exit 1 |
|
|
fi |
|
| 75 |
if [ $do8 = yes ] ; then |
if [ $do8 = yes ] ; then |
| 76 |
echo "Can't run test 8 because UTF-8 support is not configured" |
echo "Can't run test 8 because UTF-8 support is not configured" |
| 77 |
exit 1 |
exit 1 |
| 78 |
fi |
fi |
|
if [ $do9 = yes ] ; then |
|
|
echo "Can't run test 9 because UTF-8 support is not configured" |
|
|
exit 1 |
|
|
fi |
|
| 79 |
fi |
fi |
| 80 |
|
|
| 81 |
if [ $ucp -eq 0 ] ; then |
if [ $ucp -eq 0 ] ; then |
| 87 |
echo "Can't run test 9 because Unicode property support is not configured" |
echo "Can't run test 9 because Unicode property support is not configured" |
| 88 |
exit 1 |
exit 1 |
| 89 |
fi |
fi |
| 90 |
|
if [ $do10 = yes ] ; then |
| 91 |
|
echo "Can't run test 10 because Unicode property support is not configured" |
| 92 |
|
exit 1 |
| 93 |
|
fi |
| 94 |
|
fi |
| 95 |
|
|
| 96 |
|
if [ $link_size -ne 2 ] ; then |
| 97 |
|
if [ $do10 = yes ] ; then |
| 98 |
|
echo "Can't run test 10 because the link size ($link_size) is not 2" |
| 99 |
|
exit 1 |
| 100 |
|
fi |
| 101 |
fi |
fi |
| 102 |
|
|
| 103 |
# If no specific tests were requested, select all that are relevant. |
# If no specific tests were requested, select all that are relevant. |
| 104 |
|
|
| 105 |
if [ $do1 = no -a $do2 = no -a $do3 = no -a $do4 = no -a \ |
if [ $do1 = no -a $do2 = no -a $do3 = no -a $do4 = no -a \ |
| 106 |
$do5 = no -a $do6 = no -a $do7 = no -a $do8 = no -a \ |
$do5 = no -a $do6 = no -a $do7 = no -a $do8 = no -a \ |
| 107 |
$do9 = no ] ; then |
$do9 = no -a $do10 = no ] ; then |
| 108 |
do1=yes |
do1=yes |
| 109 |
do2=yes |
do2=yes |
| 110 |
do3=yes |
do3=yes |
| 114 |
do7=yes |
do7=yes |
| 115 |
if [ $utf8 -ne 0 ] ; then do8=yes; fi |
if [ $utf8 -ne 0 ] ; then do8=yes; fi |
| 116 |
if [ $utf8 -ne 0 -a $ucp -ne 0 ] ; then do9=yes; fi |
if [ $utf8 -ne 0 -a $ucp -ne 0 ] ; then do9=yes; fi |
| 117 |
|
if [ $link_size -eq 2 -a $ucp -ne 0 ] ; then do10=yes; fi |
| 118 |
fi |
fi |
| 119 |
|
|
| 120 |
# Show which release |
# Show which release |
| 129 |
echo "Test 1: main functionality (Perl compatible)" |
echo "Test 1: main functionality (Perl compatible)" |
| 130 |
$valgrind ./pcretest -q $testdata/testinput1 testtry |
$valgrind ./pcretest -q $testdata/testinput1 testtry |
| 131 |
if [ $? = 0 ] ; then |
if [ $? = 0 ] ; then |
| 132 |
$cf testtry $testdata/testoutput1 |
$cf $testdata/testoutput1 testtry |
| 133 |
if [ $? != 0 ] ; then exit 1; fi |
if [ $? != 0 ] ; then exit 1; fi |
| 134 |
else exit 1 |
else exit 1 |
| 135 |
fi |
fi |
| 139 |
# PCRE tests that are not Perl-compatible - API & error tests, mostly |
# PCRE tests that are not Perl-compatible - API & error tests, mostly |
| 140 |
|
|
| 141 |
if [ $do2 = yes ] ; then |
if [ $do2 = yes ] ; then |
| 142 |
if [ "$link_size" = "2" ] ; then |
echo "Test 2: API and error handling (not Perl compatible)" |
| 143 |
echo "Test 2: API and error handling (not Perl compatible)" |
$valgrind ./pcretest -q $testdata/testinput2 testtry |
| 144 |
$valgrind ./pcretest -q $testdata/testinput2 testtry |
if [ $? = 0 ] ; then |
| 145 |
if [ $? = 0 ] ; then |
$cf $testdata/testoutput2 testtry |
| 146 |
$cf testtry $testdata/testoutput2 |
if [ $? != 0 ] ; then exit 1; fi |
| 147 |
if [ $? != 0 ] ; then exit 1; fi |
else exit 1 |
|
else exit 1 |
|
|
fi |
|
|
echo "OK" |
|
|
else |
|
|
echo Test 2 skipped for link size other than 2 \($link_size\) |
|
|
echo " " |
|
| 148 |
fi |
fi |
| 149 |
|
echo "OK" |
| 150 |
fi |
fi |
| 151 |
|
|
| 152 |
# Locale-specific tests, provided the "fr_FR" locale is available. |
# Locale-specific tests, provided that either the "fr_FR" or the "french" |
| 153 |
# TODO: Try the locale name "french" instead - as used on Windows - but |
# locale is available. The former is the Unix-like standard; the latter is |
| 154 |
# this will mean modifying the input and output data. |
# for Windows. |
| 155 |
|
|
| 156 |
if [ $do3 = yes ] ; then |
if [ $do3 = yes ] ; then |
| 157 |
locale -a | grep '^fr_FR$' >/dev/null |
locale -a | grep '^fr_FR$' >/dev/null |
| 158 |
if [ $? -eq 0 ] ; then |
if [ $? -eq 0 ] ; then |
| 159 |
echo "Test 3: locale-specific features (using 'fr_FR' locale)" |
locale=fr_FR |
| 160 |
$valgrind ./pcretest -q $testdata/testinput3 testtry |
infile=$testdata/testinput3 |
| 161 |
|
outfile=$testdata/testoutput3 |
| 162 |
|
else |
| 163 |
|
locale -a | grep '^french$' >/dev/null |
| 164 |
|
if [ $? -eq 0 ] ; then |
| 165 |
|
locale=french |
| 166 |
|
sed 's/fr_FR/french/' $testdata/testinput3 >test3input |
| 167 |
|
sed 's/fr_FR/french/' $testdata/testoutput3 >test3output |
| 168 |
|
infile=test3input |
| 169 |
|
outfile=test3output |
| 170 |
|
else |
| 171 |
|
locale= |
| 172 |
|
fi |
| 173 |
|
fi |
| 174 |
|
|
| 175 |
|
if [ "$locale" != "" ] ; then |
| 176 |
|
echo "Test 3: locale-specific features (using '$locale' locale)" |
| 177 |
|
$valgrind ./pcretest -q $infile testtry |
| 178 |
if [ $? = 0 ] ; then |
if [ $? = 0 ] ; then |
| 179 |
$cf testtry $testdata/testoutput3 |
$cf $outfile testtry |
| 180 |
if [ $? != 0 ] ; then |
if [ $? != 0 ] ; then |
| 181 |
echo " " |
echo " " |
| 182 |
echo "Locale test did not run entirely successfully." |
echo "Locale test did not run entirely successfully." |
| 188 |
else exit 1 |
else exit 1 |
| 189 |
fi |
fi |
| 190 |
else |
else |
| 191 |
echo "Cannot test locale-specific features - 'fr_FR' locale not found," |
echo "Cannot test locale-specific features - neither the 'fr_FR' nor the" |
| 192 |
echo "or the \"locale\" command is not available to check for it." |
echo "'french' locale exists, or the \"locale\" command is not available" |
| 193 |
|
echo "to check for them." |
| 194 |
echo " " |
echo " " |
| 195 |
fi |
fi |
| 196 |
fi |
fi |
| 201 |
echo "Test 4: UTF-8 support (Perl compatible)" |
echo "Test 4: UTF-8 support (Perl compatible)" |
| 202 |
$valgrind ./pcretest -q $testdata/testinput4 testtry |
$valgrind ./pcretest -q $testdata/testinput4 testtry |
| 203 |
if [ $? = 0 ] ; then |
if [ $? = 0 ] ; then |
| 204 |
$cf testtry $testdata/testoutput4 |
$cf $testdata/testoutput4 testtry |
| 205 |
if [ $? != 0 ] ; then exit 1; fi |
if [ $? != 0 ] ; then exit 1; fi |
| 206 |
else exit 1 |
else exit 1 |
| 207 |
fi |
fi |
| 209 |
fi |
fi |
| 210 |
|
|
| 211 |
if [ $do5 = yes ] ; then |
if [ $do5 = yes ] ; then |
| 212 |
if [ "$link_size" = "2" ] ; then |
echo "Test 5: API and internals for UTF-8 support (not Perl compatible)" |
| 213 |
echo "Test 5: API and internals for UTF-8 support (not Perl compatible)" |
$valgrind ./pcretest -q $testdata/testinput5 testtry |
| 214 |
$valgrind ./pcretest -q $testdata/testinput5 testtry |
if [ $? = 0 ] ; then |
| 215 |
if [ $? = 0 ] ; then |
$cf $testdata/testoutput5 testtry |
| 216 |
$cf testtry $testdata/testoutput5 |
if [ $? != 0 ] ; then exit 1; fi |
| 217 |
if [ $? != 0 ] ; then exit 1; fi |
else exit 1 |
|
else exit 1 |
|
|
fi |
|
|
echo "OK" |
|
|
else |
|
|
echo Test 5 skipped for link size other than 2 \($link_size\) |
|
|
echo " " |
|
| 218 |
fi |
fi |
| 219 |
|
echo "OK" |
| 220 |
fi |
fi |
| 221 |
|
|
| 222 |
if [ $do6 = yes ] ; then |
if [ $do6 = yes ] ; then |
| 223 |
if [ "$link_size" = "2" ] ; then |
echo "Test 6: Unicode property support" |
| 224 |
echo "Test 6: Unicode property support" |
$valgrind ./pcretest -q $testdata/testinput6 testtry |
| 225 |
$valgrind ./pcretest -q $testdata/testinput6 testtry |
if [ $? = 0 ] ; then |
| 226 |
if [ $? = 0 ] ; then |
$cf $testdata/testoutput6 testtry |
| 227 |
$cf testtry $testdata/testoutput6 |
if [ $? != 0 ] ; then exit 1; fi |
| 228 |
if [ $? != 0 ] ; then exit 1; fi |
else exit 1 |
|
else exit 1 |
|
|
fi |
|
|
echo "OK" |
|
|
else |
|
|
echo Test 6 skipped for link size other than 2 \($link_size\) |
|
|
echo " " |
|
| 229 |
fi |
fi |
| 230 |
|
echo "OK" |
| 231 |
fi |
fi |
| 232 |
|
|
| 233 |
# Tests for DFA matching support |
# Tests for DFA matching support |
| 236 |
echo "Test 7: DFA matching" |
echo "Test 7: DFA matching" |
| 237 |
$valgrind ./pcretest -q -dfa $testdata/testinput7 testtry |
$valgrind ./pcretest -q -dfa $testdata/testinput7 testtry |
| 238 |
if [ $? = 0 ] ; then |
if [ $? = 0 ] ; then |
| 239 |
$cf testtry $testdata/testoutput7 |
$cf $testdata/testoutput7 testtry |
| 240 |
if [ $? != 0 ] ; then exit 1; fi |
if [ $? != 0 ] ; then exit 1; fi |
| 241 |
else exit 1 |
else exit 1 |
| 242 |
fi |
fi |
| 247 |
echo "Test 8: DFA matching with UTF-8" |
echo "Test 8: DFA matching with UTF-8" |
| 248 |
$valgrind ./pcretest -q -dfa $testdata/testinput8 testtry |
$valgrind ./pcretest -q -dfa $testdata/testinput8 testtry |
| 249 |
if [ $? = 0 ] ; then |
if [ $? = 0 ] ; then |
| 250 |
$cf testtry $testdata/testoutput8 |
$cf $testdata/testoutput8 testtry |
| 251 |
if [ $? != 0 ] ; then exit 1; fi |
if [ $? != 0 ] ; then exit 1; fi |
| 252 |
else exit 1 |
else exit 1 |
| 253 |
fi |
fi |
| 258 |
echo "Test 9: DFA matching with Unicode properties" |
echo "Test 9: DFA matching with Unicode properties" |
| 259 |
$valgrind ./pcretest -q -dfa $testdata/testinput9 testtry |
$valgrind ./pcretest -q -dfa $testdata/testinput9 testtry |
| 260 |
if [ $? = 0 ] ; then |
if [ $? = 0 ] ; then |
| 261 |
$cf testtry $testdata/testoutput9 |
$cf $testdata/testoutput9 testtry |
| 262 |
|
if [ $? != 0 ] ; then exit 1; fi |
| 263 |
|
else exit 1 |
| 264 |
|
fi |
| 265 |
|
echo "OK" |
| 266 |
|
fi |
| 267 |
|
|
| 268 |
|
# Test of internal offsets and code sizes. This test is run only when there |
| 269 |
|
# is Unicode property support and the link size is 2. The actual tests are |
| 270 |
|
# mostly the same as in some of the above, but in this test we inspect some |
| 271 |
|
# offsets and sizes that require a known link size. This is a doublecheck for |
| 272 |
|
# the maintainer, just in case something changes unexpectely. |
| 273 |
|
|
| 274 |
|
if [ $do10 = yes ] ; then |
| 275 |
|
echo "Test 10: Internal offsets and code size tests" |
| 276 |
|
$valgrind ./pcretest -q $testdata/testinput10 testtry |
| 277 |
|
if [ $? = 0 ] ; then |
| 278 |
|
$cf $testdata/testoutput10 testtry |
| 279 |
if [ $? != 0 ] ; then exit 1; fi |
if [ $? != 0 ] ; then exit 1; fi |
| 280 |
else exit 1 |
else exit 1 |
| 281 |
fi |
fi |