153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis#! /bin/sh
253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis###############################################################################
453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# Run the PCRE2 tests using the pcre2test program. The appropriate tests are
553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# selected, depending on which build-time options were used.
653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis#
753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# When JIT support is available, all appropriate tests are run with and without
853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# JIT, unless "-nojit" is given on the command line. There are also two tests
953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# for JIT-specific features, one to be run when JIT support is available
1053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# (unless "-nojit" is specified), and one when it is not.
1153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis#
1253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# Whichever of the 8-, 16- and 32-bit libraries exist are tested. It is also
1353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# possible to select which to test by giving "-8", "-16" or "-32" on the
1453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# command line.
1553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis#
1653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# As well as "-nojit", "-8", "-16", and "-32", arguments for this script are
1753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# individual test numbers, ranges of tests such as 3-6 or 3- (meaning 3 to the
1853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# end), or a number preceded by ~ to exclude a test. For example, "3-15 ~10"
1953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# runs tests 3 to 15, excluding test 10, and just "~10" runs all the tests
2053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# except test 10. Whatever order the arguments are in, the tests are always run
2153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# in numerical order.
2253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis#
2353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# Inappropriate tests are automatically skipped (with a comment to say so). For
2453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# example, if JIT support is not compiled, test 16 is skipped, whereas if JIT
2553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# support is compiled, test 15 is skipped.
2653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis#
2753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# Other arguments can be one of the words "-valgrind", "-valgrind-log", or
2853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# "-sim" followed by an argument to run cross-compiled executables under a
2953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# simulator, for example:
3053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis#
3153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# RunTest 3 -sim "qemu-arm -s 8388608"
3253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis#
3353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# For backwards compatibility, -nojit, -valgrind, -valgrind-log, and -sim may
3453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# be given without the leading "-" character.
3553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis#
3653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# When PCRE2 is compiled by clang with -fsanitize arguments, some tests need
3753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# very much more stack than normal. In environments where the stack can be
3853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# set at runtime, -bigstack sets a gigantic stack.
3953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis#
4053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# There are two special cases where only one argument is allowed:
4153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis#
4253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# If the first and only argument is "ebcdic", the script runs the special
4353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# EBCDIC test that can be useful for checking certain EBCDIC features, even
4453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# when run in an ASCII environment. PCRE2 must be built with EBCDIC support for
4553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# this test to be run.
4653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis#
4753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# If the script is obeyed as "RunTest list", a list of available tests is
4853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# output, but none of them are run.
4953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis###############################################################################
5053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
5153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# Define test titles in variables so that they can be output as a list. Some
5253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# of them are modified (e.g. with -8 or -16) when used in the actual tests.
5353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
5453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistitle0="Test 0: Unchecked pcre2test argument tests (to improve coverage)"
5553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistitle1="Test 1: Main non-UTF, non-UCP functionality (compatible with Perl >= 5.10)"
568b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskistitle2="Test 2: API, errors, internals and non-Perl stuff"
5753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistitle3="Test 3: Locale-specific features"
5853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistitle4A="Test 4: UTF"
5953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistitle4B=" and Unicode property support (compatible with Perl >= 5.10)"
6053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistitle5A="Test 5: API, internals, and non-Perl stuff for UTF"
6153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistitle5B=" and UCP support"
6253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistitle6="Test 6: DFA matching main non-UTF, non-UCP functionality"
6353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistitle7A="Test 7: DFA matching with UTF"
6453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistitle7B=" and Unicode property support"
6553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistitle8="Test 8: Internal offsets and code size tests"
6653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistitle9="Test 9: Specials for the basic 8-bit library"
6753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistitle10="Test 10: Specials for the 8-bit library with UTF-8 and UCP support"
6853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistitle11="Test 11: Specials for the basic 16-bit and 32-bit libraries"
6953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistitle12="Test 12: Specials for the 16-bit and 32-bit libraries UTF and UCP support"
7053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistitle13="Test 13: DFA specials for the basic 16-bit and 32-bit libraries"
7153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistitle14="Test 14: DFA specials for UTF and UCP support"
7253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistitle15="Test 15: Non-JIT limits and other non-JIT tests"
7353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistitle16="Test 16: JIT-specific features when JIT is not available"
7453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistitle17="Test 17: JIT-specific features when JIT is available"
7553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistitle18="Test 18: Tests of the POSIX interface, excluding UTF/UCP"
7653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistitle19="Test 19: Tests of the POSIX interface with UTF/UCP"
778b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskistitle20="Test 20: Serialization and code copy tests"
7853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistitle21="Test 21: \C tests without UTF (supported for DFA matching)"
7953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistitle22="Test 22: \C tests with UTF (not supported for DFA matching)"
8053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistitle23="Test 23: \C disabled test"
8153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskismaxtest=23
8253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
8353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisif [ $# -eq 1 -a "$1" = "list" ]; then
8453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo $title0
8553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo $title1
8653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo $title2 "(not UTF or UCP)"
8753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo $title3
8853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo $title4A $title4B
8953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo $title5A $title5B
9053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo $title6
9153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo $title7A $title7B
9253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo $title8
9353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo $title9
9453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo $title10
9553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo $title11
9653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo $title12
9753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo $title13
9853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo $title14
9953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo $title15
10053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo $title16
10153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo $title17
10253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo $title18
10353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo $title19
10453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo $title20
10553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo $title21
10653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo $title22
10753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo $title23
10853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  exit 0
10953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisfi
11053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
11153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# Set up a suitable "diff" command for comparison. Some systems
11253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# have a diff that lacks a -u option. Try to deal with this.
11353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
11453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskiscf="diff"
11553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdiff -u /dev/null /dev/null 2>/dev/null && cf="diff -u"
11653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
11753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# Find the test data
11853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
11953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisif [ -n "$srcdir" -a -d "$srcdir" ] ; then
12053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  testdata="$srcdir/testdata"
12153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskiselif [ -d "./testdata" ] ; then
12253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  testdata=./testdata
12353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskiselif [ -d "../testdata" ] ; then
12453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  testdata=../testdata
12553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskiselse
12653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo "Cannot find the testdata directory"
12753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  exit 1
12853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisfi
12953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
13053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
13153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# ------ Function to check results of a test -------
13253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
13353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# This function is called with three parameters:
13453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis#
13553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis#  $1 the value of $? after a call to pcre2test
13653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis#  $2 the suffix of the output file to compare with
13753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis#  $3 the $opt value (empty, -jit, or -dfa)
13853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis#
13953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# Note: must define using name(), not "function name", for Solaris.
14053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
14153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskischeckresult()
14253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  {
14353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ $1 -ne 0 ] ; then
14453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo "** pcre2test failed - check testtry"
14553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    exit 1
14653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
14753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  case "$3" in
14853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    -jit) with=" with JIT";;
14953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    -dfa) with=" with DFA";;
15053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    *)    with="";;
15153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  esac
15253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  $cf $testdata/testoutput$2 testtry
15353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ $? != 0 ] ; then
15453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo ""
15553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo "** Test $2 failed$with"
15653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    exit 1
15753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
15853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo "  OK$with"
15953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  }
16053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
16153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
16253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# ------ Function to run and check a special pcre2test arguments test -------
16353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
16453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskischeckspecial()
16553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  {
16653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  $valgrind  $vjs ./pcre2test $1 >>testtry
16753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ $? -ne 0 ] ; then
16853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo "** pcre2test $1 failed - check testtry"
16953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    exit 1
17053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
17153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  }
17253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
17353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
17453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# ------ Special EBCDIC Test -------
17553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
17653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisif [ $# -eq 1 -a "$1" = "ebcdic" ]; then
17753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  $valgrind ./pcre2test -C ebcdic >/dev/null
17853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  ebcdic=$?
17953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ $ebcdic -ne 1 ] ; then
18053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo "Cannot run EBCDIC tests: EBCDIC support not compiled"
18153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    exit 1
18253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
18353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  for opt in "" "-dfa"; do
18453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    ./pcre2test -q $opt $testdata/testinputEBC >testtry
18553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    checkresult $? EBC "$opt"
18653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  done
18753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisexit 0
18853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisfi
18953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
19053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
19153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# ------ Normal Tests ------
19253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
19353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# Default values
19453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
19553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisarg8=
19653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisarg16=
19753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisarg32=
19853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisnojit=
19953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisbigstack=
20053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskissim=
20153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisskip=
20253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisvalgrind=
20353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisvjs=
20453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
20553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# This is in case the caller has set aliases (as I do - PH)
20653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisunset cp ls mv rm
20753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
20853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# Process options and select which tests to run; for those that are explicitly
20953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# requested, check that the necessary optional facilities are available.
21053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
21153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdo0=no
21253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdo1=no
21353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdo2=no
21453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdo3=no
21553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdo4=no
21653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdo5=no
21753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdo6=no
21853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdo7=no
21953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdo8=no
22053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdo9=no
22153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdo10=no
22253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdo11=no
22353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdo12=no
22453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdo13=no
22553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdo14=no
22653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdo15=no
22753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdo16=no
22853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdo17=no
22953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdo18=no
23053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdo19=no
23153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdo20=no
23253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdo21=no
23353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdo22=no
23453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdo23=no
23553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
23653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskiswhile [ $# -gt 0 ] ; do
23753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  case $1 in
23853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    0) do0=yes;;
23953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    1) do1=yes;;
24053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    2) do2=yes;;
24153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    3) do3=yes;;
24253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    4) do4=yes;;
24353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    5) do5=yes;;
24453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    6) do6=yes;;
24553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    7) do7=yes;;
24653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    8) do8=yes;;
24753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    9) do9=yes;;
24853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis   10) do10=yes;;
24953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis   11) do11=yes;;
25053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis   12) do12=yes;;
25153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis   13) do13=yes;;
25253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis   14) do14=yes;;
25353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis   15) do15=yes;;
25453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis   16) do16=yes;;
25553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis   17) do17=yes;;
25653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis   18) do18=yes;;
25753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis   19) do19=yes;;
25853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis   20) do20=yes;;
25953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis   21) do21=yes;;
26053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis   22) do22=yes;;
26153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis   23) do23=yes;;
26253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis   -8) arg8=yes;;
26353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  -16) arg16=yes;;
26453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  -32) arg32=yes;;
26553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis   bigstack|-bigstack) bigstack=yes;;
26653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis   nojit|-nojit) nojit=yes;;
26753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis   sim|-sim) shift; sim=$1;;
2688b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis   valgrind|-valgrind) valgrind="valgrind --tool=memcheck -q --smc-check=all-non-file";;
2698b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis   valgrind-log|-valgrind-log) valgrind="valgrind --tool=memcheck --num-callers=30 --leak-check=no --error-limit=no --smc-check=all-non-file --log-file=report.%p ";;
27053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis   ~*)
27153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis     if expr "$1" : '~[0-9][0-9]*$' >/dev/null; then
27253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis       skip="$skip `expr "$1" : '~\([0-9]*\)*$'`"
27353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis     else
27453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis       echo "Unknown option or test selector '$1'"; exit 1
27553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis     fi
27653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis   ;;
27753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis   *-*)
27853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis     if expr "$1" : '[0-9][0-9]*-[0-9]*$' >/dev/null; then
27953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis       tf=`expr "$1" : '\([0-9]*\)'`
28053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis       tt=`expr "$1" : '.*-\([0-9]*\)'`
28153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis       if [ "$tt" = "" ] ; then tt=$maxtest; fi
28253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis       if expr \( "$tt" ">" "$maxtest" \) >/dev/null; then
28353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis         echo "Invalid test range '$1'"; exit 1
28453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis       fi
28553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis       while expr "$tf" "<=" "$tt" >/dev/null; do
28653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis         eval do${tf}=yes
28753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis         tf=`expr $tf + 1`
28853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis       done
28953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis     else
29053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis       echo "Invalid test range '$1'"; exit 1
29153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis     fi
29253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis   ;;
29353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis   *) echo "Unknown option or test selector '$1'"; exit 1;;
29453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  esac
29553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  shift
29653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdone
29753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
29853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# Find which optional facilities are available.
29953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
30053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis$sim ./pcre2test -C linksize >/dev/null
30153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskislink_size=$?
30253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisif [ $link_size -lt 2 ] ; then
30353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo "RunTest: Failed to find internal link size"
30453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  exit 1
30553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisfi
30653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisif [ $link_size -gt 4 ] ; then
30753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  echo "RunTest: Failed to find internal link size"
30853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  exit 1
30953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisfi
31053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
31153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# If it is possible to set the system stack size, arrange to set a value for
31253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# test 2, which needs more than the even the Linux default when PCRE2 has been
3138b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis# compiled by gcc with -fsanitize=address. If "bigstack" is on the command
3148b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis# line, set even bigger numbers. When the compiler is clang, sanitize options
3158b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis# require an even bigger stack for test 2, and an increased stack for some of
3168b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis# the other tests. Test 2 now has code to automatically try again with a 64M
3178b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis# stack if it crashes when test2stack is "-S 16" when matching with the
3188b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis# interpreter.
31953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
32053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis$sim ./pcre2test -S 1 /dev/null /dev/null
32153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisif [ $? -eq 0 ] ; then
32253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ "$bigstack" = "" ] ; then
32353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    test2stack="-S 16"
32453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    defaultstack=""
32553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  else
32653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    test2stack="-S 1024"
32753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    defaultstack="-S 64"
32853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
32953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskiselse
33053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  test2stack=""
33153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  defaultstack=""
33253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisfi
33353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
33453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# All of 8-bit, 16-bit, and 32-bit character strings may be supported, but only
33553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# one need be.
33653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
33753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis$sim ./pcre2test -C pcre2-8 >/dev/null
33853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskissupport8=$?
33953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis$sim ./pcre2test -C pcre2-16 >/dev/null
34053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskissupport16=$?
34153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis$sim ./pcre2test -C pcre2-32 >/dev/null
34253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskissupport32=$?
34353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
34453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# \C may be disabled
34553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
34653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis$sim ./pcre2test -C backslash-C >/dev/null
34753e448c1797913dbc12dbacc341559934566d6bcJanis DanisevskissupportBSC=$?
34853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
34953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# Initialize all bitsizes skipped
35053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
35153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistest8=skip
35253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistest16=skip
35353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskistest32=skip
35453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
35553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# If no bitsize arguments, select all that are available
35653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
35753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisif [ "$arg8$arg16$arg32" = "" ] ; then
35853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ $support8 -ne 0 ] ; then
35953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    test8=-8
36053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
36153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ $support16 -ne 0 ] ; then
36253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    test16=-16
36353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
36453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ $support32 -ne 0 ] ; then
36553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    test32=-32
36653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
36753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
36853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# Otherwise, select requested bit sizes
36953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
37053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskiselse
37153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ "$arg8" = yes ] ; then
37253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    if [ $support8 -eq 0 ] ; then
37353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "Cannot run 8-bit library tests: 8-bit library not compiled"
37453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      exit 1
37553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    fi
37653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    test8=-8
37753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
37853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ "$arg16" = yes ] ; then
37953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    if [ $support16 -eq 0 ] ; then
38053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "Cannot run 16-bit library tests: 16-bit library not compiled"
38153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      exit 1
38253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    fi
38353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    test16=-16
38453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
38553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ "$arg32" = yes ] ; then
38653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    if [ $support32 -eq 0 ] ; then
38753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "Cannot run 32-bit library tests: 32-bit library not compiled"
38853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      exit 1
38953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    fi
39053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    test32=-32
39153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
39253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisfi
39353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
39453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# UTF support is implied by Unicode support, and it always applies to all bit
39553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# sizes if both are supported; we can't have UTF-8 support without UTF-16 or
39653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# UTF-32 support.
39753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
39853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis$sim ./pcre2test -C unicode >/dev/null
39953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisutf=$?
40053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
40153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# When JIT is used with valgrind, we need to set up valgrind suppressions as
40253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# otherwise there are a lot of false positive valgrind reports when the
40353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# the hardware supports SSE2.
40453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
40553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisjitopt=
40653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis$sim ./pcre2test -C jit >/dev/null
40753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisjit=$?
40853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisif [ $jit -ne 0 -a "$nojit" != "yes" ] ; then
40953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  jitopt=-jit
41053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ "$valgrind" != "" ] ; then
41153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    vjs="--suppressions=$testdata/valgrind-jit.supp"
41253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
41353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisfi
41453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
41553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# If no specific tests were requested, select all. Those that are not
41653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# relevant will be automatically skipped.
41753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
41853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisif [ $do0  = no -a $do1  = no -a $do2  = no -a $do3  = no -a \
41953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis     $do4  = no -a $do5  = no -a $do6  = no -a $do7  = no -a \
42053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis     $do8  = no -a $do9  = no -a $do10 = no -a $do11 = no -a \
42153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis     $do12 = no -a $do13 = no -a $do14 = no -a $do15 = no -a \
42253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis     $do16 = no -a $do17 = no -a $do18 = no -a $do19 = no -a \
42353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis     $do20 = no -a $do21 = no -a $do22 = no -a $do23 = no \
42453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis   ]; then
42553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  do0=yes
42653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  do1=yes
42753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  do2=yes
42853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  do3=yes
42953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  do4=yes
43053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  do5=yes
43153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  do6=yes
43253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  do7=yes
43353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  do8=yes
43453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  do9=yes
43553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  do10=yes
43653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  do11=yes
43753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  do12=yes
43853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  do13=yes
43953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  do14=yes
44053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  do15=yes
44153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  do16=yes
44253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  do17=yes
44353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  do18=yes
44453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  do19=yes
44553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  do20=yes
44653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  do21=yes
44753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  do22=yes
44853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  do23=yes
44953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisfi
45053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
45153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# Handle any explicit skips at this stage, so that an argument list may consist
45253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# only of explicit skips.
45353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
45453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisfor i in $skip; do eval do$i=no; done
45553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
45653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# Show which release and which test data
45753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
45853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisecho ""
45953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisecho PCRE2 C library tests using test data from $testdata
46053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis$sim ./pcre2test /dev/null
46153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisecho ""
46253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
46353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisfor bmode in "$test8" "$test16" "$test32"; do
46453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  case "$bmode" in
46553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    skip) continue;;
46653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    -16)  if [ "$test8$test32" != "skipskip" ] ; then echo ""; fi
46753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis          bits=16; echo "---- Testing 16-bit library ----"; echo "";;
46853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    -32)  if [ "$test8$test16" != "skipskip" ] ; then echo ""; fi
46953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis          bits=32; echo "---- Testing 32-bit library ----"; echo "";;
47053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    -8)   bits=8; echo "---- Testing 8-bit library ----"; echo "";;
47153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  esac
47253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
47353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # Test 0 is a special test. Its output is not checked, because it will
47453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # be different on different hardware and with different configurations.
47553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # Running this test just exercises the code.
47653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
47753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ $do0 = yes ] ; then
47853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo $title0
47953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo '/abc/jit,memory' >testSinput
48053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo '   abc' >>testSinput
48153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo '' >testtry
48253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    checkspecial '-C'
48353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    checkspecial '--help'
48453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    checkspecial '-S 1 -t 10 testSinput'
48553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo "  OK"
48653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
48753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
48853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # Primary non-UTF test, compatible with JIT and all versions of Perl >= 5.8
48953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
49053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ $do1 = yes ] ; then
49153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo $title1
49253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    for opt in "" $jitopt; do
49353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      $sim $valgrind ${opt:+$vjs} ./pcre2test -q $defaultstack $bmode $opt $testdata/testinput1 testtry
49453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      checkresult $? 1 "$opt"
49553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    done
49653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
49753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
49853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # PCRE2 tests that are not Perl-compatible: API, errors, internals
49953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
50053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ $do2 = yes ] ; then
50153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo $title2 "(excluding UTF-$bits)"
50253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    for opt in "" $jitopt; do
50353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      $sim $valgrind ${opt:+$vjs} ./pcre2test -q $test2stack $bmode $opt $testdata/testinput2 testtry
50453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      if [ $? = 0 ] ; then
5058b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis        $sim $valgrind ${opt:+$vjs} ./pcre2test -q $bmode $opt -error -63,-62,-2,-1,0,100,188,189 >>testtry
50653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis        checkresult $? 2 "$opt"
50753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      else
50853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis        echo " "
5098b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis        echo "** Test 2, when run under the interpreter, requires a lot of stack."
5108b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis        echo "** If it has crashed with a segmentation fault, it may be that you"
5118b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis        echo "** do not have enough stack available by default. Please see the"
5128b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis        echo "** 'pcre2stack' man page for a discussion of PCRE2's stack usage."
5138b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis        if [ "$test2stack" != "-S 16" -o "$opt" != "" ]; then
5148b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis          echo " "
5158b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis          exit 1
5168b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis        fi
51753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis        echo " "
5188b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis        echo "** Trying again with an increased stack size."
5198b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis        echo " "
5208b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis        echo $title2 "(excluding UTF-$bits) (64M stack)"
5218b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis        $sim $valgrind ${opt:+$vjs} ./pcre2test -q -S 64 $bmode $opt $testdata/testinput2 testtry
5228b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis        if [ $? = 0 ] ; then
5238b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis          $sim $valgrind ${opt:+$vjs} ./pcre2test -q $bmode $opt -error -63,-62,-2,-1,0,100,188,189 >>testtry
5248b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis          checkresult $? 2 "$opt"
5258b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis        else
5268b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis          echo " "
5278b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis          echo "** Failed with an increased stack size. Tests abandoned."
5288b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis          echo " "
5298b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis          exit 1
5308b979b2abae173bb836d8e85a842cfd00447d4beJanis Danisevskis        fi
53153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      fi
53253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    done
53353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
53453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
53553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # Locale-specific tests, provided that either the "fr_FR", "fr_CA", "french"
53653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # or "fr" locale is available. The first two are Unix-like standards; the
53753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # last two are for Windows. Unfortunately, different versions of the French
53853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # locale give different outputs for some items. This test passes if the
53953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # output matches any one of the alternative output files.
54053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
54153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ $do3 = yes ] ; then
54253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    locale=
54353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
54453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    # In some environments locales that are listed by the "locale -a"
54553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    # command do not seem to work with setlocale(). Therefore, we do
54653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    # a preliminary test to see if pcre2test can set one before going
54753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    # on to use it.
54853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
54953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    for loc in 'fr_FR' 'french' 'fr' 'fr_CA'; do
55053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      locale -a | grep "^$loc\$" >/dev/null
55153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      if [ $? -eq 0 ] ; then
55253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis        echo "/a/locale=$loc" | \
55353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis          $sim $valgrind ./pcre2test -q $bmode | \
55453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis            grep "Failed to set locale" >/dev/null
55553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis        if [ $? -ne 0 ] ; then
55653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis          locale=$loc
55753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis          if [ "$locale" = "fr_FR" ] ; then
55853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis            infile=$testdata/testinput3
55953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis            outfile=$testdata/testoutput3
56053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis            outfile2=$testdata/testoutput3A
56153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis            outfile3=$testdata/testoutput3B
56253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis          else
56353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis            infile=test3input
56453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis            outfile=test3output
56553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis            outfile2=test3outputA
56653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis            outfile3=test3outputB
56753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis            sed "s/fr_FR/$loc/" $testdata/testinput3 >test3input
56853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis            sed "s/fr_FR/$loc/" $testdata/testoutput3 >test3output
56953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis            sed "s/fr_FR/$loc/" $testdata/testoutput3A >test3outputA
57053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis            sed "s/fr_FR/$loc/" $testdata/testoutput3B >test3outputB
57153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis          fi
57253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis          break
57353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis        fi
57453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      fi
57553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    done
57653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
57753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    if [ "$locale" != "" ] ; then
57853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo $title3 "(using '$locale' locale)"
57953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      for opt in "" $jitopt; do
58053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis        $sim $valgrind ${opt:+$vjs} ./pcre2test -q $defaultstack $bmode $opt $infile testtry
58153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis        if [ $? = 0 ] ; then
58253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis          case "$opt" in
58353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis            -jit) with=" with JIT";;
58453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis            *)    with="";;
58553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis          esac
58653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis          if $cf $outfile testtry >teststdout || \
58753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis             $cf $outfile2 testtry >teststdout || \
58853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis             $cf $outfile3 testtry >teststdout
58953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis          then
59053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis            echo "  OK$with"
59153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis          else
59253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis            echo "** Locale test did not run successfully$with. The output did not match"
59353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis            echo "   $outfile, $outfile2 or $outfile3."
59453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis            echo "   This may mean that there is a problem with the locale settings rather"
59553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis            echo "   than a bug in PCRE2."
59653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis            exit 1
59753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis          fi
59853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis        else exit 1
59953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis        fi
60053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      done
60153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    else
60253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "Cannot test locale-specific features - none of the 'fr_FR', 'fr_CA',"
60353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "'fr' or 'french' locales can be set, or the \"locale\" command is"
60453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "not available to check for them."
60553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo " "
60653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    fi
60753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
60853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
60953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # Tests for UTF and Unicode property support
61053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
61153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ $do4 = yes ] ; then
61253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo ${title4A}-${bits}${title4B}
61353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    if [ $utf -eq 0 ] ; then
61453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "  Skipped because UTF-$bits support is not available"
61553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    else
61653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      for opt in "" $jitopt; do
61753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis        $sim $valgrind ${opt:+$vjs} ./pcre2test -q $defaultstack $bmode $opt $testdata/testinput4 testtry
61853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis        checkresult $? 4 "$opt"
61953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      done
62053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    fi
62153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
62253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
62353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ $do5 = yes ] ; then
62453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo ${title5A}-${bits}$title5B
62553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    if [ $utf -eq 0 ] ; then
62653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "  Skipped because UTF-$bits support is not available"
62753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    else
62853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      for opt in "" $jitopt; do
62953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis        $sim $valgrind ${opt:+$vjs} ./pcre2test -q $defaultstack $bmode $opt $testdata/testinput5 testtry
63053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis        checkresult $? 5 "$opt"
63153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      done
63253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    fi
63353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
63453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
63553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # Tests for DFA matching support
63653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
63753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ $do6 = yes ] ; then
63853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo $title6
63953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    $sim $valgrind ./pcre2test -q $defaultstack $bmode $testdata/testinput6 testtry
64053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    checkresult $? 6 ""
64153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
64253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
64353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ $do7 = yes ] ; then
64453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo ${title7A}-${bits}$title7B
64553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    if [ $utf -eq 0 ] ; then
64653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "  Skipped because UTF-$bits support is not available"
64753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    else
64853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      $sim $valgrind ./pcre2test -q $defaultstack $bmode $opt $testdata/testinput7 testtry
64953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      checkresult $? 7 ""
65053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    fi
65153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
65253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
65353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # Test of internal offsets and code sizes. This test is run only when there
65453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # is UTF/UCP support. The actual tests are mostly the same as in some of the
65553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # above, but in this test we inspect some offsets and sizes. This is a
65653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # doublecheck for the maintainer, just in case something changes unexpectely.
65753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # The output from this test is different in 8-bit, 16-bit, and 32-bit modes
65853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # and for different link sizes, so there are different output files for each
65953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # mode and link size.
66053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
66153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ $do8 = yes ] ; then
66253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo $title8
66353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    if [ $utf -eq 0 ] ; then
66453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "  Skipped because UTF-$bits support is not available"
66553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    else
66653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      $sim $valgrind ./pcre2test -q $defaultstack $bmode $testdata/testinput8 testtry
66753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      checkresult $? 8-$bits-$link_size ""
66853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    fi
66953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
67053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
67153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # Tests for 8-bit-specific features
67253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
67353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ "$do9" = yes ] ; then
67453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo $title9
67553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    if [ "$bits" = "16" -o "$bits" = "32" ] ; then
67653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "  Skipped when running 16/32-bit tests"
67753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    else
67853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      for opt in "" $jitopt; do
67953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis        $sim $valgrind ${opt:+$vjs} ./pcre2test -q $defaultstack $bmode $opt $testdata/testinput9 testtry
68053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis        checkresult $? 9 "$opt"
68153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      done
68253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    fi
68353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
68453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
68553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # Tests for UTF-8 and UCP 8-bit-specific features
68653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
68753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ "$do10" = yes ] ; then
68853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo $title10
68953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    if [ "$bits" = "16" -o "$bits" = "32" ] ; then
69053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "  Skipped when running 16/32-bit tests"
69153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    elif [ $utf -eq 0 ] ; then
69253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "  Skipped because UTF-$bits support is not available"
69353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    else
69453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      for opt in "" $jitopt; do
69553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis        $sim $valgrind ${opt:+$vjs} ./pcre2test -q $defaultstack $bmode $opt $testdata/testinput10 testtry
69653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis        checkresult $? 10 "$opt"
69753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      done
69853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    fi
69953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
70053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
70153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # Tests for 16-bit and 32-bit features. Output is different for the two widths.
70253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
70353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ $do11 = yes ] ; then
70453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo $title11
70553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    if [ "$bits" = "8" ] ; then
70653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "  Skipped when running 8-bit tests"
70753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    else
70853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      for opt in "" $jitopt; do
70953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis        $sim $valgrind ${opt:+$vjs} ./pcre2test -q $defaultstack $bmode $opt $testdata/testinput11 testtry
71053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis        checkresult $? 11-$bits "$opt"
71153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      done
71253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    fi
71353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
71453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
71553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # Tests for 16-bit and 32-bit features with UTF-16/32 and UCP support. Output
71653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # is different for the two widths.
71753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
71853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ $do12 = yes ] ; then
71953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo $title12
72053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    if [ "$bits" = "8" ] ; then
72153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "  Skipped when running 8-bit tests"
72253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    elif [ $utf -eq 0 ] ; then
72353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "  Skipped because UTF-$bits support is not available"
72453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    else
72553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      for opt in "" $jitopt; do
72653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis        $sim $valgrind ${opt:+$vjs} ./pcre2test -q $defaultstack $bmode $opt $testdata/testinput12 testtry
72753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis        checkresult $? 12-$bits "$opt"
72853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      done
72953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    fi
73053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
73153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
73253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # Tests for 16/32-bit-specific features in DFA non-UTF modes
73353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
73453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ $do13 = yes ] ; then
73553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo $title13
73653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    if [ "$bits" = "8" ] ; then
73753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "  Skipped when running 8-bit tests"
73853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    else
73953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      $sim $valgrind ./pcre2test -q $defaultstack $bmode $testdata/testinput13 testtry
74053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      checkresult $? 13 ""
74153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    fi
74253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
74353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
74453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # Tests for DFA UTF and UCP features. Output is different for the different widths.
74553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
74653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ $do14 = yes ] ; then
74753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo $title14
74853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    if [ $utf -eq 0 ] ; then
74953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "  Skipped because UTF-$bits support is not available"
75053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    else
75153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      $sim $valgrind ./pcre2test -q $defaultstack $bmode $opt $testdata/testinput14 testtry
75253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      checkresult $? 14-$bits ""
75353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    fi
75453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
75553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
75653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # Test non-JIT match and recursion limits
75753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
75853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ $do15 = yes ] ; then
75953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo $title15
76053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    $sim $valgrind ./pcre2test -q $defaultstack $bmode $testdata/testinput15 testtry
76153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    checkresult $? 15 ""
76253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
76353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
76453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # Test JIT-specific features when JIT is not available
76553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
76653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ $do16 = yes ] ; then
76753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo $title16
76853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    if [ $jit -ne 0 ] ; then
76953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "  Skipped because JIT is available"
77053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    else
77153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      $sim $valgrind ./pcre2test -q $defaultstack $bmode $testdata/testinput16 testtry
77253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      checkresult $? 16 ""
77353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    fi
77453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
77553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
77653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # Test JIT-specific features when JIT is available
77753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
77853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ $do17 = yes ] ; then
77953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo $title17
78053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    if [ $jit -eq 0 -o "$nojit" = "yes" ] ; then
78153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "  Skipped because JIT is not available or nojit was specified"
78253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    else
78353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      $sim $valgrind $vjs ./pcre2test -q $defaultstack $bmode $testdata/testinput17 testtry
78453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      checkresult $? 17 ""
78553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    fi
78653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
78753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
78853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # Tests for the POSIX interface without UTF/UCP (8-bit only)
78953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
79053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ $do18 = yes ] ; then
79153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo $title18
79253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    if [ "$bits" = "16" -o "$bits" = "32" ] ; then
79353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "  Skipped when running 16/32-bit tests"
79453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    else
79553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      $sim $valgrind ./pcre2test -q $defaultstack $bmode $testdata/testinput18 testtry
79653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      checkresult $? 18 ""
79753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    fi
79853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
79953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
80053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # Tests for the POSIX interface with UTF/UCP (8-bit only)
80153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
80253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ $do19 = yes ] ; then
80353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo $title19
80453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    if [ "$bits" = "16" -o "$bits" = "32" ] ; then
80553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "  Skipped when running 16/32-bit tests"
80653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    elif [ $utf -eq 0 ] ; then
80753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "  Skipped because UTF-$bits support is not available"
80853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    else
80953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      $sim $valgrind ./pcre2test -q $defaultstack $bmode $testdata/testinput19 testtry
81053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      checkresult $? 19 ""
81153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    fi
81253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
81353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
81453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # Serialization tests
81553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
81653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ $do20 = yes ] ; then
81753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo $title20
81853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    $sim $valgrind ./pcre2test -q $defaultstack $bmode $testdata/testinput20 testtry
81953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    checkresult $? 20 ""
82053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
82153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
82253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # \C tests without UTF - DFA matching is supported
82353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
82453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ "$do21" = yes ] ; then
82553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo $title21
82653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    if [ $supportBSC -eq 0 ] ; then
82753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "  Skipped because \C is disabled"
82853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    else
82953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      for opt in "" $jitopt -dfa; do
83053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis        $sim $valgrind ${opt:+$vjs} ./pcre2test -q $defaultstack $bmode $opt $testdata/testinput21 testtry
83153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis        checkresult $? 21 "$opt"
83253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      done
83353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    fi
83453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
83553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
83653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # \C tests with UTF - DFA matching is not supported for \C in UTF mode
83753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
83853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ "$do22" = yes ] ; then
83953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo $title22
84053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    if [ $supportBSC -eq 0 ] ; then
84153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "  Skipped because \C is disabled"
84253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    elif [ $utf -eq 0 ] ; then
84353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "  Skipped because UTF-$bits support is not available"
84453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    else
84553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      for opt in "" $jitopt; do
84653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis        $sim $valgrind ${opt:+$vjs} ./pcre2test -q $defaultstack $bmode $opt $testdata/testinput22 testtry
84753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis        checkresult $? 22-$bits "$opt"
84853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      done
84953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    fi
85053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
85153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
85253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  # Test when \C is disabled
85353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
85453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  if [ "$do23" = yes ] ; then
85553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    echo $title23
85653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    if [ $supportBSC -ne 0 ] ; then
85753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      echo "  Skipped because \C is not disabled"
85853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    else
85953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      $sim $valgrind ${opt:+$vjs} ./pcre2test -q $defaultstack $bmode $opt $testdata/testinput23 testtry
86053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis      checkresult $? 23 ""
86153e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis    fi
86253e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis  fi
86353e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
86453e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# End of loop for 8/16/32-bit tests
86553e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisdone
86653e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
86753e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# Clean up local working files
86853e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskisrm -f testSinput test3input testsaved1 testsaved2 test3output test3outputA test3outputB teststdout teststderr testtry
86953e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis
87053e448c1797913dbc12dbacc341559934566d6bcJanis Danisevskis# End
871