/[pcre]/code/branches/pcre16/RunTest
ViewVC logotype

Contents of /code/branches/pcre16/RunTest

Parent Directory Parent Directory | Revision Log Revision Log


Revision 671 - (hide annotations) (download)
Tue Aug 23 11:17:49 2011 UTC (3 years ago) by ph10
Original Path: code/trunk/RunTest
File size: 14597 byte(s)
Refactor RunTest and add JIT-specific tests.

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