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