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# Whichever of the 8-bit and 16-bit libraries exist are tested. It is also
22# possible to select which to test by the arguments -8 or -16.
23
24# Other arguments for this script can be individual test numbers, or the word
25# "valgrind", or "sim" followed by an argument to run cross-compiled
26# executables under a simulator, for example:
27#
28# RunTest 3 sim "qemu-arm -s 8388608"
29#
30# Finally, if the script is obeyed as "RunTest list", a list of available
31# tests is output, but none of them are run.
32
33# Define test titles in variables so that they can be output as a list. Some
34# of them are modified (e.g. with -8 or -16) when used in the actual tests.
35
36title1="Test 1: Main functionality (Compatible with Perl >= 5.10)"
37title2="Test 2: API, errors, internals, and non-Perl stuff"
38title3="Test 3: Locale-specific features"
39title4A="Test 4: UTF"
40title4B=" support (Compatible with Perl >= 5.10)"
41title5="Test 5: API, internals, and non-Perl stuff for UTF"
42title6="Test 6: Unicode property support (Compatible with Perl >= 5.10)"
43title7="Test 7: API, internals, and non-Perl stuff for Unicode property support"
44title8="Test 8: DFA matching main functionality"
45title9="Test 9: DFA matching with UTF"
46title10="Test 10: DFA matching with Unicode properties"
47title11="Test 11: Internal offsets and code size tests"
48title12="Test 12: JIT-specific features (JIT available)"
49title13="Test 13: JIT-specific features (JIT not available)"
50title14="Test 14: Specials for the basic 8-bit library"
51title15="Test 15: Specials for the 8-bit library with UTF-8 support"
52title16="Test 16: Specials for the 8-bit library with Unicode propery support"
53title17="Test 17: Specials for the basic 16-bit library"
54title18="Test 18: Specials for the 16-bit library with UTF-16 support"
55title19="Test 19: Specials for the 16-bit library with Unicode propery support"
56title20="Test 20: DFA specials for the basic 16-bit library"
57title21="Test 21: Reloads for the basic 16-bit library"
58title22="Test 22: Reloads for the 16-bit library with UTF-16 support"
59
60if [ $# -eq 1 -a "$1" = "list" ]; then
61  echo $title1
62  echo $title2 "(not UTF)"
63  echo $title3
64  echo $title4A $title4B
65  echo $title5 support
66  echo $title6
67  echo $title7
68  echo $title8
69  echo $title9
70  echo $title10
71  echo $title11
72  echo $title12
73  echo $title13
74  echo $title14
75  echo $title15
76  echo $title16
77  echo $title17
78  echo $title18
79  echo $title19
80  echo $title20
81  echo $title21
82  echo $title22
83  exit 0
84fi
85
86# Default values
87
88valgrind=
89sim=
90arg8=
91arg16=
92
93# This is in case the caller has set aliases (as I do - PH)
94unset cp ls mv rm
95
96# Select which tests to run; for those that are explicitly requested, check
97# that the necessary optional facilities are available.
98
99do1=no
100do2=no
101do3=no
102do4=no
103do5=no
104do6=no
105do7=no
106do8=no
107do9=no
108do10=no
109do11=no
110do12=no
111do13=no
112do14=no
113do15=no
114do16=no
115do17=no
116do18=no
117do19=no
118do20=no
119do21=no
120do22=no
121
122while [ $# -gt 0 ] ; do
123  case $1 in
124    1) do1=yes;;
125    2) do2=yes;;
126    3) do3=yes;;
127    4) do4=yes;;
128    5) do5=yes;;
129    6) do6=yes;;
130    7) do7=yes;;
131    8) do8=yes;;
132    9) do9=yes;;
133   10) do10=yes;;
134   11) do11=yes;;
135   12) do12=yes;;
136   13) do13=yes;;
137   14) do14=yes;;
138   15) do15=yes;;
139   16) do16=yes;;
140   17) do17=yes;;
141   18) do18=yes;;
142   19) do19=yes;;
143   20) do20=yes;;
144   21) do21=yes;;
145   22) do22=yes;;
146   -8) arg8=yes;;
147  -16) arg16=yes;;
148   valgrind) valgrind="valgrind -q --smc-check=all";;
149   sim) shift; sim=$1;;
150    *) echo "Unknown test number '$1'"; exit 1;;
151  esac
152  shift
153done
154
155# Set up a suitable "diff" command for comparison. Some systems
156# have a diff that lacks a -u option. Try to deal with this.
157
158if diff -u /dev/null /dev/null; then cf="diff -u"; else cf="diff"; fi
159
160# Find the test data
161
162if [ -n "$srcdir" -a -d "$srcdir" ] ; then
163  testdata="$srcdir/testdata"
164elif [ -d "./testdata" ] ; then
165  testdata=./testdata
166elif [ -d "../testdata" ] ; then
167  testdata=../testdata
168else
169  echo "Cannot find the testdata directory"
170  exit 1
171fi
172
173# Find which optional facilities are available. In some Windows environments
174# the output of pcretest -C has CRLF at the end of each line, but the shell
175# strips only linefeeds from the output of a `backquoted` command. Hence the
176# alternative patterns.
177
178$sim ./pcretest -C linksize >/dev/null
179link_size=$?
180if [ $link_size -lt 2 ] ; then
181  echo "Failed to find internal link size"
182  exit 1
183fi
184if [ $link_size -gt 4 ] ; then
185  echo "Failed to find internal link size"
186  exit 1
187fi
188
189# Both 8-bit and 16-bit character strings may be supported, but only one
190# need be.
191
192$sim ./pcretest -C pcre8 >/dev/null
193support8=$?
194$sim ./pcretest -C pcre16 >/dev/null
195support16=$?
196if [ `expr $support8 + $support16` -eq 2 ] ; then
197  test8=
198  test16=-16
199  if [ "$arg8" = yes -a "$arg16" != yes ] ; then
200    test16=skip
201  fi
202  if [ "$arg16" = yes -a "$arg8" != yes ] ; then
203    test8=skip
204  fi
205else
206  if [ $support8 -ne 0 ] ; then
207    if [ "$arg16" = yes ] ; then
208      echo "Cannot run 16-bit library tests: 16-bit library not compiled"
209      exit 1
210    fi
211    test8=
212    test16=skip
213  else
214    if [ "$arg8" = yes ] ; then
215      echo "Cannot run 8-bit library tests: 8-bit library not compiled"
216      exit 1
217    fi
218    test8=skip
219    test16=-16
220  fi
221fi
222
223# UTF support always applies to both bit sizes if both are supported; we can't
224# have UTF-8 support without UTF-16 support (for example).
225
226$sim ./pcretest -C utf >/dev/null
227utf=$?
228
229$sim ./pcretest -C ucp >/dev/null
230ucp=$?
231
232jitopt=
233$sim ./pcretest -C jit >/dev/null
234jit=$?
235if [ $jit -ne 0 ] ; then
236  jitopt=-s+
237fi
238
239if [ $utf -eq 0 ] ; then
240  if [ $do4 = yes ] ; then
241    echo "Can't run test 4 because UTF support is not configured"
242    exit 1
243  fi
244  if [ $do5 = yes ] ; then
245    echo "Can't run test 5 because UTF support is not configured"
246    exit 1
247  fi
248  if [ $do9 = yes ] ; then
249    echo "Can't run test 8 because UTF support is not configured"
250    exit 1
251  fi
252  if [ $do15 = yes ] ; then
253    echo "Can't run test 15 because UTF support is not configured"
254    exit 1
255  fi
256  if [ $do18 = yes ] ; then
257    echo "Can't run test 18 because UTF support is not configured"
258  fi
259  if [ $do22 = yes ] ; then
260    echo "Can't run test 22 because UTF support is not configured"
261  fi
262fi
263
264if [ $ucp -eq 0 ] ; then
265  if [ $do6 = yes ] ; then
266    echo "Can't run test 6 because Unicode property support is not configured"
267    exit 1
268  fi
269  if [ $do7 = yes ] ; then
270    echo "Can't run test 7 because Unicode property support is not configured"
271    exit 1
272  fi
273  if [ $do10 = yes ] ; then
274    echo "Can't run test 10 because Unicode property support is not configured"
275    exit 1
276  fi
277  if [ $do16 = yes ] ; then
278    echo "Can't run test 16 because Unicode property support is not configured"
279    exit 1
280  fi
281  if [ $do19 = yes ] ; then
282    echo "Can't run test 19 because Unicode property support is not configured"
283    exit 1
284  fi
285fi
286
287if [ $link_size -ne 2 ] ; then
288  if [ $do11 = yes ] ; then
289    echo "Can't run test 11 because the link size ($link_size) is not 2"
290    exit 1
291  fi
292fi
293
294if [ $jit -eq 0 ] ; then
295  if [ $do12 = "yes" ] ; then
296    echo "Can't run test 12 because JIT support is not configured"
297    exit 1
298  fi
299else
300  if [ $do13 = "yes" ] ; then
301    echo "Can't run test 13 because JIT support is configured"
302    exit 1
303  fi
304fi
305
306# If no specific tests were requested, select all. Those that are not
307# relevant will be skipped.
308
309if [ $do1  = no -a $do2  = no -a $do3  = no -a $do4  = no -a \
310     $do5  = no -a $do6  = no -a $do7  = no -a $do8  = no -a \
311     $do9  = no -a $do10 = no -a $do11 = no -a $do12 = no -a \
312     $do13 = no -a $do14 = no -a $do15 = no -a $do16 = no -a \
313     $do17 = no -a $do18 = no -a $do19 = no -a $do20 = no -a \
314     $do21 = no -a $do22 = no ] ; then
315  do1=yes
316  do2=yes
317  do3=yes
318  do4=yes
319  do5=yes
320  do6=yes
321  do7=yes
322  do8=yes
323  do9=yes
324  do10=yes
325  do11=yes
326  do12=yes
327  do13=yes
328  do14=yes
329  do15=yes
330  do16=yes
331  do17=yes
332  do18=yes
333  do19=yes
334  do20=yes
335  do21=yes
336  do22=yes
337fi
338
339# Show which release and which test data
340
341echo ""
342echo PCRE C library tests using test data from $testdata
343$sim ./pcretest /dev/null
344
345for bmode in "$test8" "$test16"; do
346  case "$bmode" in
347    skip) continue;;
348    -16)  if [ "$test8" != "skip" ] ; then echo ""; fi
349          bits=16; echo "---- Testing 16-bit library ----"; echo "";;
350    *)    bits=8; echo "---- Testing 8-bit library ----"; echo "";;
351  esac
352
353# Primary test, compatible with JIT and all versions of Perl >= 5.8
354
355if [ $do1 = yes ] ; then
356  echo $title1
357  for opt in "" "-s" $jitopt; do
358    $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput1 testtry
359    if [ $? = 0 ] ; then
360      $cf $testdata/testoutput1 testtry
361      if [ $? != 0 ] ; then exit 1; fi
362    else exit 1
363    fi
364    if [ "$opt" = "-s" ] ; then echo "  OK with study"
365    elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
366    else echo "  OK"
367    fi
368  done
369fi
370
371# PCRE tests that are not JIT or Perl-compatible: API, errors, internals
372
373if [ $do2 = yes ] ; then
374  echo $title2 "(not UTF-$bits)"
375  for opt in "" "-s" $jitopt; do
376    $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput2 testtry
377    if [ $? = 0 ] ; then
378      $cf $testdata/testoutput2 testtry
379      if [ $? != 0 ] ; then exit 1; fi
380    else
381      echo " "
382      echo "** Test 2 requires a lot of stack. If it has crashed with a"
383      echo "** segmentation fault, it may be that you do not have enough"
384      echo "** stack available by default. Please see the 'pcrestack' man"
385      echo "** page for a discussion of PCRE's stack usage."
386      echo " "
387      exit 1
388    fi
389    if [ "$opt" = "-s" ] ; then echo "  OK with study"
390    elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
391    else echo "  OK"
392    fi
393  done
394fi
395
396# Locale-specific tests, provided that either the "fr_FR" or the "french"
397# locale is available. The former is the Unix-like standard; the latter is
398# for Windows. Another possibility is "fr", which needs to be run against
399# the Windows-specific input and output files.
400
401if [ $do3 = yes ] ; then
402  locale -a | grep '^fr_FR$' >/dev/null
403  if [ $? -eq 0 ] ; then
404    locale=fr_FR
405    infile=$testdata/testinput3
406    outfile=$testdata/testoutput3
407  else
408    infile=test3input
409    outfile=test3output
410    locale -a | grep '^french$' >/dev/null
411    if [ $? -eq 0 ] ; then
412      locale=french
413      sed 's/fr_FR/french/' $testdata/testinput3 >test3input
414      sed 's/fr_FR/french/' $testdata/testoutput3 >test3output
415    else
416      locale -a | grep '^fr$' >/dev/null
417      if [ $? -eq 0 ] ; then
418        locale=fr
419        sed 's/fr_FR/fr/' $testdata/wintestinput3 >test3input
420        sed 's/fr_FR/fr/' $testdata/wintestoutput3 >test3output
421      else
422        locale=
423      fi
424    fi
425  fi
426
427  if [ "$locale" != "" ] ; then
428    echo $title3 "(using '$locale' locale)"
429    for opt in "" "-s" $jitopt; do
430      $sim $valgrind ./pcretest -q $bmode $opt $infile testtry
431      if [ $? = 0 ] ; then
432        $cf $outfile testtry
433        if [ $? != 0 ] ; then
434          echo " "
435          echo "Locale test did not run entirely successfully."
436          echo "This usually means that there is a problem with the locale"
437          echo "settings rather than a bug in PCRE."
438          break;
439        else
440          if [ "$opt" = "-s" ] ; then echo "  OK with study"
441          elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
442          else echo "  OK"
443          fi
444        fi
445      else exit 1
446      fi
447    done
448  else
449    echo "Cannot test locale-specific features - none of the 'fr_FR', 'fr' or"
450    echo "'french' locales exist, or the \"locale\" command is not available"
451    echo "to check for them."
452    echo " "
453  fi
454fi
455
456# Additional tests for UTF support
457
458if [ $do4 = yes ] ; then
459  echo ${title4A}-${bits}${title4B}
460  if [ $utf -eq 0 ] ; then
461    echo "  Skipped because UTF-$bits support is not available"
462  else
463    for opt in "" "-s" $jitopt; do
464      $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput4 testtry
465      if [ $? = 0 ] ; then
466        $cf $testdata/testoutput4 testtry
467        if [ $? != 0 ] ; then exit 1; fi
468      else exit 1
469      fi
470      if [ "$opt" = "-s" ] ; then echo "  OK with study"
471      elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
472      else echo "  OK"
473      fi
474    done
475  fi
476fi
477
478if [ $do5 = yes ] ; then
479  echo ${title5}-${bits} support
480  if [ $utf -eq 0 ] ; then
481    echo "  Skipped because UTF-$bits support is not available"
482  else
483    for opt in "" "-s" $jitopt; do
484      $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput5 testtry
485      if [ $? = 0 ] ; then
486        $cf $testdata/testoutput5 testtry
487        if [ $? != 0 ] ; then exit 1; fi
488      else exit 1
489      fi
490      if [ "$opt" = "-s" ] ; then echo "  OK with study"
491      elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
492      else echo "  OK"
493      fi
494    done
495  fi
496fi
497
498if [ $do6 = yes ] ; then
499  echo $title6
500  if [ $utf -eq 0 -o $ucp -eq 0 ] ; then
501    echo "  Skipped because Unicode property support is not available"
502  else
503    for opt in "" "-s" $jitopt; do
504      $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput6 testtry
505      if [ $? = 0 ] ; then
506        $cf $testdata/testoutput6 testtry
507        if [ $? != 0 ] ; then exit 1; fi
508      else exit 1
509      fi
510      if [ "$opt" = "-s" ] ; then echo "  OK with study"
511      elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
512      else echo "  OK"
513      fi
514    done
515  fi
516fi
517
518# Test non-Perl-compatible Unicode property support
519
520if [ $do7 = yes ] ; then
521  echo $title7
522  if [ $utf -eq 0 -o $ucp -eq 0 ] ; then
523    echo "  Skipped because Unicode property support is not available"
524  else
525    for opt in "" "-s" $jitopt; do
526      $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput7 testtry
527      if [ $? = 0 ] ; then
528        $cf $testdata/testoutput7 testtry
529        if [ $? != 0 ] ; then exit 1; fi
530      else exit 1
531      fi
532      if [ "$opt" = "-s" ] ; then echo "  OK with study"
533      elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
534      else echo "  OK"
535      fi
536    done
537  fi
538fi
539
540# Tests for DFA matching support
541
542if [ $do8 = yes ] ; then
543  echo $title8
544  for opt in "" "-s"; do
545    $sim $valgrind ./pcretest -q $bmode $opt -dfa $testdata/testinput8 testtry
546    if [ $? = 0 ] ; then
547      $cf $testdata/testoutput8 testtry
548      if [ $? != 0 ] ; then exit 1; fi
549    else exit 1
550    fi
551    if [ "$opt" = "-s" ] ; then echo "  OK with study" ; else echo "  OK"; fi
552  done
553fi
554
555if [ $do9 = yes ] ; then
556  echo ${title9}-${bits}
557  if [ $utf -eq 0 ] ; then
558    echo "  Skipped because UTF-$bits support is not available"
559  else
560    for opt in "" "-s"; do
561      $sim $valgrind ./pcretest -q $bmode $opt -dfa $testdata/testinput9 testtry
562      if [ $? = 0 ] ; then
563        $cf $testdata/testoutput9 testtry
564        if [ $? != 0 ] ; then exit 1; fi
565      else exit 1
566      fi
567      if [ "$opt" = "-s" ] ; then echo "  OK with study" ; else echo "  OK"; fi
568    done
569  fi
570fi
571
572if [ $do10 = yes ] ; then
573  echo $title10
574  if [ $utf -eq 0 -o $ucp -eq 0 ] ; then
575    echo "  Skipped because Unicode property support is not available"
576  else
577    for opt in "" "-s"; do
578      $sim $valgrind ./pcretest -q $bmode $opt -dfa $testdata/testinput10 testtry
579      if [ $? = 0 ] ; then
580        $cf $testdata/testoutput10 testtry
581        if [ $? != 0 ] ; then exit 1; fi
582      else exit 1
583      fi
584      if [ "$opt" = "-s" ] ; then echo "  OK with study" ; else echo "  OK"; fi
585    done
586  fi
587fi
588
589# Test of internal offsets and code sizes. This test is run only when there
590# is Unicode property support and the link size is 2. The actual tests are
591# mostly the same as in some of the above, but in this test we inspect some
592# offsets and sizes that require a known link size. This is a doublecheck for
593# the maintainer, just in case something changes unexpectely. The output from
594# this test is not the same in 8-bit and 16-bit modes.
595
596if [ $do11 = yes ] ; then
597  echo $title11
598  if [ $link_size -ne 2 ] ; then
599    echo "  Skipped because link size is not 2"
600  elif [ $ucp -eq 0 ] ; then
601    echo "  Skipped because Unicode property support is not available"
602  else
603    for opt in "" "-s"; do
604      $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput11 testtry
605      if [ $? = 0 ] ; then
606        $cf $testdata/testoutput11-$bits testtry
607        if [ $? != 0 ] ; then exit 1; fi
608      else exit 1
609      fi
610      if [ "$opt" = "-s" ] ; then echo "  OK with study" ; else echo "  OK"; fi
611    done
612  fi
613fi
614
615# Test JIT-specific features when JIT is available
616
617if [ $do12 = yes ] ; then
618  echo $title12
619  if [ $jit -eq 0 ] ; then
620    echo "  Skipped because JIT is not available or not usable"
621  else
622    $sim $valgrind ./pcretest -q $bmode $testdata/testinput12 testtry
623    if [ $? = 0 ] ; then
624      $cf $testdata/testoutput12 testtry
625      if [ $? != 0 ] ; then exit 1; fi
626    else exit 1
627    fi
628    echo "  OK"
629  fi
630fi
631
632# Test JIT-specific features when JIT is not available
633
634if [ $do13 = yes ] ; then
635  echo $title13
636  if [ $jit -ne 0 ] ; then
637    echo "  Skipped because JIT is available"
638  else
639    $sim $valgrind ./pcretest -q $bmode $testdata/testinput13 testtry
640    if [ $? = 0 ] ; then
641      $cf $testdata/testoutput13 testtry
642      if [ $? != 0 ] ; then exit 1; fi
643    else exit 1
644    fi
645    echo "  OK"
646  fi
647fi
648
649# Tests for 8-bit-specific features
650
651if [ "$do14" = yes ] ; then
652  echo $title14
653  if [ "$bits" = "16" ] ; then
654    echo "  Skipped when running 16-bit tests"
655  else
656    cp -f $testdata/saved16 testsaved16
657    for opt in "" "-s" $jitopt; do
658      $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput14 testtry
659      if [ $? = 0 ] ; then
660        $cf $testdata/testoutput14 testtry
661        if [ $? != 0 ] ; then exit 1; fi
662      else exit 1
663      fi
664      if [ "$opt" = "-s" ] ; then echo "  OK with study"
665      elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
666      else echo "  OK"
667      fi
668    done
669  fi
670fi
671
672# Tests for 8-bit-specific features (needs UTF-8 support)
673
674if [ "$do15" = yes ] ; then
675  echo $title15
676  if [ "$bits" = "16" ] ; then
677    echo "  Skipped when running 16-bit tests"
678  elif [ $utf -eq 0 ] ; then
679    echo "  Skipped because UTF-$bits support is not available"
680  else
681    for opt in "" "-s" $jitopt; do
682      $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput15 testtry
683      if [ $? = 0 ] ; then
684        $cf $testdata/testoutput15 testtry
685        if [ $? != 0 ] ; then exit 1; fi
686      else exit 1
687      fi
688      if [ "$opt" = "-s" ] ; then echo "  OK with study"
689      elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
690      else echo "  OK"
691      fi
692    done
693  fi
694fi
695
696# Tests for 8-bit-specific features (Unicode property support)
697
698if [ $do16 = yes ] ; then
699  echo $title16
700  if [ "$bits" = "16" ] ; then
701    echo "  Skipped when running 16-bit tests"
702  elif [ $ucp -eq 0 ] ; then
703    echo "  Skipped because Unicode property support is not available"
704  else
705    for opt in "" "-s" $jitopt; do
706      $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput16 testtry
707      if [ $? = 0 ] ; then
708        $cf $testdata/testoutput16 testtry
709        if [ $? != 0 ] ; then exit 1; fi
710      else exit 1
711      fi
712      if [ "$opt" = "-s" ] ; then echo "  OK with study"
713      elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
714      else echo "  OK"
715      fi
716    done
717  fi
718fi
719
720# Tests for 16-bit-specific features
721
722if [ $do17 = yes ] ; then
723  echo $title17
724  if [ "$bits" = "8" ] ; then
725    echo "  Skipped when running 8-bit tests"
726  else
727    for opt in "" "-s" $jitopt; do
728      $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput17 testtry
729      if [ $? = 0 ] ; then
730        $cf $testdata/testoutput17 testtry
731        if [ $? != 0 ] ; then exit 1; fi
732      else exit 1
733      fi
734      if [ "$opt" = "-s" ] ; then echo "  OK with study"
735      elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
736      else echo "  OK"
737      fi
738    done
739  fi
740fi
741
742# Tests for 16-bit-specific features (UTF-16 support)
743
744if [ $do18 = yes ] ; then
745  echo $title18
746  if [ "$bits" = "8" ] ; then
747    echo "  Skipped when running 8-bit tests"
748  elif [ $utf -eq 0 ] ; then
749    echo "  Skipped because UTF-$bits support is not available"
750  else
751    for opt in "" "-s" $jitopt; do
752      $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput18 testtry
753      if [ $? = 0 ] ; then
754        $cf $testdata/testoutput18 testtry
755        if [ $? != 0 ] ; then exit 1; fi
756      else exit 1
757      fi
758      if [ "$opt" = "-s" ] ; then echo "  OK with study"
759      elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
760      else echo "  OK"
761      fi
762    done
763  fi
764fi
765
766# Tests for 16-bit-specific features (Unicode property support)
767
768if [ $do19 = yes ] ; then
769  echo $title19
770  if [ "$bits" = "8" ] ; then
771    echo "  Skipped when running 8-bit tests"
772  elif [ $ucp -eq 0 ] ; then
773    echo "  Skipped because Unicode property support is not available"
774  else
775    for opt in "" "-s" $jitopt; do
776      $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput19 testtry
777      if [ $? = 0 ] ; then
778        $cf $testdata/testoutput19 testtry
779        if [ $? != 0 ] ; then exit 1; fi
780      else exit 1
781      fi
782      if [ "$opt" = "-s" ] ; then echo "  OK with study"
783      elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
784      else echo "  OK"
785      fi
786    done
787  fi
788fi
789
790# Tests for 16-bit-specific features in DFA non-UTF-16 mode
791
792if [ $do20 = yes ] ; then
793  echo $title20
794  if [ "$bits" = "8" ] ; then
795    echo "  Skipped when running 8-bit tests"
796  else
797    for opt in "" "-s"; do
798      $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput20 testtry
799      if [ $? = 0 ] ; then
800        $cf $testdata/testoutput20 testtry
801        if [ $? != 0 ] ; then exit 1; fi
802      else exit 1
803      fi
804      if [ "$opt" = "-s" ] ; then echo "  OK with study"
805      else echo "  OK"
806      fi
807    done
808  fi
809fi
810
811# Tests for reloads with 16-bit library
812
813if [ $do21 = yes ] ; then
814  echo $title21
815  if [ "$bits" = "8" ] ; then
816    echo "  Skipped when running 8-bit tests"
817  elif [ $link_size -ne 2 ] ; then
818    echo "  Skipped because link size is not 2"
819  else
820    cp -f $testdata/saved8 testsaved8
821    cp -f $testdata/saved16LE-1 testsaved16LE-1
822    cp -f $testdata/saved16BE-1 testsaved16BE-1
823    $sim $valgrind ./pcretest -q $bmode $testdata/testinput21 testtry
824    if [ $? = 0 ] ; then
825      $cf $testdata/testoutput21 testtry
826      if [ $? != 0 ] ; then exit 1; fi
827    else exit 1
828    fi
829    echo "  OK"
830  fi
831fi
832
833# Tests for reloads with 16-bit library (UTF-16 support)
834
835if [ $do22 = yes ] ; then
836  echo $title22
837  if [ "$bits" = "8" ] ; then
838    echo "  Skipped when running 8-bit tests"
839  elif [ $utf -eq 0 ] ; then
840    echo "  Skipped because UTF-$bits support is not available"
841  elif [ $link_size -ne 2 ] ; then
842    echo "  Skipped because link size is not 2"
843  else
844    cp -f $testdata/saved16LE-2 testsaved16LE-2
845    cp -f $testdata/saved16BE-2 testsaved16BE-2
846    $sim $valgrind ./pcretest -q $bmode $testdata/testinput22 testtry
847    if [ $? = 0 ] ; then
848      $cf $testdata/testoutput22 testtry
849      if [ $? != 0 ] ; then exit 1; fi
850    else exit 1
851    fi
852    echo "  OK"
853  fi
854fi
855
856# End of loop for 8-bit/16-bit tests
857done
858
859# Clean up local working files
860rm -f test3input test3output testNinput testsaved* teststderr teststdout testtry
861
862# End
863