| 1 |
nigel |
49 |
#! /bin/sh |
| 2 |
|
|
|
| 3 |
ph10 |
345 |
# Run PCRE tests. |
| 4 |
nigel |
49 |
|
| 5 |
nigel |
87 |
valgrind= |
| 6 |
ph10 |
339 |
|
| 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 |
ph10 |
137 |
testdata=testdata |
| 15 |
|
|
if [ -n "$srcdir" -a -d "$srcdir" ] ; then |
| 16 |
|
|
testdata="$srcdir/testdata" |
| 17 |
nigel |
81 |
fi |
| 18 |
nigel |
49 |
|
| 19 |
ph10 |
116 |
# Find which optional facilities are available |
| 20 |
nigel |
87 |
|
| 21 |
ph10 |
116 |
case `./pcretest -C | ./pcregrep 'Internal link size'` in |
| 22 |
|
|
*2) link_size=2;; |
| 23 |
|
|
*3) link_size=3;; |
| 24 |
|
|
*4) link_size=4;; |
| 25 |
|
|
*) echo "Failed to find internal link size"; exit 1;; |
| 26 |
|
|
esac |
| 27 |
nigel |
49 |
|
| 28 |
ph10 |
116 |
./pcretest -C | ./pcregrep 'No UTF-8 support' >/dev/null |
| 29 |
|
|
utf8=$? |
| 30 |
|
|
|
| 31 |
|
|
./pcretest -C | ./pcregrep 'No Unicode properties support' >/dev/null |
| 32 |
|
|
ucp=$? |
| 33 |
|
|
|
| 34 |
|
|
# Select which tests to run; for those that are explicitly requested, check |
| 35 |
|
|
# that the necessary optional facilities are available. |
| 36 |
|
|
|
| 37 |
nigel |
49 |
do1=no |
| 38 |
|
|
do2=no |
| 39 |
|
|
do3=no |
| 40 |
|
|
do4=no |
| 41 |
|
|
do5=no |
| 42 |
nigel |
75 |
do6=no |
| 43 |
nigel |
77 |
do7=no |
| 44 |
|
|
do8=no |
| 45 |
|
|
do9=no |
| 46 |
ph10 |
164 |
do10=no |
| 47 |
nigel |
49 |
|
| 48 |
|
|
while [ $# -gt 0 ] ; do |
| 49 |
|
|
case $1 in |
| 50 |
|
|
1) do1=yes;; |
| 51 |
|
|
2) do2=yes;; |
| 52 |
|
|
3) do3=yes;; |
| 53 |
|
|
4) do4=yes;; |
| 54 |
nigel |
77 |
5) do5=yes;; |
| 55 |
|
|
6) do6=yes;; |
| 56 |
|
|
7) do7=yes;; |
| 57 |
|
|
8) do8=yes;; |
| 58 |
|
|
9) do9=yes;; |
| 59 |
ph10 |
165 |
10) do10=yes;; |
| 60 |
ph10 |
164 |
valgrind) valgrind="valgrind -q";; |
| 61 |
nigel |
49 |
*) echo "Unknown test number $1"; exit 1;; |
| 62 |
|
|
esac |
| 63 |
|
|
shift |
| 64 |
|
|
done |
| 65 |
|
|
|
| 66 |
ph10 |
116 |
if [ $utf8 -eq 0 ] ; then |
| 67 |
nigel |
63 |
if [ $do4 = yes ] ; then |
| 68 |
nigel |
75 |
echo "Can't run test 4 because UTF-8 support is not configured" |
| 69 |
nigel |
63 |
exit 1 |
| 70 |
nigel |
77 |
fi |
| 71 |
nigel |
49 |
if [ $do5 = yes ] ; then |
| 72 |
nigel |
75 |
echo "Can't run test 5 because UTF-8 support is not configured" |
| 73 |
nigel |
49 |
exit 1 |
| 74 |
nigel |
77 |
fi |
| 75 |
|
|
if [ $do8 = yes ] ; then |
| 76 |
|
|
echo "Can't run test 8 because UTF-8 support is not configured" |
| 77 |
|
|
exit 1 |
| 78 |
|
|
fi |
| 79 |
|
|
fi |
| 80 |
nigel |
49 |
|
| 81 |
ph10 |
116 |
if [ $ucp -eq 0 ] ; then |
| 82 |
nigel |
75 |
if [ $do6 = yes ] ; then |
| 83 |
|
|
echo "Can't run test 6 because Unicode property support is not configured" |
| 84 |
|
|
exit 1 |
| 85 |
|
|
fi |
| 86 |
nigel |
77 |
if [ $do9 = yes ] ; then |
| 87 |
|
|
echo "Can't run test 9 because Unicode property support is not configured" |
| 88 |
|
|
exit 1 |
| 89 |
|
|
fi |
| 90 |
ph10 |
164 |
if [ $do10 = yes ] ; then |
| 91 |
|
|
echo "Can't run test 10 because Unicode property support is not configured" |
| 92 |
|
|
exit 1 |
| 93 |
|
|
fi |
| 94 |
nigel |
77 |
fi |
| 95 |
nigel |
75 |
|
| 96 |
ph10 |
164 |
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 |
ph10 |
165 |
fi |
| 102 |
ph10 |
164 |
|
| 103 |
ph10 |
116 |
# If no specific tests were requested, select all that are relevant. |
| 104 |
|
|
|
| 105 |
nigel |
75 |
if [ $do1 = no -a $do2 = no -a $do3 = no -a $do4 = no -a \ |
| 106 |
nigel |
77 |
$do5 = no -a $do6 = no -a $do7 = no -a $do8 = no -a \ |
| 107 |
ph10 |
164 |
$do9 = no -a $do10 = no ] ; then |
| 108 |
nigel |
49 |
do1=yes |
| 109 |
ph10 |
247 |
do2=yes |
| 110 |
nigel |
49 |
do3=yes |
| 111 |
ph10 |
116 |
if [ $utf8 -ne 0 ] ; then do4=yes; fi |
| 112 |
ph10 |
247 |
if [ $utf8 -ne 0 ] ; then do5=yes; fi |
| 113 |
ph10 |
116 |
if [ $utf8 -ne 0 -a $ucp -ne 0 ] ; then do6=yes; fi |
| 114 |
ph10 |
247 |
do7=yes |
| 115 |
|
|
if [ $utf8 -ne 0 ] ; then do8=yes; fi |
| 116 |
ph10 |
116 |
if [ $utf8 -ne 0 -a $ucp -ne 0 ] ; then do9=yes; fi |
| 117 |
ph10 |
173 |
if [ $link_size -eq 2 -a $ucp -ne 0 ] ; then do10=yes; fi |
| 118 |
nigel |
49 |
fi |
| 119 |
|
|
|
| 120 |
nigel |
73 |
# Show which release |
| 121 |
|
|
|
| 122 |
ph10 |
128 |
echo "" |
| 123 |
|
|
echo PCRE C library tests |
| 124 |
nigel |
73 |
./pcretest /dev/null |
| 125 |
|
|
|
| 126 |
nigel |
49 |
# Primary test, Perl-compatible |
| 127 |
|
|
|
| 128 |
|
|
if [ $do1 = yes ] ; then |
| 129 |
nigel |
75 |
echo "Test 1: main functionality (Perl compatible)" |
| 130 |
nigel |
87 |
$valgrind ./pcretest -q $testdata/testinput1 testtry |
| 131 |
nigel |
49 |
if [ $? = 0 ] ; then |
| 132 |
ph10 |
158 |
$cf $testdata/testoutput1 testtry |
| 133 |
nigel |
49 |
if [ $? != 0 ] ; then exit 1; fi |
| 134 |
|
|
else exit 1 |
| 135 |
|
|
fi |
| 136 |
nigel |
77 |
echo "OK" |
| 137 |
nigel |
49 |
fi |
| 138 |
|
|
|
| 139 |
|
|
# PCRE tests that are not Perl-compatible - API & error tests, mostly |
| 140 |
|
|
|
| 141 |
|
|
if [ $do2 = yes ] ; then |
| 142 |
ph10 |
162 |
echo "Test 2: API and error handling (not Perl compatible)" |
| 143 |
|
|
$valgrind ./pcretest -q $testdata/testinput2 testtry |
| 144 |
|
|
if [ $? = 0 ] ; then |
| 145 |
|
|
$cf $testdata/testoutput2 testtry |
| 146 |
|
|
if [ $? != 0 ] ; then exit 1; fi |
| 147 |
ph10 |
371 |
else |
| 148 |
ph10 |
358 |
echo " " |
| 149 |
|
|
echo "** Test 2 requires a lot of stack. If it has crashed with a" |
| 150 |
|
|
echo "** segmentation fault, it may be that you do not have enough" |
| 151 |
|
|
echo "** stack available by default. Please see the 'pcrestack' man" |
| 152 |
ph10 |
371 |
echo "** page for a discussion of PCRE's stack usage." |
| 153 |
|
|
echo " " |
| 154 |
ph10 |
358 |
exit 1 |
| 155 |
nigel |
77 |
fi |
| 156 |
ph10 |
162 |
echo "OK" |
| 157 |
nigel |
49 |
fi |
| 158 |
|
|
|
| 159 |
ph10 |
157 |
# Locale-specific tests, provided that either the "fr_FR" or the "french" |
| 160 |
|
|
# locale is available. The former is the Unix-like standard; the latter is |
| 161 |
|
|
# for Windows. |
| 162 |
nigel |
49 |
|
| 163 |
nigel |
63 |
if [ $do3 = yes ] ; then |
| 164 |
nigel |
73 |
locale -a | grep '^fr_FR$' >/dev/null |
| 165 |
nigel |
49 |
if [ $? -eq 0 ] ; then |
| 166 |
ph10 |
157 |
locale=fr_FR |
| 167 |
|
|
infile=$testdata/testinput3 |
| 168 |
|
|
outfile=$testdata/testoutput3 |
| 169 |
|
|
else |
| 170 |
|
|
locale -a | grep '^french$' >/dev/null |
| 171 |
|
|
if [ $? -eq 0 ] ; then |
| 172 |
|
|
locale=french |
| 173 |
|
|
sed 's/fr_FR/french/' $testdata/testinput3 >test3input |
| 174 |
|
|
sed 's/fr_FR/french/' $testdata/testoutput3 >test3output |
| 175 |
|
|
infile=test3input |
| 176 |
ph10 |
159 |
outfile=test3output |
| 177 |
ph10 |
157 |
else |
| 178 |
ph10 |
159 |
locale= |
| 179 |
ph10 |
157 |
fi |
| 180 |
ph10 |
159 |
fi |
| 181 |
ph10 |
157 |
|
| 182 |
|
|
if [ "$locale" != "" ] ; then |
| 183 |
|
|
echo "Test 3: locale-specific features (using '$locale' locale)" |
| 184 |
|
|
$valgrind ./pcretest -q $infile testtry |
| 185 |
nigel |
49 |
if [ $? = 0 ] ; then |
| 186 |
ph10 |
158 |
$cf $outfile testtry |
| 187 |
nigel |
77 |
if [ $? != 0 ] ; then |
| 188 |
nigel |
49 |
echo " " |
| 189 |
|
|
echo "Locale test did not run entirely successfully." |
| 190 |
|
|
echo "This usually means that there is a problem with the locale" |
| 191 |
nigel |
77 |
echo "settings rather than a bug in PCRE." |
| 192 |
nigel |
49 |
else |
| 193 |
nigel |
77 |
echo "OK" |
| 194 |
|
|
fi |
| 195 |
nigel |
49 |
else exit 1 |
| 196 |
|
|
fi |
| 197 |
|
|
else |
| 198 |
ph10 |
157 |
echo "Cannot test locale-specific features - neither the 'fr_FR' nor the" |
| 199 |
|
|
echo "'french' locale exists, or the \"locale\" command is not available" |
| 200 |
|
|
echo "to check for them." |
| 201 |
nigel |
77 |
echo " " |
| 202 |
nigel |
49 |
fi |
| 203 |
|
|
fi |
| 204 |
|
|
|
| 205 |
|
|
# Additional tests for UTF8 support |
| 206 |
|
|
|
| 207 |
nigel |
63 |
if [ $do4 = yes ] ; then |
| 208 |
nigel |
75 |
echo "Test 4: UTF-8 support (Perl compatible)" |
| 209 |
nigel |
87 |
$valgrind ./pcretest -q $testdata/testinput4 testtry |
| 210 |
nigel |
49 |
if [ $? = 0 ] ; then |
| 211 |
ph10 |
158 |
$cf $testdata/testoutput4 testtry |
| 212 |
nigel |
49 |
if [ $? != 0 ] ; then exit 1; fi |
| 213 |
|
|
else exit 1 |
| 214 |
|
|
fi |
| 215 |
nigel |
77 |
echo "OK" |
| 216 |
nigel |
49 |
fi |
| 217 |
|
|
|
| 218 |
nigel |
63 |
if [ $do5 = yes ] ; then |
| 219 |
ph10 |
162 |
echo "Test 5: API and internals for UTF-8 support (not Perl compatible)" |
| 220 |
|
|
$valgrind ./pcretest -q $testdata/testinput5 testtry |
| 221 |
|
|
if [ $? = 0 ] ; then |
| 222 |
|
|
$cf $testdata/testoutput5 testtry |
| 223 |
|
|
if [ $? != 0 ] ; then exit 1; fi |
| 224 |
|
|
else exit 1 |
| 225 |
nigel |
77 |
fi |
| 226 |
ph10 |
162 |
echo "OK" |
| 227 |
nigel |
49 |
fi |
| 228 |
|
|
|
| 229 |
nigel |
75 |
if [ $do6 = yes ] ; then |
| 230 |
ph10 |
162 |
echo "Test 6: Unicode property support" |
| 231 |
|
|
$valgrind ./pcretest -q $testdata/testinput6 testtry |
| 232 |
|
|
if [ $? = 0 ] ; then |
| 233 |
|
|
$cf $testdata/testoutput6 testtry |
| 234 |
|
|
if [ $? != 0 ] ; then exit 1; fi |
| 235 |
|
|
else exit 1 |
| 236 |
nigel |
77 |
fi |
| 237 |
ph10 |
162 |
echo "OK" |
| 238 |
nigel |
75 |
fi |
| 239 |
|
|
|
| 240 |
nigel |
77 |
# Tests for DFA matching support |
| 241 |
|
|
|
| 242 |
|
|
if [ $do7 = yes ] ; then |
| 243 |
|
|
echo "Test 7: DFA matching" |
| 244 |
nigel |
87 |
$valgrind ./pcretest -q -dfa $testdata/testinput7 testtry |
| 245 |
nigel |
77 |
if [ $? = 0 ] ; then |
| 246 |
ph10 |
158 |
$cf $testdata/testoutput7 testtry |
| 247 |
nigel |
77 |
if [ $? != 0 ] ; then exit 1; fi |
| 248 |
|
|
else exit 1 |
| 249 |
|
|
fi |
| 250 |
|
|
echo "OK" |
| 251 |
|
|
fi |
| 252 |
|
|
|
| 253 |
|
|
if [ $do8 = yes ] ; then |
| 254 |
|
|
echo "Test 8: DFA matching with UTF-8" |
| 255 |
nigel |
87 |
$valgrind ./pcretest -q -dfa $testdata/testinput8 testtry |
| 256 |
nigel |
77 |
if [ $? = 0 ] ; then |
| 257 |
ph10 |
158 |
$cf $testdata/testoutput8 testtry |
| 258 |
nigel |
77 |
if [ $? != 0 ] ; then exit 1; fi |
| 259 |
|
|
else exit 1 |
| 260 |
|
|
fi |
| 261 |
|
|
echo "OK" |
| 262 |
|
|
fi |
| 263 |
|
|
|
| 264 |
|
|
if [ $do9 = yes ] ; then |
| 265 |
|
|
echo "Test 9: DFA matching with Unicode properties" |
| 266 |
nigel |
87 |
$valgrind ./pcretest -q -dfa $testdata/testinput9 testtry |
| 267 |
nigel |
77 |
if [ $? = 0 ] ; then |
| 268 |
ph10 |
158 |
$cf $testdata/testoutput9 testtry |
| 269 |
nigel |
77 |
if [ $? != 0 ] ; then exit 1; fi |
| 270 |
|
|
else exit 1 |
| 271 |
|
|
fi |
| 272 |
|
|
echo "OK" |
| 273 |
|
|
fi |
| 274 |
|
|
|
| 275 |
ph10 |
164 |
# Test of internal offsets and code sizes. This test is run only when there |
| 276 |
|
|
# is Unicode property support and the link size is 2. The actual tests are |
| 277 |
|
|
# mostly the same as in some of the above, but in this test we inspect some |
| 278 |
|
|
# offsets and sizes that require a known link size. This is a doublecheck for |
| 279 |
|
|
# the maintainer, just in case something changes unexpectely. |
| 280 |
|
|
|
| 281 |
|
|
if [ $do10 = yes ] ; then |
| 282 |
|
|
echo "Test 10: Internal offsets and code size tests" |
| 283 |
|
|
$valgrind ./pcretest -q $testdata/testinput10 testtry |
| 284 |
|
|
if [ $? = 0 ] ; then |
| 285 |
|
|
$cf $testdata/testoutput10 testtry |
| 286 |
|
|
if [ $? != 0 ] ; then exit 1; fi |
| 287 |
|
|
else exit 1 |
| 288 |
|
|
fi |
| 289 |
|
|
echo "OK" |
| 290 |
|
|
fi |
| 291 |
|
|
|
| 292 |
nigel |
49 |
# End |