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

Contents of /code/trunk/RunTest

Parent Directory Parent Directory | Revision Log Revision Log


Revision 674 - (hide annotations) (download)
Fri Aug 26 18:17:51 2011 UTC (3 years, 3 months ago) by ph10
File size: 14772 byte(s)
More JIT testing.

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