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

Contents of /code/branches/pcre16/RunTest

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.5