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

Contents of /code/trunk/RunTest

Parent Directory Parent Directory | Revision Log Revision Log


Revision 766 - (hide annotations) (download)
Fri Nov 25 10:04:12 2011 UTC (2 years, 4 months ago) by ph10
File size: 15682 byte(s)
Some UTF-8 tests were in the wrong file.

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     if [ -n "$srcdir" -a -d "$srcdir" ] ; then
81     testdata="$srcdir/testdata"
82 ph10 706 elif [ -d "./testdata" ] ; then
83     testdata=./testdata
84     elif [ -d "../testdata" ] ; then
85     testdata=../testdata
86     else
87     echo "Cannot find the testdata directory"
88 ph10 708 exit 1
89 ph10 689 fi
90    
91 ph10 712 # Find which optional facilities are available. In some Windows environments
92     # the output of pcretest -C has CRLF at the end of each line, but the shell
93     # strips only linefeeds from the output of a `backquoted` command. Hence the
94     # alternative patterns.
95 ph10 689
96     case `$sim ./pcretest -C | $sim ./pcregrep 'Internal link size'` in
97 ph10 712 *2|*2[[:space:]]) link_size=2;;
98     *3|*3[[:space:]]) link_size=3;;
99     *4|*4[[:space:]]) link_size=4;;
100 ph10 689 *) echo "Failed to find internal link size"; exit 1;;
101     esac
102    
103     $sim ./pcretest -C | $sim ./pcregrep 'No UTF-8 support' >/dev/null
104     utf8=$?
105    
106     $sim ./pcretest -C | $sim ./pcregrep 'No Unicode properties support' >/dev/null
107     ucp=$?
108    
109     jitopt=
110     $sim ./pcretest -C | $sim ./pcregrep 'No just-in-time compiler support' \
111     >/dev/null
112     jit=$?
113     if [ $jit -ne 0 ] ; then
114     jitopt=-s+
115     fi
116    
117 ph10 116 if [ $utf8 -eq 0 ] ; then
118 nigel 63 if [ $do4 = yes ] ; then
119 nigel 75 echo "Can't run test 4 because UTF-8 support is not configured"
120 nigel 63 exit 1
121 nigel 77 fi
122 nigel 49 if [ $do5 = yes ] ; then
123 nigel 75 echo "Can't run test 5 because UTF-8 support is not configured"
124 nigel 49 exit 1
125 nigel 77 fi
126     if [ $do8 = yes ] ; then
127     echo "Can't run test 8 because UTF-8 support is not configured"
128     exit 1
129     fi
130 ph10 651 if [ $do12 = yes ] ; then
131     echo "Can't run test 12 because UTF-8 support is not configured"
132     exit 1
133     fi
134 nigel 77 fi
135 nigel 49
136 ph10 116 if [ $ucp -eq 0 ] ; then
137 nigel 75 if [ $do6 = yes ] ; then
138     echo "Can't run test 6 because Unicode property support is not configured"
139     exit 1
140     fi
141 nigel 77 if [ $do9 = yes ] ; then
142     echo "Can't run test 9 because Unicode property support is not configured"
143     exit 1
144     fi
145 ph10 164 if [ $do10 = yes ] ; then
146     echo "Can't run test 10 because Unicode property support is not configured"
147     exit 1
148     fi
149 ph10 651 if [ $do13 = yes ] ; then
150 ph10 448 echo "Can't run test 12 because Unicode property support is not configured"
151     exit 1
152     fi
153 nigel 77 fi
154 nigel 75
155 ph10 164 if [ $link_size -ne 2 ] ; then
156     if [ $do10 = yes ] ; then
157     echo "Can't run test 10 because the link size ($link_size) is not 2"
158     exit 1
159     fi
160 ph10 165 fi
161 ph10 164
162 ph10 671 if [ $jit -eq 0 ] ; then
163     if [ $do14 = "yes" ] ; then
164     echo "Can't run test 14 because JIT support is not configured"
165     exit 1
166     fi
167     else
168     if [ $do15 = "yes" ] ; then
169     echo "Can't run test 15 because JIT support is configured"
170     exit 1
171     fi
172 ph10 674 fi
173 ph10 116
174 ph10 671 # If no specific tests were requested, select all. Those that are not
175     # relevant will be skipped.
176    
177     if [ $do1 = no -a $do2 = no -a $do3 = no -a $do4 = no -a \
178     $do5 = no -a $do6 = no -a $do7 = no -a $do8 = no -a \
179     $do9 = no -a $do10 = no -a $do11 = no -a $do12 = no -a \
180     $do13 = no -a $do14 = no -a $do15 = no ] ; then
181 nigel 49 do1=yes
182 ph10 247 do2=yes
183 nigel 49 do3=yes
184 ph10 671 do4=yes
185     do5=yes
186     do6=yes
187 ph10 247 do7=yes
188 ph10 671 do8=yes
189     do9=yes
190     do10=yes
191 ph10 448 do11=yes
192 ph10 671 do12=yes
193     do13=yes
194     do14=yes
195     do15=yes
196 nigel 49 fi
197    
198 ph10 706 # Show which release and which test data
199 nigel 73
200 ph10 128 echo ""
201 ph10 706 echo PCRE C library tests using test data from $testdata
202     $sim ./pcretest /dev/null
203 nigel 73
204 ph10 666 # Primary test, compatible with JIT and all versions of Perl >= 5.8
205 nigel 49
206     if [ $do1 = yes ] ; then
207 ph10 559 echo "Test 1: main functionality (Compatible with Perl >= 5.8)"
208 ph10 666 for opt in "" "-s" $jitopt; do
209 ph10 689 $sim $valgrind ./pcretest -q $opt $testdata/testinput1 testtry
210 ph10 612 if [ $? = 0 ] ; then
211     $cf $testdata/testoutput1 testtry
212     if [ $? != 0 ] ; then exit 1; fi
213     else exit 1
214     fi
215 ph10 674 if [ "$opt" = "-s" ] ; then echo " OK with study"
216     elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
217     else echo " OK"
218 ph10 666 fi
219 ph10 654 done
220 nigel 49 fi
221    
222 ph10 666 # PCRE tests that are not JIT or Perl-compatible: API, errors, internals
223 nigel 49
224     if [ $do2 = yes ] ; then
225 ph10 766 echo "Test 2: API, errors, internals, and non-Perl stuff (not UTF-8)"
226 ph10 666 for opt in "" "-s" $jitopt; do
227 ph10 689 $sim $valgrind ./pcretest -q $opt $testdata/testinput2 testtry
228 ph10 612 if [ $? = 0 ] ; then
229     $cf $testdata/testoutput2 testtry
230     if [ $? != 0 ] ; then exit 1; fi
231     else
232     echo " "
233     echo "** Test 2 requires a lot of stack. If it has crashed with a"
234     echo "** segmentation fault, it may be that you do not have enough"
235     echo "** stack available by default. Please see the 'pcrestack' man"
236     echo "** page for a discussion of PCRE's stack usage."
237     echo " "
238     exit 1
239     fi
240 ph10 674 if [ "$opt" = "-s" ] ; then echo " OK with study"
241     elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
242     else echo " OK"
243 ph10 666 fi
244 ph10 654 done
245 nigel 49 fi
246    
247 ph10 157 # Locale-specific tests, provided that either the "fr_FR" or the "french"
248     # locale is available. The former is the Unix-like standard; the latter is
249 ph10 706 # for Windows. Another possibility is "fr", which needs to be run against
250     # the Windows-specific input and output files.
251 nigel 49
252 nigel 63 if [ $do3 = yes ] ; then
253 nigel 73 locale -a | grep '^fr_FR$' >/dev/null
254 nigel 49 if [ $? -eq 0 ] ; then
255 ph10 157 locale=fr_FR
256     infile=$testdata/testinput3
257     outfile=$testdata/testoutput3
258     else
259 ph10 706 infile=test3input
260     outfile=test3output
261 ph10 157 locale -a | grep '^french$' >/dev/null
262     if [ $? -eq 0 ] ; then
263     locale=french
264     sed 's/fr_FR/french/' $testdata/testinput3 >test3input
265     sed 's/fr_FR/french/' $testdata/testoutput3 >test3output
266     else
267 ph10 706 locale -a | grep '^fr$' >/dev/null
268     if [ $? -eq 0 ] ; then
269     locale=fr
270     sed 's/fr_FR/fr/' $testdata/wintestinput3 >test3input
271     sed 's/fr_FR/fr/' $testdata/wintestoutput3 >test3output
272     else
273     locale=
274 ph10 708 fi
275 ph10 157 fi
276 ph10 159 fi
277 ph10 157
278     if [ "$locale" != "" ] ; then
279     echo "Test 3: locale-specific features (using '$locale' locale)"
280 ph10 666 for opt in "" "-s" $jitopt; do
281 ph10 689 $sim $valgrind ./pcretest -q $opt $infile testtry
282 ph10 612 if [ $? = 0 ] ; then
283     $cf $outfile testtry
284     if [ $? != 0 ] ; then
285     echo " "
286     echo "Locale test did not run entirely successfully."
287     echo "This usually means that there is a problem with the locale"
288     echo "settings rather than a bug in PCRE."
289 ph10 654 break;
290 ph10 612 else
291 ph10 674 if [ "$opt" = "-s" ] ; then echo " OK with study"
292     elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
293     else echo " OK"
294 ph10 666 fi
295 ph10 612 fi
296     else exit 1
297 nigel 77 fi
298 ph10 654 done
299 nigel 49 else
300 ph10 712 echo "Cannot test locale-specific features - none of the 'fr_FR', 'fr' or"
301     echo "'french' locales exist, or the \"locale\" command is not available"
302 ph10 157 echo "to check for them."
303 nigel 77 echo " "
304 nigel 49 fi
305     fi
306    
307     # Additional tests for UTF8 support
308    
309 nigel 63 if [ $do4 = yes ] ; then
310 ph10 559 echo "Test 4: UTF-8 support (Compatible with Perl >= 5.8)"
311 ph10 671 if [ $utf8 -eq 0 ] ; then
312     echo " Skipped because UTF-8 support is not available"
313 ph10 674 else
314 ph10 671 for opt in "" "-s" $jitopt; do
315 ph10 689 $sim $valgrind ./pcretest -q $opt $testdata/testinput4 testtry
316 ph10 671 if [ $? = 0 ] ; then
317     $cf $testdata/testoutput4 testtry
318     if [ $? != 0 ] ; then exit 1; fi
319     else exit 1
320     fi
321 ph10 674 if [ "$opt" = "-s" ] ; then echo " OK with study"
322     elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
323     else echo " OK"
324 ph10 671 fi
325     done
326 ph10 674 fi
327 nigel 49 fi
328    
329 nigel 63 if [ $do5 = yes ] ; then
330 ph10 426 echo "Test 5: API, internals, and non-Perl stuff for UTF-8 support"
331 ph10 671 if [ $utf8 -eq 0 ] ; then
332     echo " Skipped because UTF-8 support is not available"
333 ph10 674 else
334 ph10 671 for opt in "" "-s" $jitopt; do
335 ph10 689 $sim $valgrind ./pcretest -q $opt $testdata/testinput5 testtry
336 ph10 671 if [ $? = 0 ] ; then
337     $cf $testdata/testoutput5 testtry
338     if [ $? != 0 ] ; then exit 1; fi
339     else exit 1
340     fi
341 ph10 674 if [ "$opt" = "-s" ] ; then echo " OK with study"
342     elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
343     else echo " OK"
344 ph10 671 fi
345     done
346 ph10 674 fi
347 nigel 49 fi
348    
349 nigel 75 if [ $do6 = yes ] ; then
350 ph10 559 echo "Test 6: Unicode property support (Compatible with Perl >= 5.10)"
351 ph10 671 if [ $utf8 -eq 0 -o $ucp -eq 0 ] ; then
352     echo " Skipped because Unicode property support is not available"
353 ph10 674 else
354 ph10 671 for opt in "" "-s" $jitopt; do
355 ph10 689 $sim $valgrind ./pcretest -q $opt $testdata/testinput6 testtry
356 ph10 671 if [ $? = 0 ] ; then
357     $cf $testdata/testoutput6 testtry
358     if [ $? != 0 ] ; then exit 1; fi
359     else exit 1
360     fi
361 ph10 674 if [ "$opt" = "-s" ] ; then echo " OK with study"
362     elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
363     else echo " OK"
364 ph10 671 fi
365     done
366 ph10 674 fi
367 nigel 75 fi
368    
369 nigel 77 # Tests for DFA matching support
370    
371     if [ $do7 = yes ] ; then
372     echo "Test 7: DFA matching"
373 ph10 654 for opt in "" "-s"; do
374 ph10 689 $sim $valgrind ./pcretest -q $opt -dfa $testdata/testinput7 testtry
375 ph10 612 if [ $? = 0 ] ; then
376     $cf $testdata/testoutput7 testtry
377     if [ $? != 0 ] ; then exit 1; fi
378     else exit 1
379     fi
380 ph10 671 if [ "$opt" = "-s" ] ; then echo " OK with study" ; else echo " OK"; fi
381 ph10 654 done
382 nigel 77 fi
383    
384     if [ $do8 = yes ] ; then
385     echo "Test 8: DFA matching with UTF-8"
386 ph10 671 if [ $utf8 -eq 0 ] ; then
387     echo " Skipped because UTF-8 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/testinput8 testtry
391 ph10 671 if [ $? = 0 ] ; then
392     $cf $testdata/testoutput8 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     if [ $do9 = yes ] ; then
402     echo "Test 9: DFA matching with Unicode properties"
403 ph10 671 if [ $utf8 -eq 0 -o $ucp -eq 0 ] ; then
404     echo " Skipped because Unicode property support is not available"
405 ph10 674 else
406 ph10 671 for opt in "" "-s"; do
407 ph10 689 $sim $valgrind ./pcretest -q $opt -dfa $testdata/testinput9 testtry
408 ph10 671 if [ $? = 0 ] ; then
409     $cf $testdata/testoutput9 testtry
410     if [ $? != 0 ] ; then exit 1; fi
411     else exit 1
412     fi
413     if [ "$opt" = "-s" ] ; then echo " OK with study" ; else echo " OK"; fi
414     done
415 ph10 674 fi
416 nigel 77 fi
417    
418 ph10 164 # Test of internal offsets and code sizes. This test is run only when there
419     # is Unicode property support and the link size is 2. The actual tests are
420     # mostly the same as in some of the above, but in this test we inspect some
421     # offsets and sizes that require a known link size. This is a doublecheck for
422     # the maintainer, just in case something changes unexpectely.
423    
424     if [ $do10 = yes ] ; then
425     echo "Test 10: Internal offsets and code size tests"
426 ph10 674 if [ $link_size -ne 2 ] ; then
427 ph10 671 echo " Skipped because link size is not 2"
428 ph10 674 elif [ $ucp -eq 0 ] ; then
429 ph10 671 echo " Skipped because Unicode property support is not available"
430 ph10 674 else
431 ph10 671 for opt in "" "-s"; do
432 ph10 689 $sim $valgrind ./pcretest -q $opt $testdata/testinput10 testtry
433 ph10 671 if [ $? = 0 ] ; then
434     $cf $testdata/testoutput10 testtry
435     if [ $? != 0 ] ; then exit 1; fi
436     else exit 1
437     fi
438     if [ "$opt" = "-s" ] ; then echo " OK with study" ; else echo " OK"; fi
439     done
440 ph10 674 fi
441 ph10 164 fi
442    
443 ph10 651 # Test of Perl >= 5.10 features without UTF8 support
444 ph10 448
445     if [ $do11 = yes ] ; then
446 ph10 651 echo "Test 11: Features from Perl >= 5.10 without UTF8 support"
447 ph10 666 for opt in "" "-s" $jitopt; do
448 ph10 689 $sim $valgrind ./pcretest -q $opt $testdata/testinput11 testtry
449 ph10 612 if [ $? = 0 ] ; then
450     $cf $testdata/testoutput11 testtry
451     if [ $? != 0 ] ; then exit 1; fi
452     else exit 1
453     fi
454 ph10 674 if [ "$opt" = "-s" ] ; then echo " OK with study"
455     elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
456     else echo " OK"
457 ph10 666 fi
458 ph10 654 done
459 ph10 448 fi
460    
461 ph10 651 # Test of Perl >= 5.10 features with UTF8 support
462 ph10 448
463     if [ $do12 = yes ] ; then
464 ph10 651 echo "Test 12: Features from Perl >= 5.10 with UTF8 support"
465 ph10 671 if [ $utf8 -eq 0 ] ; then
466     echo " Skipped because UTF-8 support is not available"
467 ph10 674 else
468 ph10 671 for opt in "" "-s" $jitopt; do
469 ph10 689 $sim $valgrind ./pcretest -q $opt $testdata/testinput12 testtry
470 ph10 671 if [ $? = 0 ] ; then
471     $cf $testdata/testoutput12 testtry
472     if [ $? != 0 ] ; then exit 1; fi
473     else exit 1
474     fi
475 ph10 674 if [ "$opt" = "-s" ] ; then echo " OK with study"
476     elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
477     else echo " OK"
478 ph10 671 fi
479     done
480 ph10 674 fi
481 ph10 448 fi
482    
483 ph10 651 # Test non-Perl-compatible Unicode property support
484    
485     if [ $do13 = yes ] ; then
486     echo "Test 13: API, internals, and non-Perl stuff for Unicode property support"
487 ph10 671 if [ $utf8 -eq 0 -o $ucp -eq 0 ] ; then
488     echo " Skipped because Unicode property support is not available"
489 ph10 674 else
490 ph10 671 for opt in "" "-s" $jitopt; do
491 ph10 689 $sim $valgrind ./pcretest -q $opt $testdata/testinput13 testtry
492 ph10 671 if [ $? = 0 ] ; then
493     $cf $testdata/testoutput13 testtry
494     if [ $? != 0 ] ; then exit 1; fi
495     else exit 1
496     fi
497 ph10 674 if [ "$opt" = "-s" ] ; then echo " OK with study"
498     elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
499     else echo " OK"
500 ph10 671 fi
501     done
502 ph10 674 fi
503 ph10 671 fi
504    
505     # Test JIT-specific features when JIT is available
506    
507     if [ $do14 = yes ] ; then
508 ph10 689 echo "Test 14: JIT-specific features (JIT available)"
509 ph10 671 if [ $jit -eq 0 ] ; then
510 ph10 674 echo " Skipped because JIT is not available or not usable"
511 ph10 671 else
512 ph10 689 $sim $valgrind ./pcretest -q $testdata/testinput14 testtry
513 ph10 651 if [ $? = 0 ] ; then
514 ph10 671 $cf $testdata/testoutput14 testtry
515 ph10 651 if [ $? != 0 ] ; then exit 1; fi
516     else exit 1
517     fi
518 ph10 674 echo " OK"
519     fi
520 ph10 671 fi
521 ph10 674
522 ph10 671 # Test JIT-specific features when JIT is not available
523    
524     if [ $do15 = yes ] ; then
525 ph10 689 echo "Test 15: JIT-specific features (JIT not available)"
526 ph10 671 if [ $jit -ne 0 ] ; then
527     echo " Skipped because JIT is available"
528     else
529 ph10 689 $sim $valgrind ./pcretest -q $testdata/testinput15 testtry
530 ph10 671 if [ $? = 0 ] ; then
531     $cf $testdata/testoutput15 testtry
532     if [ $? != 0 ] ; then exit 1; fi
533     else exit 1
534 ph10 666 fi
535 ph10 674 echo " OK"
536     fi
537 ph10 651 fi
538    
539 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