1#! /bin/sh
2
3###############################################################################
4# Run the PCRE tests using the pcretest program. The appropriate tests are
5# selected, depending on which build-time options were used.
6#
7# All tests are now run both with and without -s, to ensure that everything is
8# tested with and without studying. However, there are some tests that produce
9# different output after studying, typically when we are tracing the actual
10# matching process (for example, using auto-callouts). In these few cases, the
11# tests are duplicated in the files, one with /S to force studying always, and
12# one with /SS to force *not* studying always. The use of -s doesn't then make
13# any difference to their output. There is also one test which compiles invalid
14# UTF-8 with the UTF-8 check turned off; for this, studying must also be
15# disabled with /SS.
16#
17# When JIT support is available, all appropriate tests are also run with -s+ to
18# test (again, almost) everything with studying and the JIT option, unless
19# "nojit" is given on the command line. There are also two tests for
20# JIT-specific features, one to be run when JIT support is available (unless
21# "nojit" is specified), and one when it is not.
22#
23# Whichever of the 8-, 16- and 32-bit libraries exist are tested. It is also
24# possible to select which to test by giving "-8", "-16" or "-32" on the
25# command line.
26#
27# As well as "nojit", "-8", "-16", and "-32", arguments for this script are
28# individual test numbers, ranges of tests such as 3-6 or 3- (meaning 3 to the
29# end), or a number preceded by ~ to exclude a test. For example, "3-15 ~10"
30# runs tests 3 to 15, excluding test 10, and just "~10" runs all the tests
31# except test 10. Whatever order the arguments are in, the tests are always run
32# in numerical order.
33#
34# The special argument "3S" runs test 3, stopping if it fails. Test 3 is the
35# locale test, and failure usually means there's an issue with the locale
36# rather than a bug in PCRE, so normally subsequent tests are run. "3S" is
37# useful when you want to debug or update the test.
38#
39# Inappropriate tests are automatically skipped (with a comment to say so): for
40# example, if JIT support is not compiled, test 12 is skipped, whereas if JIT
41# support is compiled, test 13 is skipped.
42#
43# Other arguments can be one of the words "valgrind", "valgrind-log", or "sim"
44# followed by an argument to run cross-compiled executables under a simulator,
45# for example:
46#
47# RunTest 3 sim "qemu-arm -s 8388608"
48#
49# There are two special cases where only one argument is allowed:
50#
51# If the first and only argument is "ebcdic", the script runs the special
52# EBCDIC test that can be useful for checking certain EBCDIC features, even
53# when run in an ASCII environment.
54#
55# If the script is obeyed as "RunTest list", a list of available tests is
56# output, but none of them are run.
57###############################################################################
58
59# Define test titles in variables so that they can be output as a list. Some
60# of them are modified (e.g. with -8 or -16) when used in the actual tests.
61
62title1="Test 1: Main functionality (Compatible with Perl >= 5.10)"
63title2="Test 2: API, errors, internals, and non-Perl stuff"
64title3="Test 3: Locale-specific features"
65title4A="Test 4: UTF"
66title4B=" support (Compatible with Perl >= 5.10)"
67title5="Test 5: API, internals, and non-Perl stuff for UTF"
68title6="Test 6: Unicode property support (Compatible with Perl >= 5.10)"
69title7="Test 7: API, internals, and non-Perl stuff for Unicode property support"
70title8="Test 8: DFA matching main functionality"
71title9="Test 9: DFA matching with UTF"
72title10="Test 10: DFA matching with Unicode properties"
73title11="Test 11: Internal offsets and code size tests"
74title12="Test 12: JIT-specific features (when JIT is available)"
75title13="Test 13: JIT-specific features (when JIT is not available)"
76title14="Test 14: Specials for the basic 8-bit library"
77title15="Test 15: Specials for the 8-bit library with UTF-8 support"
78title16="Test 16: Specials for the 8-bit library with Unicode propery support"
79title17="Test 17: Specials for the basic 16/32-bit library"
80title18="Test 18: Specials for the 16/32-bit library with UTF-16/32 support"
81title19="Test 19: Specials for the 16/32-bit library with Unicode property support"
82title20="Test 20: DFA specials for the basic 16/32-bit library"
83title21="Test 21: Reloads for the basic 16/32-bit library"
84title22="Test 22: Reloads for the 16/32-bit library with UTF-16/32 support"
85title23="Test 23: Specials for the 16-bit library"
86title24="Test 24: Specials for the 16-bit library with UTF-16 support"
87title25="Test 25: Specials for the 32-bit library"
88title26="Test 26: Specials for the 32-bit library with UTF-32 support"
89
90maxtest=26
91
92if [ $# -eq 1 -a "$1" = "list" ]; then
93  echo $title1
94  echo $title2 "(not UTF)"
95  echo $title3
96  echo $title4A $title4B
97  echo $title5 support
98  echo $title6
99  echo $title7
100  echo $title8
101  echo $title9
102  echo $title10
103  echo $title11
104  echo $title12
105  echo $title13
106  echo $title14
107  echo $title15
108  echo $title16
109  echo $title17
110  echo $title18
111  echo $title19
112  echo $title20
113  echo $title21
114  echo $title22
115  echo $title23
116  echo $title24
117  echo $title25
118  echo $title26
119  exit 0
120fi
121
122# Set up a suitable "diff" command for comparison. Some systems
123# have a diff that lacks a -u option. Try to deal with this.
124
125cf="diff"
126diff -u /dev/null /dev/null 2>/dev/null && cf="diff -u"
127
128# Find the test data
129
130if [ -n "$srcdir" -a -d "$srcdir" ] ; then
131  testdata="$srcdir/testdata"
132elif [ -d "./testdata" ] ; then
133  testdata=./testdata
134elif [ -d "../testdata" ] ; then
135  testdata=../testdata
136else
137  echo "Cannot find the testdata directory"
138  exit 1
139fi
140
141
142# ------ Special EBCDIC Test -------
143
144if [ $# -eq 1 -a "$1" = "ebcdic" ]; then
145  ./pcretest -C ebcdic >/dev/null
146  ebcdic=$?
147  if [ $ebcdic -ne 1 ] ; then
148    echo "Cannot run EBCDIC tests: EBCDIC support not compiled"
149    exit 1
150  fi
151
152  for opt in "" "-s" "-dfa" "-s -dfa"; do
153    ./pcretest -q $opt $testdata/testinputEBC >testtry
154    if [ $? = 0 ] ; then
155      $cf $testdata/testoutputEBC testtry
156      if [ $? != 0 ] ; then exit 1; fi
157    else exit 1
158    fi
159    if [ "$opt" = "-s" ] ; then echo "  OK with study"
160    elif [ "$opt" = "-dfa" ] ; then echo "  OK using DFA"
161    elif [ "$opt" = "-s -dfa" ] ; then echo "  OK using DFA with study"
162    else echo "  OK"
163    fi
164  done
165
166exit 0
167fi
168
169
170# ------ Normal Tests ------
171
172# Default values
173
174arg8=
175arg16=
176arg32=
177nojit=
178sim=
179skip=
180valgrind=
181vjs=
182
183# This is in case the caller has set aliases (as I do - PH)
184unset cp ls mv rm
185
186# Process options and select which tests to run; for those that are explicitly
187# requested, check that the necessary optional facilities are available.
188
189do1=no
190do2=no
191do3=no
192do4=no
193do5=no
194do6=no
195do7=no
196do8=no
197do9=no
198do10=no
199do11=no
200do12=no
201do13=no
202do14=no
203do15=no
204do16=no
205do17=no
206do18=no
207do19=no
208do20=no
209do21=no
210do22=no
211do23=no
212do24=no
213do25=no
214do26=no
215
216while [ $# -gt 0 ] ; do
217  case $1 in
218    1) do1=yes;;
219    2) do2=yes;;
220    3) do3=yes;;
221    4) do4=yes;;
222    5) do5=yes;;
223    6) do6=yes;;
224    7) do7=yes;;
225    8) do8=yes;;
226    9) do9=yes;;
227   10) do10=yes;;
228   11) do11=yes;;
229   12) do12=yes;;
230   13) do13=yes;;
231   14) do14=yes;;
232   15) do15=yes;;
233   16) do16=yes;;
234   17) do17=yes;;
235   18) do18=yes;;
236   19) do19=yes;;
237   20) do20=yes;;
238   21) do21=yes;;
239   22) do22=yes;;
240   23) do23=yes;;
241   24) do24=yes;;
242   25) do25=yes;;
243   26) do26=yes;;
244   -8) arg8=yes;;
245  -16) arg16=yes;;
246  -32) arg32=yes;;
247   nojit) nojit=yes;;
248   sim) shift; sim=$1;;
249   valgrind) valgrind="valgrind --tool=memcheck -q --smc-check=all";;
250   valgrind-log) valgrind="valgrind --tool=memcheck --num-callers=30 --leak-check=no --error-limit=no --smc-check=all --log-file=report.%p ";;
251   ~*)
252     if expr "$1" : '~[0-9][0-9]*$' >/dev/null; then
253       skip="$skip `expr "$1" : '~\([0-9]*\)*$'`"
254     else
255       echo "Unknown option or test selector '$1'"; exit 1
256     fi
257   ;;
258   *-*)
259     if expr "$1" : '[0-9][0-9]*-[0-9]*$' >/dev/null; then
260       tf=`expr "$1" : '\([0-9]*\)'`
261       tt=`expr "$1" : '.*-\([0-9]*\)'`
262       if [ "$tt" = "" ] ; then tt=$maxtest; fi
263       if expr \( "$tf" "<" 1 \) \| \( "$tt" ">" "$maxtest" \) >/dev/null; then
264         echo "Invalid test range '$1'"; exit 1
265       fi
266       while expr "$tf" "<=" "$tt" >/dev/null; do
267         eval do${tf}=yes
268         tf=`expr $tf + 1`
269       done
270     else
271       echo "Invalid test range '$1'"; exit 1
272     fi
273   ;;
274   *) echo "Unknown option or test selector '$1'"; exit 1;;
275  esac
276  shift
277done
278
279# Find which optional facilities are available.
280
281$sim ./pcretest -C linksize >/dev/null
282link_size=$?
283if [ $link_size -lt 2 ] ; then
284  echo "Failed to find internal link size"
285  exit 1
286fi
287if [ $link_size -gt 4 ] ; then
288  echo "Failed to find internal link size"
289  exit 1
290fi
291
292# All of 8-bit, 16-bit, and 32-bit character strings may be supported, but only
293# one need be.
294
295$sim ./pcretest -C pcre8 >/dev/null
296support8=$?
297$sim ./pcretest -C pcre16 >/dev/null
298support16=$?
299$sim ./pcretest -C pcre32 >/dev/null
300support32=$?
301
302# Initialize all bitsizes skipped
303
304test8=skip
305test16=skip
306test32=skip
307
308# If no bitsize arguments, select all that are available
309
310if [ "$arg8$arg16$arg32" = "" ] ; then
311  if [ $support8 -ne 0 ] ; then
312    test8=
313  fi
314  if [ $support16 -ne 0 ] ; then
315    test16=-16
316  fi
317  if [ $support32 -ne 0 ] ; then
318    test32=-32
319  fi
320
321# Select requested bit sizes
322
323else
324  if [ "$arg8" = yes ] ; then
325    if [ $support8 -eq 0 ] ; then
326      echo "Cannot run 8-bit library tests: 8-bit library not compiled"
327      exit 1
328    fi
329    test8=
330  fi
331  if [ "$arg16" = yes ] ; then
332    if [ $support16 -eq 0 ] ; then
333      echo "Cannot run 16-bit library tests: 16-bit library not compiled"
334      exit 1
335    fi
336    test16=-16
337  fi
338  if [ "$arg32" = yes ] ; then
339    if [ $support32 -eq 0 ] ; then
340      echo "Cannot run 32-bit library tests: 32-bit library not compiled"
341      exit 1
342    fi
343    test32=-32
344  fi
345fi
346
347# UTF support always applies to all bit sizes if both are supported; we can't
348# have UTF-8 support without UTF-16 support (for example).
349
350$sim ./pcretest -C utf >/dev/null
351utf=$?
352
353$sim ./pcretest -C ucp >/dev/null
354ucp=$?
355
356jitopt=
357$sim ./pcretest -C jit >/dev/null
358jit=$?
359if [ $jit -ne 0 -a "$nojit" != "yes" ] ; then
360  jitopt=-s+
361  if [ "$valgrind" != "" ] ; then
362    vjs="--suppressions=$testdata/valgrind-jit.supp"
363  fi
364fi
365
366# If no specific tests were requested, select all. Those that are not
367# relevant will be automatically skipped.
368
369if [ $do1  = no -a $do2  = no -a $do3  = no -a $do4  = no -a \
370     $do5  = no -a $do6  = no -a $do7  = no -a $do8  = no -a \
371     $do9  = no -a $do10 = no -a $do11 = no -a $do12 = no -a \
372     $do13 = no -a $do14 = no -a $do15 = no -a $do16 = no -a \
373     $do17 = no -a $do18 = no -a $do19 = no -a $do20 = no -a \
374     $do21 = no -a $do22 = no -a $do23 = no -a $do24 = no -a \
375     $do25 = no -a $do26 = no ] ; then
376  do1=yes
377  do2=yes
378  do3=yes
379  do4=yes
380  do5=yes
381  do6=yes
382  do7=yes
383  do8=yes
384  do9=yes
385  do10=yes
386  do11=yes
387  do12=yes
388  do13=yes
389  do14=yes
390  do15=yes
391  do16=yes
392  do17=yes
393  do18=yes
394  do19=yes
395  do20=yes
396  do21=yes
397  do22=yes
398  do23=yes
399  do24=yes
400  do25=yes
401  do26=yes
402fi
403
404# Handle any explicit skips at this stage, so that an argument list may consist
405# only of explicit skips.
406
407for i in $skip; do eval do$i=no; done
408
409# Show which release and which test data
410
411echo ""
412echo PCRE C library tests using test data from $testdata
413$sim ./pcretest /dev/null
414
415for bmode in "$test8" "$test16" "$test32"; do
416  case "$bmode" in
417    skip) continue;;
418    -16)  if [ "$test8$test32" != "skipskip" ] ; then echo ""; fi
419          bits=16; echo "---- Testing 16-bit library ----"; echo "";;
420    -32)  if [ "$test8$test16" != "skipskip" ] ; then echo ""; fi
421          bits=32; echo "---- Testing 32-bit library ----"; echo "";;
422    *)    bits=8; echo "---- Testing 8-bit library ----"; echo "";;
423  esac
424
425# Primary test, compatible with JIT and all versions of Perl >= 5.8
426
427if [ $do1 = yes ] ; then
428  echo $title1
429  for opt in "" "-s" $jitopt; do
430    $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput1 testtry
431    if [ $? = 0 ] ; then
432      $cf $testdata/testoutput1 testtry
433      if [ $? != 0 ] ; then exit 1; fi
434    else exit 1
435    fi
436    if [ "$opt" = "-s" ] ; then echo "  OK with study"
437    elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
438    else echo "  OK"
439    fi
440  done
441fi
442
443# PCRE tests that are not JIT or Perl-compatible: API, errors, internals
444
445if [ $do2 = yes ] ; then
446  echo $title2 "(not UTF-$bits)"
447  for opt in "" "-s" $jitopt; do
448    $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput2 testtry
449    if [ $? = 0 ] ; then
450      $cf $testdata/testoutput2 testtry
451      if [ $? != 0 ] ; then exit 1; fi
452    else
453      echo " "
454      echo "** Test 2 requires a lot of stack. If it has crashed with a"
455      echo "** segmentation fault, it may be that you do not have enough"
456      echo "** stack available by default. Please see the 'pcrestack' man"
457      echo "** page for a discussion of PCRE's stack usage."
458      echo " "
459      exit 1
460    fi
461    if [ "$opt" = "-s" ] ; then echo "  OK with study"
462    elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
463    else echo "  OK"
464    fi
465  done
466fi
467
468# Locale-specific tests, provided that either the "fr_FR" or the "french"
469# locale is available. The former is the Unix-like standard; the latter is
470# for Windows. Another possibility is "fr". Unfortunately, different versions
471# of the French locale give different outputs for some items. This test passes
472# if the output matches any one of the alternative output files.
473
474if [ $do3 = yes ] ; then
475  locale -a | grep '^fr_FR$' >/dev/null
476  if [ $? -eq 0 ] ; then
477    locale=fr_FR
478    infile=$testdata/testinput3
479    outfile=$testdata/testoutput3
480    outfile2=$testdata/testoutput3A
481    outfile3=$testdata/testoutput3B
482  else
483    infile=test3input
484    outfile=test3output
485    outfile2=test3outputA
486    outfile3=test3outputB
487    locale -a | grep '^french$' >/dev/null
488    if [ $? -eq 0 ] ; then
489      locale=french
490      sed 's/fr_FR/french/' $testdata/testinput3 >test3input
491      sed 's/fr_FR/french/' $testdata/testoutput3 >test3output
492      sed 's/fr_FR/french/' $testdata/testoutput3A >test3outputA
493      sed 's/fr_FR/french/' $testdata/testoutput3B >test3outputB
494    else
495      locale -a | grep '^fr$' >/dev/null
496      if [ $? -eq 0 ] ; then
497        locale=fr
498        sed 's/fr_FR/fr/' $testdata/intestinput3 >test3input
499        sed 's/fr_FR/fr/' $testdata/intestoutput3 >test3output
500        sed 's/fr_FR/fr/' $testdata/intestoutput3A >test3outputA
501        sed 's/fr_FR/fr/' $testdata/intestoutput3B >test3outputB
502      else
503        locale=
504      fi
505    fi
506  fi
507
508  if [ "$locale" != "" ] ; then
509    echo $title3 "(using '$locale' locale)"
510    for opt in "" "-s" $jitopt; do
511      $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $infile testtry
512      if [ $? = 0 ] ; then
513        if $cf $outfile testtry >teststdout || \
514           $cf $outfile2 testtry >teststdout || \
515           $cf $outfile3 testtry >teststdout
516        then
517          if [ "$opt" = "-s" ] ; then echo "  OK with study"
518          elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
519          else echo "  OK"
520          fi
521        else
522          echo "** Locale test did not run successfully. The output did not match"
523          echo "   $outfile, $outfile2 or $outfile3."
524          echo "   This may mean that there is a problem with the locale settings rather"
525          echo "   than a bug in PCRE."
526          exit 1
527        fi
528      else exit 1
529      fi
530    done
531  else
532    echo "Cannot test locale-specific features - none of the 'fr_FR', 'fr' or"
533    echo "'french' locales exist, or the \"locale\" command is not available"
534    echo "to check for them."
535    echo " "
536  fi
537fi
538
539# Additional tests for UTF support
540
541if [ $do4 = yes ] ; then
542  echo ${title4A}-${bits}${title4B}
543  if [ $utf -eq 0 ] ; then
544    echo "  Skipped because UTF-$bits support is not available"
545  else
546    for opt in "" "-s" $jitopt; do
547      $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput4 testtry
548      if [ $? = 0 ] ; then
549        $cf $testdata/testoutput4 testtry
550        if [ $? != 0 ] ; then exit 1; fi
551      else exit 1
552      fi
553      if [ "$opt" = "-s" ] ; then echo "  OK with study"
554      elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
555      else echo "  OK"
556      fi
557    done
558  fi
559fi
560
561if [ $do5 = yes ] ; then
562  echo ${title5}-${bits} support
563  if [ $utf -eq 0 ] ; then
564    echo "  Skipped because UTF-$bits support is not available"
565  else
566    for opt in "" "-s" $jitopt; do
567      $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput5 testtry
568      if [ $? = 0 ] ; then
569        $cf $testdata/testoutput5 testtry
570        if [ $? != 0 ] ; then exit 1; fi
571      else exit 1
572      fi
573      if [ "$opt" = "-s" ] ; then echo "  OK with study"
574      elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
575      else echo "  OK"
576      fi
577    done
578  fi
579fi
580
581if [ $do6 = yes ] ; then
582  echo $title6
583  if [ $utf -eq 0 -o $ucp -eq 0 ] ; then
584    echo "  Skipped because Unicode property support is not available"
585  else
586    for opt in "" "-s" $jitopt; do
587      $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput6 testtry
588      if [ $? = 0 ] ; then
589        $cf $testdata/testoutput6 testtry
590        if [ $? != 0 ] ; then exit 1; fi
591      else exit 1
592      fi
593      if [ "$opt" = "-s" ] ; then echo "  OK with study"
594      elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
595      else echo "  OK"
596      fi
597    done
598  fi
599fi
600
601# Test non-Perl-compatible Unicode property support
602
603if [ $do7 = yes ] ; then
604  echo $title7
605  if [ $utf -eq 0 -o $ucp -eq 0 ] ; then
606    echo "  Skipped because Unicode property support is not available"
607  else
608    for opt in "" "-s" $jitopt; do
609      $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput7 testtry
610      if [ $? = 0 ] ; then
611        $cf $testdata/testoutput7 testtry
612        if [ $? != 0 ] ; then exit 1; fi
613      else exit 1
614      fi
615      if [ "$opt" = "-s" ] ; then echo "  OK with study"
616      elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
617      else echo "  OK"
618      fi
619    done
620  fi
621fi
622
623# Tests for DFA matching support
624
625if [ $do8 = yes ] ; then
626  echo $title8
627  for opt in "" "-s"; do
628    $sim $valgrind ./pcretest -q $bmode $opt -dfa $testdata/testinput8 testtry
629    if [ $? = 0 ] ; then
630      $cf $testdata/testoutput8 testtry
631      if [ $? != 0 ] ; then exit 1; fi
632    else exit 1
633    fi
634    if [ "$opt" = "-s" ] ; then echo "  OK with study" ; else echo "  OK"; fi
635  done
636fi
637
638if [ $do9 = yes ] ; then
639  echo ${title9}-${bits}
640  if [ $utf -eq 0 ] ; then
641    echo "  Skipped because UTF-$bits support is not available"
642  else
643    for opt in "" "-s"; do
644      $sim $valgrind ./pcretest -q $bmode $opt -dfa $testdata/testinput9 testtry
645      if [ $? = 0 ] ; then
646        $cf $testdata/testoutput9 testtry
647        if [ $? != 0 ] ; then exit 1; fi
648      else exit 1
649      fi
650      if [ "$opt" = "-s" ] ; then echo "  OK with study" ; else echo "  OK"; fi
651    done
652  fi
653fi
654
655if [ $do10 = yes ] ; then
656  echo $title10
657  if [ $utf -eq 0 -o $ucp -eq 0 ] ; then
658    echo "  Skipped because Unicode property support is not available"
659  else
660    for opt in "" "-s"; do
661      $sim $valgrind ./pcretest -q $bmode $opt -dfa $testdata/testinput10 testtry
662      if [ $? = 0 ] ; then
663        $cf $testdata/testoutput10 testtry
664        if [ $? != 0 ] ; then exit 1; fi
665      else exit 1
666      fi
667      if [ "$opt" = "-s" ] ; then echo "  OK with study" ; else echo "  OK"; fi
668    done
669  fi
670fi
671
672# Test of internal offsets and code sizes. This test is run only when there
673# is Unicode property support and the link size is 2. The actual tests are
674# mostly the same as in some of the above, but in this test we inspect some
675# offsets and sizes that require a known link size. This is a doublecheck for
676# the maintainer, just in case something changes unexpectely. The output from
677# this test is not the same in 8-bit and 16-bit modes.
678
679if [ $do11 = yes ] ; then
680  echo $title11
681  if [ $link_size -ne 2 ] ; then
682    echo "  Skipped because link size is not 2"
683  elif [ $ucp -eq 0 ] ; then
684    echo "  Skipped because Unicode property support is not available"
685  else
686    for opt in "" "-s"; do
687      $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput11 testtry
688      if [ $? = 0 ] ; then
689        $cf $testdata/testoutput11-$bits testtry
690        if [ $? != 0 ] ; then exit 1; fi
691      else exit 1
692      fi
693      if [ "$opt" = "-s" ] ; then echo "  OK with study" ; else echo "  OK"; fi
694    done
695  fi
696fi
697
698# Test JIT-specific features when JIT is available
699
700if [ $do12 = yes ] ; then
701  echo $title12
702  if [ $jit -eq 0 -o "$nojit" = "yes" ] ; then
703    echo "  Skipped because JIT is not available or not usable"
704  else
705    $sim $valgrind $vjs ./pcretest -q $bmode $testdata/testinput12 testtry
706    if [ $? = 0 ] ; then
707      $cf $testdata/testoutput12 testtry
708      if [ $? != 0 ] ; then exit 1; fi
709    else exit 1
710    fi
711    echo "  OK"
712  fi
713fi
714
715# Test JIT-specific features when JIT is not available
716
717if [ $do13 = yes ] ; then
718  echo $title13
719  if [ $jit -ne 0 ] ; then
720    echo "  Skipped because JIT is available"
721  else
722    $sim $valgrind ./pcretest -q $bmode $testdata/testinput13 testtry
723    if [ $? = 0 ] ; then
724      $cf $testdata/testoutput13 testtry
725      if [ $? != 0 ] ; then exit 1; fi
726    else exit 1
727    fi
728    echo "  OK"
729  fi
730fi
731
732# Tests for 8-bit-specific features
733
734if [ "$do14" = yes ] ; then
735  echo $title14
736  if [ "$bits" = "16" -o "$bits" = "32" ] ; then
737    echo "  Skipped when running 16/32-bit tests"
738  else
739    cp -f $testdata/saved16 testsaved16
740    cp -f $testdata/saved32 testsaved32
741    for opt in "" "-s" $jitopt; do
742      $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput14 testtry
743      if [ $? = 0 ] ; then
744        $cf $testdata/testoutput14 testtry
745        if [ $? != 0 ] ; then exit 1; fi
746      else exit 1
747      fi
748      if [ "$opt" = "-s" ] ; then echo "  OK with study"
749      elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
750      else echo "  OK"
751      fi
752    done
753  fi
754fi
755
756# Tests for 8-bit-specific features (needs UTF-8 support)
757
758if [ "$do15" = yes ] ; then
759  echo $title15
760  if [ "$bits" = "16" -o "$bits" = "32" ] ; then
761    echo "  Skipped when running 16/32-bit tests"
762  elif [ $utf -eq 0 ] ; then
763    echo "  Skipped because UTF-$bits support is not available"
764  else
765    for opt in "" "-s" $jitopt; do
766      $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput15 testtry
767      if [ $? = 0 ] ; then
768        $cf $testdata/testoutput15 testtry
769        if [ $? != 0 ] ; then exit 1; fi
770      else exit 1
771      fi
772      if [ "$opt" = "-s" ] ; then echo "  OK with study"
773      elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
774      else echo "  OK"
775      fi
776    done
777  fi
778fi
779
780# Tests for 8-bit-specific features (Unicode property support)
781
782if [ $do16 = yes ] ; then
783  echo $title16
784  if [ "$bits" = "16" -o "$bits" = "32" ] ; then
785    echo "  Skipped when running 16/32-bit tests"
786  elif [ $ucp -eq 0 ] ; then
787    echo "  Skipped because Unicode property support is not available"
788  else
789    for opt in "" "-s" $jitopt; do
790      $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput16 testtry
791      if [ $? = 0 ] ; then
792        $cf $testdata/testoutput16 testtry
793        if [ $? != 0 ] ; then exit 1; fi
794      else exit 1
795      fi
796      if [ "$opt" = "-s" ] ; then echo "  OK with study"
797      elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
798      else echo "  OK"
799      fi
800    done
801  fi
802fi
803
804# Tests for 16/32-bit-specific features
805
806if [ $do17 = yes ] ; then
807  echo $title17
808  if [ "$bits" = "8" ] ; then
809    echo "  Skipped when running 8-bit tests"
810  else
811    for opt in "" "-s" $jitopt; do
812      $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput17 testtry
813      if [ $? = 0 ] ; then
814        $cf $testdata/testoutput17 testtry
815        if [ $? != 0 ] ; then exit 1; fi
816      else exit 1
817      fi
818      if [ "$opt" = "-s" ] ; then echo "  OK with study"
819      elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
820      else echo "  OK"
821      fi
822    done
823  fi
824fi
825
826# Tests for 16/32-bit-specific features (UTF-16/32 support)
827
828if [ $do18 = yes ] ; then
829  echo $title18
830  if [ "$bits" = "8" ] ; then
831    echo "  Skipped when running 8-bit tests"
832  elif [ $utf -eq 0 ] ; then
833    echo "  Skipped because UTF-$bits support is not available"
834  else
835    for opt in "" "-s" $jitopt; do
836      $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput18 testtry
837      if [ $? = 0 ] ; then
838        $cf $testdata/testoutput18-$bits testtry
839        if [ $? != 0 ] ; then exit 1; fi
840      else exit 1
841      fi
842      if [ "$opt" = "-s" ] ; then echo "  OK with study"
843      elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
844      else echo "  OK"
845      fi
846    done
847  fi
848fi
849
850# Tests for 16/32-bit-specific features (Unicode property support)
851
852if [ $do19 = yes ] ; then
853  echo $title19
854  if [ "$bits" = "8" ] ; then
855    echo "  Skipped when running 8-bit tests"
856  elif [ $ucp -eq 0 ] ; then
857    echo "  Skipped because Unicode property support is not available"
858  else
859    for opt in "" "-s" $jitopt; do
860      $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput19 testtry
861      if [ $? = 0 ] ; then
862        $cf $testdata/testoutput19 testtry
863        if [ $? != 0 ] ; then exit 1; fi
864      else exit 1
865      fi
866      if [ "$opt" = "-s" ] ; then echo "  OK with study"
867      elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
868      else echo "  OK"
869      fi
870    done
871  fi
872fi
873
874# Tests for 16/32-bit-specific features in DFA non-UTF-16/32 mode
875
876if [ $do20 = yes ] ; then
877  echo $title20
878  if [ "$bits" = "8" ] ; then
879    echo "  Skipped when running 8-bit tests"
880  else
881    for opt in "" "-s"; do
882      $sim $valgrind ./pcretest -q $bmode $opt -dfa $testdata/testinput20 testtry
883      if [ $? = 0 ] ; then
884        $cf $testdata/testoutput20 testtry
885        if [ $? != 0 ] ; then exit 1; fi
886      else exit 1
887      fi
888      if [ "$opt" = "-s" ] ; then echo "  OK with study"
889      else echo "  OK"
890      fi
891    done
892  fi
893fi
894
895# Tests for reloads with 16/32-bit library
896
897if [ $do21 = yes ] ; then
898  echo $title21
899  if [ "$bits" = "8" ] ; then
900    echo "  Skipped when running 8-bit tests"
901  elif [ $link_size -ne 2 ] ; then
902    echo "  Skipped because link size is not 2"
903  else
904    cp -f $testdata/saved8 testsaved8
905    cp -f $testdata/saved16LE-1 testsaved16LE-1
906    cp -f $testdata/saved16BE-1 testsaved16BE-1
907    cp -f $testdata/saved32LE-1 testsaved32LE-1
908    cp -f $testdata/saved32BE-1 testsaved32BE-1
909    $sim $valgrind ./pcretest -q $bmode $testdata/testinput21 testtry
910    if [ $? = 0 ] ; then
911      $cf $testdata/testoutput21-$bits testtry
912      if [ $? != 0 ] ; then exit 1; fi
913    else exit 1
914    fi
915    echo "  OK"
916  fi
917fi
918
919# Tests for reloads with 16/32-bit library (UTF-16 support)
920
921if [ $do22 = yes ] ; then
922  echo $title22
923  if [ "$bits" = "8" ] ; then
924    echo "  Skipped when running 8-bit tests"
925  elif [ $utf -eq 0 ] ; then
926    echo "  Skipped because UTF-$bits support is not available"
927  elif [ $link_size -ne 2 ] ; then
928    echo "  Skipped because link size is not 2"
929  else
930    cp -f $testdata/saved16LE-2 testsaved16LE-2
931    cp -f $testdata/saved16BE-2 testsaved16BE-2
932    cp -f $testdata/saved32LE-2 testsaved32LE-2
933    cp -f $testdata/saved32BE-2 testsaved32BE-2
934    $sim $valgrind ./pcretest -q $bmode $testdata/testinput22 testtry
935    if [ $? = 0 ] ; then
936      $cf $testdata/testoutput22-$bits testtry
937      if [ $? != 0 ] ; then exit 1; fi
938    else exit 1
939    fi
940    echo "  OK"
941  fi
942fi
943
944if [ $do23 = yes ] ; then
945  echo $title23
946  if [ "$bits" = "8" -o "$bits" = "32" ] ; then
947    echo "  Skipped when running 8/32-bit tests"
948  else
949    $sim $valgrind ./pcretest -q $bmode $testdata/testinput23 testtry
950    if [ $? = 0 ] ; then
951      $cf $testdata/testoutput23 testtry
952      if [ $? != 0 ] ; then exit 1; fi
953    else exit 1
954    fi
955    echo "  OK"
956  fi
957fi
958
959if [ $do24 = yes ] ; then
960  echo $title24
961  if [ "$bits" = "8" -o "$bits" = "32" ] ; then
962    echo "  Skipped when running 8/32-bit tests"
963  elif [ $utf -eq 0 ] ; then
964    echo "  Skipped because UTF-$bits support is not available"
965  else
966    $sim $valgrind ./pcretest -q $bmode $testdata/testinput24 testtry
967    if [ $? = 0 ] ; then
968      $cf $testdata/testoutput24 testtry
969      if [ $? != 0 ] ; then exit 1; fi
970    else exit 1
971    fi
972    echo "  OK"
973  fi
974fi
975
976if [ $do25 = yes ] ; then
977  echo $title25
978  if [ "$bits" = "8" -o "$bits" = "16" ] ; then
979    echo "  Skipped when running 8/16-bit tests"
980  else
981    $sim $valgrind ./pcretest -q $bmode $testdata/testinput25 testtry
982    if [ $? = 0 ] ; then
983      $cf $testdata/testoutput25 testtry
984      if [ $? != 0 ] ; then exit 1; fi
985    else exit 1
986    fi
987    echo "  OK"
988  fi
989fi
990
991if [ $do26 = yes ] ; then
992  echo $title26
993  if [ "$bits" = "8" -o "$bits" = "16" ] ; then
994    echo "  Skipped when running 8/16-bit tests"
995  elif [ $utf -eq 0 ] ; then
996    echo "  Skipped because UTF-$bits support is not available"
997  else
998    $sim $valgrind ./pcretest -q $bmode $testdata/testinput26 testtry
999    if [ $? = 0 ] ; then
1000      $cf $testdata/testoutput26 testtry
1001      if [ $? != 0 ] ; then exit 1; fi
1002    else exit 1
1003    fi
1004    echo "  OK"
1005  fi
1006fi
1007
1008# End of loop for 8/16/32-bit tests
1009done
1010
1011# Clean up local working files
1012rm -f test3input test3output test3outputA testNinput testsaved* teststderr teststdout testtry
1013
1014# End
1015