/[pcre]/code/trunk/RunTest
ViewVC logotype

Contents of /code/trunk/RunTest

Parent Directory Parent Directory | Revision Log Revision Log


Revision 689 - (show annotations) (download)
Fri Sep 9 10:34:57 2011 UTC (3 years, 2 months ago) by ph10
File size: 14878 byte(s)
Patch to RunTest for use with simulations; further JIT code/test tidies.

1 #! /bin/sh
2
3 # Run the PCRE tests using the pcretest program. The appropriate tests are
4 # selected, depending on which build-time options were used.
5
6 # All tests are now run both with and without -s, to ensure that everything is
7 # tested with and without studying. However, there are some tests that produce
8 # different output after studying, typically when we are tracing the actual
9 # matching process (for example, using auto-callouts). In these few cases, the
10 # tests are duplicated in the files, one with /S to force studying always, and
11 # one with /SS to force *not* studying always. The use of -s doesn't then make
12 # any difference to their output. There is also one test which compiles invalid
13 # UTF-8 with the UTF-8 check turned off; for this, studying must also be
14 # disabled with /SS.
15
16 # When JIT support is available, all the tests are also run with -s+ to test
17 # (again, almost) everything with studying and the JIT option. There are also
18 # two tests for JIT-specific features, one to be run when JIT support is
19 # available, and one when it is not.
20
21 # The arguments for this script can be individual test numbers, or the word
22 # "valgrind", or "sim" followed by an argument to run cross-compiled
23 # executables under a simulator, for example:
24 #
25 # RunTest 3 sim "qemu-arm -s 8388608"
26
27 valgrind=
28 sim=
29
30 # Select which tests to run; for those that are explicitly requested, check
31 # that the necessary optional facilities are available.
32
33 do1=no
34 do2=no
35 do3=no
36 do4=no
37 do5=no
38 do6=no
39 do7=no
40 do8=no
41 do9=no
42 do10=no
43 do11=no
44 do12=no
45 do13=no
46 do14=no
47 do15=no
48
49 while [ $# -gt 0 ] ; do
50 case $1 in
51 1) do1=yes;;
52 2) do2=yes;;
53 3) do3=yes;;
54 4) do4=yes;;
55 5) do5=yes;;
56 6) do6=yes;;
57 7) do7=yes;;
58 8) do8=yes;;
59 9) do9=yes;;
60 10) do10=yes;;
61 11) do11=yes;;
62 12) do12=yes;;
63 13) do13=yes;;
64 14) do14=yes;;
65 15) do15=yes;;
66 valgrind) valgrind="valgrind -q --smc-check=all";;
67 sim) shift; sim=$1;;
68 *) echo "Unknown test number $1"; exit 1;;
69 esac
70 shift
71 done
72
73 # Set up a suitable "diff" command for comparison. Some systems
74 # have a diff that lacks a -u option. Try to deal with this.
75
76 if diff -u /dev/null /dev/null; then cf="diff -u"; else cf="diff"; fi
77
78 # Find the test data
79
80 testdata=testdata
81 if [ -n "$srcdir" -a -d "$srcdir" ] ; then
82 testdata="$srcdir/testdata"
83 fi
84
85 # Find which optional facilities are available
86
87 case `$sim ./pcretest -C | $sim ./pcregrep 'Internal link size'` in
88 *2) link_size=2;;
89 *3) link_size=3;;
90 *4) link_size=4;;
91 *) echo "Failed to find internal link size"; exit 1;;
92 esac
93
94 $sim ./pcretest -C | $sim ./pcregrep 'No UTF-8 support' >/dev/null
95 utf8=$?
96
97 $sim ./pcretest -C | $sim ./pcregrep 'No Unicode properties support' >/dev/null
98 ucp=$?
99
100 jitopt=
101 $sim ./pcretest -C | $sim ./pcregrep 'No just-in-time compiler support' \
102 >/dev/null
103 jit=$?
104 if [ $jit -ne 0 ] ; then
105 jitopt=-s+
106 fi
107
108 if [ $utf8 -eq 0 ] ; then
109 if [ $do4 = yes ] ; then
110 echo "Can't run test 4 because UTF-8 support is not configured"
111 exit 1
112 fi
113 if [ $do5 = yes ] ; then
114 echo "Can't run test 5 because UTF-8 support is not configured"
115 exit 1
116 fi
117 if [ $do8 = yes ] ; then
118 echo "Can't run test 8 because UTF-8 support is not configured"
119 exit 1
120 fi
121 if [ $do12 = yes ] ; then
122 echo "Can't run test 12 because UTF-8 support is not configured"
123 exit 1
124 fi
125 fi
126
127 if [ $ucp -eq 0 ] ; then
128 if [ $do6 = yes ] ; then
129 echo "Can't run test 6 because Unicode property support is not configured"
130 exit 1
131 fi
132 if [ $do9 = yes ] ; then
133 echo "Can't run test 9 because Unicode property support is not configured"
134 exit 1
135 fi
136 if [ $do10 = yes ] ; then
137 echo "Can't run test 10 because Unicode property support is not configured"
138 exit 1
139 fi
140 if [ $do13 = yes ] ; then
141 echo "Can't run test 12 because Unicode property support is not configured"
142 exit 1
143 fi
144 fi
145
146 if [ $link_size -ne 2 ] ; then
147 if [ $do10 = yes ] ; then
148 echo "Can't run test 10 because the link size ($link_size) is not 2"
149 exit 1
150 fi
151 fi
152
153 if [ $jit -eq 0 ] ; then
154 if [ $do14 = "yes" ] ; then
155 echo "Can't run test 14 because JIT support is not configured"
156 exit 1
157 fi
158 else
159 if [ $do15 = "yes" ] ; then
160 echo "Can't run test 15 because JIT support is configured"
161 exit 1
162 fi
163 fi
164
165 # If no specific tests were requested, select all. Those that are not
166 # relevant will be skipped.
167
168 if [ $do1 = no -a $do2 = no -a $do3 = no -a $do4 = no -a \
169 $do5 = no -a $do6 = no -a $do7 = no -a $do8 = no -a \
170 $do9 = no -a $do10 = no -a $do11 = no -a $do12 = no -a \
171 $do13 = no -a $do14 = no -a $do15 = no ] ; then
172 do1=yes
173 do2=yes
174 do3=yes
175 do4=yes
176 do5=yes
177 do6=yes
178 do7=yes
179 do8=yes
180 do9=yes
181 do10=yes
182 do11=yes
183 do12=yes
184 do13=yes
185 do14=yes
186 do15=yes
187 fi
188
189 # Show which release
190
191 echo ""
192 echo PCRE C library tests
193 ./pcretest /dev/null
194
195 # Primary test, compatible with JIT and all versions of Perl >= 5.8
196
197 if [ $do1 = yes ] ; then
198 echo "Test 1: main functionality (Compatible with Perl >= 5.8)"
199 for opt in "" "-s" $jitopt; do
200 $sim $valgrind ./pcretest -q $opt $testdata/testinput1 testtry
201 if [ $? = 0 ] ; then
202 $cf $testdata/testoutput1 testtry
203 if [ $? != 0 ] ; then exit 1; fi
204 else exit 1
205 fi
206 if [ "$opt" = "-s" ] ; then echo " OK with study"
207 elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
208 else echo " OK"
209 fi
210 done
211 fi
212
213 # PCRE tests that are not JIT or Perl-compatible: API, errors, internals
214
215 if [ $do2 = yes ] ; then
216 echo "Test 2: API, errors, internals, and non-Perl stuff"
217 for opt in "" "-s" $jitopt; do
218 $sim $valgrind ./pcretest -q $opt $testdata/testinput2 testtry
219 if [ $? = 0 ] ; then
220 $cf $testdata/testoutput2 testtry
221 if [ $? != 0 ] ; then exit 1; fi
222 else
223 echo " "
224 echo "** Test 2 requires a lot of stack. If it has crashed with a"
225 echo "** segmentation fault, it may be that you do not have enough"
226 echo "** stack available by default. Please see the 'pcrestack' man"
227 echo "** page for a discussion of PCRE's stack usage."
228 echo " "
229 exit 1
230 fi
231 if [ "$opt" = "-s" ] ; then echo " OK with study"
232 elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
233 else echo " OK"
234 fi
235 done
236 fi
237
238 # Locale-specific tests, provided that either the "fr_FR" or the "french"
239 # locale is available. The former is the Unix-like standard; the latter is
240 # for Windows.
241
242 if [ $do3 = yes ] ; then
243 locale -a | grep '^fr_FR$' >/dev/null
244 if [ $? -eq 0 ] ; then
245 locale=fr_FR
246 infile=$testdata/testinput3
247 outfile=$testdata/testoutput3
248 else
249 locale -a | grep '^french$' >/dev/null
250 if [ $? -eq 0 ] ; then
251 locale=french
252 sed 's/fr_FR/french/' $testdata/testinput3 >test3input
253 sed 's/fr_FR/french/' $testdata/testoutput3 >test3output
254 infile=test3input
255 outfile=test3output
256 else
257 locale=
258 fi
259 fi
260
261 if [ "$locale" != "" ] ; then
262 echo "Test 3: locale-specific features (using '$locale' locale)"
263 for opt in "" "-s" $jitopt; do
264 $sim $valgrind ./pcretest -q $opt $infile testtry
265 if [ $? = 0 ] ; then
266 $cf $outfile testtry
267 if [ $? != 0 ] ; then
268 echo " "
269 echo "Locale test did not run entirely successfully."
270 echo "This usually means that there is a problem with the locale"
271 echo "settings rather than a bug in PCRE."
272 break;
273 else
274 if [ "$opt" = "-s" ] ; then echo " OK with study"
275 elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
276 else echo " OK"
277 fi
278 fi
279 else exit 1
280 fi
281 done
282 else
283 echo "Cannot test locale-specific features - neither the 'fr_FR' nor the"
284 echo "'french' locale exists, or the \"locale\" command is not available"
285 echo "to check for them."
286 echo " "
287 fi
288 fi
289
290 # Additional tests for UTF8 support
291
292 if [ $do4 = yes ] ; then
293 echo "Test 4: UTF-8 support (Compatible with Perl >= 5.8)"
294 if [ $utf8 -eq 0 ] ; then
295 echo " Skipped because UTF-8 support is not available"
296 else
297 for opt in "" "-s" $jitopt; do
298 $sim $valgrind ./pcretest -q $opt $testdata/testinput4 testtry
299 if [ $? = 0 ] ; then
300 $cf $testdata/testoutput4 testtry
301 if [ $? != 0 ] ; then exit 1; fi
302 else exit 1
303 fi
304 if [ "$opt" = "-s" ] ; then echo " OK with study"
305 elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
306 else echo " OK"
307 fi
308 done
309 fi
310 fi
311
312 if [ $do5 = yes ] ; then
313 echo "Test 5: API, internals, and non-Perl stuff for UTF-8 support"
314 if [ $utf8 -eq 0 ] ; then
315 echo " Skipped because UTF-8 support is not available"
316 else
317 for opt in "" "-s" $jitopt; do
318 $sim $valgrind ./pcretest -q $opt $testdata/testinput5 testtry
319 if [ $? = 0 ] ; then
320 $cf $testdata/testoutput5 testtry
321 if [ $? != 0 ] ; then exit 1; fi
322 else exit 1
323 fi
324 if [ "$opt" = "-s" ] ; then echo " OK with study"
325 elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
326 else echo " OK"
327 fi
328 done
329 fi
330 fi
331
332 if [ $do6 = yes ] ; then
333 echo "Test 6: Unicode property support (Compatible with Perl >= 5.10)"
334 if [ $utf8 -eq 0 -o $ucp -eq 0 ] ; then
335 echo " Skipped because Unicode property support is not available"
336 else
337 for opt in "" "-s" $jitopt; do
338 $sim $valgrind ./pcretest -q $opt $testdata/testinput6 testtry
339 if [ $? = 0 ] ; then
340 $cf $testdata/testoutput6 testtry
341 if [ $? != 0 ] ; then exit 1; fi
342 else exit 1
343 fi
344 if [ "$opt" = "-s" ] ; then echo " OK with study"
345 elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
346 else echo " OK"
347 fi
348 done
349 fi
350 fi
351
352 # Tests for DFA matching support
353
354 if [ $do7 = yes ] ; then
355 echo "Test 7: DFA matching"
356 for opt in "" "-s"; do
357 $sim $valgrind ./pcretest -q $opt -dfa $testdata/testinput7 testtry
358 if [ $? = 0 ] ; then
359 $cf $testdata/testoutput7 testtry
360 if [ $? != 0 ] ; then exit 1; fi
361 else exit 1
362 fi
363 if [ "$opt" = "-s" ] ; then echo " OK with study" ; else echo " OK"; fi
364 done
365 fi
366
367 if [ $do8 = yes ] ; then
368 echo "Test 8: DFA matching with UTF-8"
369 if [ $utf8 -eq 0 ] ; then
370 echo " Skipped because UTF-8 support is not available"
371 else
372 for opt in "" "-s"; do
373 $sim $valgrind ./pcretest -q $opt -dfa $testdata/testinput8 testtry
374 if [ $? = 0 ] ; then
375 $cf $testdata/testoutput8 testtry
376 if [ $? != 0 ] ; then exit 1; fi
377 else exit 1
378 fi
379 if [ "$opt" = "-s" ] ; then echo " OK with study" ; else echo " OK"; fi
380 done
381 fi
382 fi
383
384 if [ $do9 = yes ] ; then
385 echo "Test 9: DFA matching with Unicode properties"
386 if [ $utf8 -eq 0 -o $ucp -eq 0 ] ; then
387 echo " Skipped because Unicode property support is not available"
388 else
389 for opt in "" "-s"; do
390 $sim $valgrind ./pcretest -q $opt -dfa $testdata/testinput9 testtry
391 if [ $? = 0 ] ; then
392 $cf $testdata/testoutput9 testtry
393 if [ $? != 0 ] ; then exit 1; fi
394 else exit 1
395 fi
396 if [ "$opt" = "-s" ] ; then echo " OK with study" ; else echo " OK"; fi
397 done
398 fi
399 fi
400
401 # Test of internal offsets and code sizes. This test is run only when there
402 # is Unicode property support and the link size is 2. The actual tests are
403 # mostly the same as in some of the above, but in this test we inspect some
404 # offsets and sizes that require a known link size. This is a doublecheck for
405 # the maintainer, just in case something changes unexpectely.
406
407 if [ $do10 = yes ] ; then
408 echo "Test 10: Internal offsets and code size tests"
409 if [ $link_size -ne 2 ] ; then
410 echo " Skipped because link size is not 2"
411 elif [ $ucp -eq 0 ] ; then
412 echo " Skipped because Unicode property support is not available"
413 else
414 for opt in "" "-s"; do
415 $sim $valgrind ./pcretest -q $opt $testdata/testinput10 testtry
416 if [ $? = 0 ] ; then
417 $cf $testdata/testoutput10 testtry
418 if [ $? != 0 ] ; then exit 1; fi
419 else exit 1
420 fi
421 if [ "$opt" = "-s" ] ; then echo " OK with study" ; else echo " OK"; fi
422 done
423 fi
424 fi
425
426 # Test of Perl >= 5.10 features without UTF8 support
427
428 if [ $do11 = yes ] ; then
429 echo "Test 11: Features from Perl >= 5.10 without UTF8 support"
430 for opt in "" "-s" $jitopt; do
431 $sim $valgrind ./pcretest -q $opt $testdata/testinput11 testtry
432 if [ $? = 0 ] ; then
433 $cf $testdata/testoutput11 testtry
434 if [ $? != 0 ] ; then exit 1; fi
435 else exit 1
436 fi
437 if [ "$opt" = "-s" ] ; then echo " OK with study"
438 elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
439 else echo " OK"
440 fi
441 done
442 fi
443
444 # Test of Perl >= 5.10 features with UTF8 support
445
446 if [ $do12 = yes ] ; then
447 echo "Test 12: Features from Perl >= 5.10 with UTF8 support"
448 if [ $utf8 -eq 0 ] ; then
449 echo " Skipped because UTF-8 support is not available"
450 else
451 for opt in "" "-s" $jitopt; do
452 $sim $valgrind ./pcretest -q $opt $testdata/testinput12 testtry
453 if [ $? = 0 ] ; then
454 $cf $testdata/testoutput12 testtry
455 if [ $? != 0 ] ; then exit 1; fi
456 else exit 1
457 fi
458 if [ "$opt" = "-s" ] ; then echo " OK with study"
459 elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
460 else echo " OK"
461 fi
462 done
463 fi
464 fi
465
466 # Test non-Perl-compatible Unicode property support
467
468 if [ $do13 = yes ] ; then
469 echo "Test 13: API, internals, and non-Perl stuff for Unicode property support"
470 if [ $utf8 -eq 0 -o $ucp -eq 0 ] ; then
471 echo " Skipped because Unicode property support is not available"
472 else
473 for opt in "" "-s" $jitopt; do
474 $sim $valgrind ./pcretest -q $opt $testdata/testinput13 testtry
475 if [ $? = 0 ] ; then
476 $cf $testdata/testoutput13 testtry
477 if [ $? != 0 ] ; then exit 1; fi
478 else exit 1
479 fi
480 if [ "$opt" = "-s" ] ; then echo " OK with study"
481 elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
482 else echo " OK"
483 fi
484 done
485 fi
486 fi
487
488 # Test JIT-specific features when JIT is available
489
490 if [ $do14 = yes ] ; then
491 echo "Test 14: JIT-specific features (JIT available)"
492 if [ $jit -eq 0 ] ; then
493 echo " Skipped because JIT is not available or not usable"
494 else
495 $sim $valgrind ./pcretest -q $testdata/testinput14 testtry
496 if [ $? = 0 ] ; then
497 $cf $testdata/testoutput14 testtry
498 if [ $? != 0 ] ; then exit 1; fi
499 else exit 1
500 fi
501 echo " OK"
502 fi
503 fi
504
505 # Test JIT-specific features when JIT is not available
506
507 if [ $do15 = yes ] ; then
508 echo "Test 15: JIT-specific features (JIT not available)"
509 if [ $jit -ne 0 ] ; then
510 echo " Skipped because JIT is available"
511 else
512 $sim $valgrind ./pcretest -q $testdata/testinput15 testtry
513 if [ $? = 0 ] ; then
514 $cf $testdata/testoutput15 testtry
515 if [ $? != 0 ] ; then exit 1; fi
516 else exit 1
517 fi
518 echo " OK"
519 fi
520 fi
521
522 # End

Properties

Name Value
svn:executable *
svn:keywords "Author Date Id Revision Url"

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12