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

Contents of /code/trunk/RunTest

Parent Directory Parent Directory | Revision Log Revision Log


Revision 691 - (hide annotations) (download)
Sun Sep 11 14:31:21 2011 UTC (2 years, 11 months ago) by ph10
File size: 14876 byte(s)
Final source and document tidies for 8.20-RC1.

1 nigel 49 #! /bin/sh
2    
3 ph10 671 # Run the PCRE tests using the pcretest program. The appropriate tests are
4     # selected, depending on which build-time options were used.
5 nigel 49
6 ph10 671 # 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 ph10 674 # two tests for JIT-specific features, one to be run when JIT support is
19 ph10 671 # available, and one when it is not.
20    
21 ph10 691 # 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 ph10 689 # executables under a simulator, for example:
24     #
25     # RunTest 3 sim "qemu-arm -s 8388608"
26    
27 nigel 87 valgrind=
28 ph10 689 sim=
29 ph10 339
30 ph10 116 # Select which tests to run; for those that are explicitly requested, check
31     # that the necessary optional facilities are available.
32    
33 nigel 49 do1=no
34     do2=no
35     do3=no
36     do4=no
37     do5=no
38 nigel 75 do6=no
39 nigel 77 do7=no
40     do8=no
41     do9=no
42 ph10 164 do10=no
43 ph10 448 do11=no
44     do12=no
45 ph10 651 do13=no
46 ph10 671 do14=no
47     do15=no
48 nigel 49
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 nigel 77 5) do5=yes;;
56     6) do6=yes;;
57     7) do7=yes;;
58     8) do8=yes;;
59     9) do9=yes;;
60 ph10 165 10) do10=yes;;
61 ph10 448 11) do11=yes;;
62 ph10 461 12) do12=yes;;
63 ph10 666 13) do13=yes;;
64 ph10 671 14) do14=yes;;
65     15) do15=yes;;
66 ph10 666 valgrind) valgrind="valgrind -q --smc-check=all";;
67 ph10 689 sim) shift; sim=$1;;
68 nigel 49 *) echo "Unknown test number $1"; exit 1;;
69     esac
70     shift
71     done
72    
73 ph10 689 # 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 ph10 116 if [ $utf8 -eq 0 ] ; then
109 nigel 63 if [ $do4 = yes ] ; then
110 nigel 75 echo "Can't run test 4 because UTF-8 support is not configured"
111 nigel 63 exit 1
112 nigel 77 fi
113 nigel 49 if [ $do5 = yes ] ; then
114 nigel 75 echo "Can't run test 5 because UTF-8 support is not configured"
115 nigel 49 exit 1
116 nigel 77 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 ph10 651 if [ $do12 = yes ] ; then
122     echo "Can't run test 12 because UTF-8 support is not configured"
123     exit 1
124     fi
125 nigel 77 fi
126 nigel 49
127 ph10 116 if [ $ucp -eq 0 ] ; then
128 nigel 75 if [ $do6 = yes ] ; then
129     echo "Can't run test 6 because Unicode property support is not configured"
130     exit 1
131     fi
132 nigel 77 if [ $do9 = yes ] ; then
133     echo "Can't run test 9 because Unicode property support is not configured"
134     exit 1
135     fi
136 ph10 164 if [ $do10 = yes ] ; then
137     echo "Can't run test 10 because Unicode property support is not configured"
138     exit 1
139     fi
140 ph10 651 if [ $do13 = yes ] ; then
141 ph10 448 echo "Can't run test 12 because Unicode property support is not configured"
142     exit 1
143     fi
144 nigel 77 fi
145 nigel 75
146 ph10 164 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 ph10 165 fi
152 ph10 164
153 ph10 671 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 ph10 674 fi
164 ph10 116
165 ph10 671 # 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 nigel 49 do1=yes
173 ph10 247 do2=yes
174 nigel 49 do3=yes
175 ph10 671 do4=yes
176     do5=yes
177     do6=yes
178 ph10 247 do7=yes
179 ph10 671 do8=yes
180     do9=yes
181     do10=yes
182 ph10 448 do11=yes
183 ph10 671 do12=yes
184     do13=yes
185     do14=yes
186     do15=yes
187 nigel 49 fi
188    
189 nigel 73 # Show which release
190    
191 ph10 128 echo ""
192     echo PCRE C library tests
193 nigel 73 ./pcretest /dev/null
194    
195 ph10 666 # Primary test, compatible with JIT and all versions of Perl >= 5.8
196 nigel 49
197     if [ $do1 = yes ] ; then
198 ph10 559 echo "Test 1: main functionality (Compatible with Perl >= 5.8)"
199 ph10 666 for opt in "" "-s" $jitopt; do
200 ph10 689 $sim $valgrind ./pcretest -q $opt $testdata/testinput1 testtry
201 ph10 612 if [ $? = 0 ] ; then
202     $cf $testdata/testoutput1 testtry
203     if [ $? != 0 ] ; then exit 1; fi
204     else exit 1
205     fi
206 ph10 674 if [ "$opt" = "-s" ] ; then echo " OK with study"
207     elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
208     else echo " OK"
209 ph10 666 fi
210 ph10 654 done
211 nigel 49 fi
212    
213 ph10 666 # PCRE tests that are not JIT or Perl-compatible: API, errors, internals
214 nigel 49
215     if [ $do2 = yes ] ; then
216 ph10 449 echo "Test 2: API, errors, internals, and non-Perl stuff"
217 ph10 666 for opt in "" "-s" $jitopt; do
218 ph10 689 $sim $valgrind ./pcretest -q $opt $testdata/testinput2 testtry
219 ph10 612 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 ph10 674 if [ "$opt" = "-s" ] ; then echo " OK with study"
232     elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
233     else echo " OK"
234 ph10 666 fi
235 ph10 654 done
236 nigel 49 fi
237    
238 ph10 157 # 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 nigel 49
242 nigel 63 if [ $do3 = yes ] ; then
243 nigel 73 locale -a | grep '^fr_FR$' >/dev/null
244 nigel 49 if [ $? -eq 0 ] ; then
245 ph10 157 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 ph10 159 outfile=test3output
256 ph10 157 else
257 ph10 159 locale=
258 ph10 157 fi
259 ph10 159 fi
260 ph10 157
261     if [ "$locale" != "" ] ; then
262     echo "Test 3: locale-specific features (using '$locale' locale)"
263 ph10 666 for opt in "" "-s" $jitopt; do
264 ph10 689 $sim $valgrind ./pcretest -q $opt $infile testtry
265 ph10 612 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 ph10 654 break;
273 ph10 612 else
274 ph10 674 if [ "$opt" = "-s" ] ; then echo " OK with study"
275     elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
276     else echo " OK"
277 ph10 666 fi
278 ph10 612 fi
279     else exit 1
280 nigel 77 fi
281 ph10 654 done
282 nigel 49 else
283 ph10 157 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 nigel 77 echo " "
287 nigel 49 fi
288     fi
289    
290     # Additional tests for UTF8 support
291    
292 nigel 63 if [ $do4 = yes ] ; then
293 ph10 559 echo "Test 4: UTF-8 support (Compatible with Perl >= 5.8)"
294 ph10 671 if [ $utf8 -eq 0 ] ; then
295     echo " Skipped because UTF-8 support is not available"
296 ph10 674 else
297 ph10 671 for opt in "" "-s" $jitopt; do
298 ph10 689 $sim $valgrind ./pcretest -q $opt $testdata/testinput4 testtry
299 ph10 671 if [ $? = 0 ] ; then
300     $cf $testdata/testoutput4 testtry
301     if [ $? != 0 ] ; then exit 1; fi
302     else exit 1
303     fi
304 ph10 674 if [ "$opt" = "-s" ] ; then echo " OK with study"
305     elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
306     else echo " OK"
307 ph10 671 fi
308     done
309 ph10 674 fi
310 nigel 49 fi
311    
312 nigel 63 if [ $do5 = yes ] ; then
313 ph10 426 echo "Test 5: API, internals, and non-Perl stuff for UTF-8 support"
314 ph10 671 if [ $utf8 -eq 0 ] ; then
315     echo " Skipped because UTF-8 support is not available"
316 ph10 674 else
317 ph10 671 for opt in "" "-s" $jitopt; do
318 ph10 689 $sim $valgrind ./pcretest -q $opt $testdata/testinput5 testtry
319 ph10 671 if [ $? = 0 ] ; then
320     $cf $testdata/testoutput5 testtry
321     if [ $? != 0 ] ; then exit 1; fi
322     else exit 1
323     fi
324 ph10 674 if [ "$opt" = "-s" ] ; then echo " OK with study"
325     elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
326     else echo " OK"
327 ph10 671 fi
328     done
329 ph10 674 fi
330 nigel 49 fi
331    
332 nigel 75 if [ $do6 = yes ] ; then
333 ph10 559 echo "Test 6: Unicode property support (Compatible with Perl >= 5.10)"
334 ph10 671 if [ $utf8 -eq 0 -o $ucp -eq 0 ] ; then
335     echo " Skipped because Unicode property support is not available"
336 ph10 674 else
337 ph10 671 for opt in "" "-s" $jitopt; do
338 ph10 689 $sim $valgrind ./pcretest -q $opt $testdata/testinput6 testtry
339 ph10 671 if [ $? = 0 ] ; then
340     $cf $testdata/testoutput6 testtry
341     if [ $? != 0 ] ; then exit 1; fi
342     else exit 1
343     fi
344 ph10 674 if [ "$opt" = "-s" ] ; then echo " OK with study"
345     elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
346     else echo " OK"
347 ph10 671 fi
348     done
349 ph10 674 fi
350 nigel 75 fi
351    
352 nigel 77 # Tests for DFA matching support
353    
354     if [ $do7 = yes ] ; then
355     echo "Test 7: DFA matching"
356 ph10 654 for opt in "" "-s"; do
357 ph10 689 $sim $valgrind ./pcretest -q $opt -dfa $testdata/testinput7 testtry
358 ph10 612 if [ $? = 0 ] ; then
359     $cf $testdata/testoutput7 testtry
360     if [ $? != 0 ] ; then exit 1; fi
361     else exit 1
362     fi
363 ph10 671 if [ "$opt" = "-s" ] ; then echo " OK with study" ; else echo " OK"; fi
364 ph10 654 done
365 nigel 77 fi
366    
367     if [ $do8 = yes ] ; then
368     echo "Test 8: DFA matching with UTF-8"
369 ph10 671 if [ $utf8 -eq 0 ] ; then
370     echo " Skipped because UTF-8 support is not available"
371 ph10 674 else
372 ph10 671 for opt in "" "-s"; do
373 ph10 689 $sim $valgrind ./pcretest -q $opt -dfa $testdata/testinput8 testtry
374 ph10 671 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 ph10 674 fi
382 nigel 77 fi
383    
384     if [ $do9 = yes ] ; then
385     echo "Test 9: DFA matching with Unicode properties"
386 ph10 671 if [ $utf8 -eq 0 -o $ucp -eq 0 ] ; then
387     echo " Skipped because Unicode property support is not available"
388 ph10 674 else
389 ph10 671 for opt in "" "-s"; do
390 ph10 689 $sim $valgrind ./pcretest -q $opt -dfa $testdata/testinput9 testtry
391 ph10 671 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 ph10 674 fi
399 nigel 77 fi
400    
401 ph10 164 # 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 ph10 674 if [ $link_size -ne 2 ] ; then
410 ph10 671 echo " Skipped because link size is not 2"
411 ph10 674 elif [ $ucp -eq 0 ] ; then
412 ph10 671 echo " Skipped because Unicode property support is not available"
413 ph10 674 else
414 ph10 671 for opt in "" "-s"; do
415 ph10 689 $sim $valgrind ./pcretest -q $opt $testdata/testinput10 testtry
416 ph10 671 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 ph10 674 fi
424 ph10 164 fi
425    
426 ph10 651 # Test of Perl >= 5.10 features without UTF8 support
427 ph10 448
428     if [ $do11 = yes ] ; then
429 ph10 651 echo "Test 11: Features from Perl >= 5.10 without UTF8 support"
430 ph10 666 for opt in "" "-s" $jitopt; do
431 ph10 689 $sim $valgrind ./pcretest -q $opt $testdata/testinput11 testtry
432 ph10 612 if [ $? = 0 ] ; then
433     $cf $testdata/testoutput11 testtry
434     if [ $? != 0 ] ; then exit 1; fi
435     else exit 1
436     fi
437 ph10 674 if [ "$opt" = "-s" ] ; then echo " OK with study"
438     elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
439     else echo " OK"
440 ph10 666 fi
441 ph10 654 done
442 ph10 448 fi
443    
444 ph10 651 # Test of Perl >= 5.10 features with UTF8 support
445 ph10 448
446     if [ $do12 = yes ] ; then
447 ph10 651 echo "Test 12: Features from Perl >= 5.10 with UTF8 support"
448 ph10 671 if [ $utf8 -eq 0 ] ; then
449     echo " Skipped because UTF-8 support is not available"
450 ph10 674 else
451 ph10 671 for opt in "" "-s" $jitopt; do
452 ph10 689 $sim $valgrind ./pcretest -q $opt $testdata/testinput12 testtry
453 ph10 671 if [ $? = 0 ] ; then
454     $cf $testdata/testoutput12 testtry
455     if [ $? != 0 ] ; then exit 1; fi
456     else exit 1
457     fi
458 ph10 674 if [ "$opt" = "-s" ] ; then echo " OK with study"
459     elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
460     else echo " OK"
461 ph10 671 fi
462     done
463 ph10 674 fi
464 ph10 448 fi
465    
466 ph10 651 # 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 ph10 671 if [ $utf8 -eq 0 -o $ucp -eq 0 ] ; then
471     echo " Skipped because Unicode property support is not available"
472 ph10 674 else
473 ph10 671 for opt in "" "-s" $jitopt; do
474 ph10 689 $sim $valgrind ./pcretest -q $opt $testdata/testinput13 testtry
475 ph10 671 if [ $? = 0 ] ; then
476     $cf $testdata/testoutput13 testtry
477     if [ $? != 0 ] ; then exit 1; fi
478     else exit 1
479     fi
480 ph10 674 if [ "$opt" = "-s" ] ; then echo " OK with study"
481     elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
482     else echo " OK"
483 ph10 671 fi
484     done
485 ph10 674 fi
486 ph10 671 fi
487    
488     # Test JIT-specific features when JIT is available
489    
490     if [ $do14 = yes ] ; then
491 ph10 689 echo "Test 14: JIT-specific features (JIT available)"
492 ph10 671 if [ $jit -eq 0 ] ; then
493 ph10 674 echo " Skipped because JIT is not available or not usable"
494 ph10 671 else
495 ph10 689 $sim $valgrind ./pcretest -q $testdata/testinput14 testtry
496 ph10 651 if [ $? = 0 ] ; then
497 ph10 671 $cf $testdata/testoutput14 testtry
498 ph10 651 if [ $? != 0 ] ; then exit 1; fi
499     else exit 1
500     fi
501 ph10 674 echo " OK"
502     fi
503 ph10 671 fi
504 ph10 674
505 ph10 671 # Test JIT-specific features when JIT is not available
506    
507     if [ $do15 = yes ] ; then
508 ph10 689 echo "Test 15: JIT-specific features (JIT not available)"
509 ph10 671 if [ $jit -ne 0 ] ; then
510     echo " Skipped because JIT is available"
511     else
512 ph10 689 $sim $valgrind ./pcretest -q $testdata/testinput15 testtry
513 ph10 671 if [ $? = 0 ] ; then
514     $cf $testdata/testoutput15 testtry
515     if [ $? != 0 ] ; then exit 1; fi
516     else exit 1
517 ph10 666 fi
518 ph10 674 echo " OK"
519     fi
520 ph10 651 fi
521    
522 nigel 49 # End

Properties

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

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12