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