RunTest 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869
  1. #! /bin/sh
  2. ###############################################################################
  3. # Run the PCRE2 tests using the pcre2test program. The appropriate tests are
  4. # selected, depending on which build-time options were used.
  5. #
  6. # When JIT support is available, all appropriate tests are run with and without
  7. # JIT, unless "-nojit" is given on the command line. There are also two tests
  8. # for JIT-specific features, one to be run when JIT support is available
  9. # (unless "-nojit" is specified), and one when it is not.
  10. #
  11. # Whichever of the 8-, 16- and 32-bit libraries exist are tested. It is also
  12. # possible to select which to test by giving "-8", "-16" or "-32" on the
  13. # command line.
  14. #
  15. # As well as "-nojit", "-8", "-16", and "-32", arguments for this script are
  16. # individual test numbers, ranges of tests such as 3-6 or 3- (meaning 3 to the
  17. # end), or a number preceded by ~ to exclude a test. For example, "3-15 ~10"
  18. # runs tests 3 to 15, excluding test 10, and just "~10" runs all the tests
  19. # except test 10. Whatever order the arguments are in, the tests are always run
  20. # in numerical order.
  21. #
  22. # Inappropriate tests are automatically skipped (with a comment to say so). For
  23. # example, if JIT support is not compiled, test 16 is skipped, whereas if JIT
  24. # support is compiled, test 15 is skipped.
  25. #
  26. # Other arguments can be one of the words "-valgrind", "-valgrind-log", or
  27. # "-sim" followed by an argument to run cross-compiled executables under a
  28. # simulator, for example:
  29. #
  30. # RunTest 3 -sim "qemu-arm -s 8388608"
  31. #
  32. # For backwards compatibility, -nojit, -valgrind, -valgrind-log, and -sim may
  33. # be given without the leading "-" character.
  34. #
  35. # When PCRE2 is compiled by clang with -fsanitize arguments, some tests need
  36. # very much more stack than normal. In environments where the stack can be
  37. # set at runtime, -bigstack sets a gigantic stack.
  38. #
  39. # There are two special cases where only one argument is allowed:
  40. #
  41. # If the first and only argument is "ebcdic", the script runs the special
  42. # EBCDIC test that can be useful for checking certain EBCDIC features, even
  43. # when run in an ASCII environment. PCRE2 must be built with EBCDIC support for
  44. # this test to be run.
  45. #
  46. # If the script is obeyed as "RunTest list", a list of available tests is
  47. # output, but none of them are run.
  48. ###############################################################################
  49. # Define test titles in variables so that they can be output as a list. Some
  50. # of them are modified (e.g. with -8 or -16) when used in the actual tests.
  51. title0="Test 0: Unchecked pcre2test argument tests (to improve coverage)"
  52. title1="Test 1: Main non-UTF, non-UCP functionality (compatible with Perl >= 5.10)"
  53. title2="Test 2: API, errors, internals and non-Perl stuff"
  54. title3="Test 3: Locale-specific features"
  55. title4A="Test 4: UTF"
  56. title4B=" and Unicode property support (compatible with Perl >= 5.10)"
  57. title5A="Test 5: API, internals, and non-Perl stuff for UTF"
  58. title5B=" and UCP support"
  59. title6="Test 6: DFA matching main non-UTF, non-UCP functionality"
  60. title7A="Test 7: DFA matching with UTF"
  61. title7B=" and Unicode property support"
  62. title8="Test 8: Internal offsets and code size tests"
  63. title9="Test 9: Specials for the basic 8-bit library"
  64. title10="Test 10: Specials for the 8-bit library with UTF-8 and UCP support"
  65. title11="Test 11: Specials for the basic 16-bit and 32-bit libraries"
  66. title12="Test 12: Specials for the 16-bit and 32-bit libraries UTF and UCP support"
  67. title13="Test 13: DFA specials for the basic 16-bit and 32-bit libraries"
  68. title14="Test 14: DFA specials for UTF and UCP support"
  69. title15="Test 15: Non-JIT limits and other non-JIT tests"
  70. title16="Test 16: JIT-specific features when JIT is not available"
  71. title17="Test 17: JIT-specific features when JIT is available"
  72. title18="Test 18: Tests of the POSIX interface, excluding UTF/UCP"
  73. title19="Test 19: Tests of the POSIX interface with UTF/UCP"
  74. title20="Test 20: Serialization and code copy tests"
  75. title21="Test 21: \C tests without UTF (supported for DFA matching)"
  76. title22="Test 22: \C tests with UTF (not supported for DFA matching)"
  77. title23="Test 23: \C disabled test"
  78. title24="Test 24: Non-UTF pattern conversion tests"
  79. title25="Test 25: UTF pattern conversion tests"
  80. maxtest=25
  81. if [ $# -eq 1 -a "$1" = "list" ]; then
  82. echo $title0
  83. echo $title1
  84. echo $title2 "(not UTF or UCP)"
  85. echo $title3
  86. echo $title4A $title4B
  87. echo $title5A $title5B
  88. echo $title6
  89. echo $title7A $title7B
  90. echo $title8
  91. echo $title9
  92. echo $title10
  93. echo $title11
  94. echo $title12
  95. echo $title13
  96. echo $title14
  97. echo $title15
  98. echo $title16
  99. echo $title17
  100. echo $title18
  101. echo $title19
  102. echo $title20
  103. echo $title21
  104. echo $title22
  105. echo $title23
  106. echo $title24
  107. echo $title25
  108. exit 0
  109. fi
  110. # Set up a suitable "diff" command for comparison. Some systems
  111. # have a diff that lacks a -u option. Try to deal with this.
  112. cf="diff"
  113. diff -u /dev/null /dev/null 2>/dev/null && cf="diff -u"
  114. # Find the test data
  115. if [ -n "$srcdir" -a -d "$srcdir" ] ; then
  116. testdata="$srcdir/testdata"
  117. elif [ -d "./testdata" ] ; then
  118. testdata=./testdata
  119. elif [ -d "../testdata" ] ; then
  120. testdata=../testdata
  121. else
  122. echo "Cannot find the testdata directory"
  123. exit 1
  124. fi
  125. # ------ Function to check results of a test -------
  126. # This function is called with three parameters:
  127. #
  128. # $1 the value of $? after a call to pcre2test
  129. # $2 the suffix of the output file to compare with
  130. # $3 the $opt value (empty, -jit, or -dfa)
  131. #
  132. # Note: must define using name(), not "function name", for Solaris.
  133. checkresult()
  134. {
  135. if [ $1 -ne 0 ] ; then
  136. echo "** pcre2test failed - check testtry"
  137. exit 1
  138. fi
  139. case "$3" in
  140. -jit) with=" with JIT";;
  141. -dfa) with=" with DFA";;
  142. *) with="";;
  143. esac
  144. $cf $testdata/testoutput$2 testtry
  145. if [ $? != 0 ] ; then
  146. echo ""
  147. echo "** Test $2 failed$with"
  148. exit 1
  149. fi
  150. echo " OK$with"
  151. }
  152. # ------ Function to run and check a special pcre2test arguments test -------
  153. checkspecial()
  154. {
  155. $valgrind $vjs ./pcre2test $1 >>testtry
  156. if [ $? -ne 0 ] ; then
  157. echo "** pcre2test $1 failed - check testtry"
  158. exit 1
  159. fi
  160. }
  161. # ------ Special EBCDIC Test -------
  162. if [ $# -eq 1 -a "$1" = "ebcdic" ]; then
  163. $valgrind ./pcre2test -C ebcdic >/dev/null
  164. ebcdic=$?
  165. if [ $ebcdic -ne 1 ] ; then
  166. echo "Cannot run EBCDIC tests: EBCDIC support not compiled"
  167. exit 1
  168. fi
  169. for opt in "" "-dfa"; do
  170. ./pcre2test -q $opt $testdata/testinputEBC >testtry
  171. checkresult $? EBC "$opt"
  172. done
  173. exit 0
  174. fi
  175. # ------ Normal Tests ------
  176. # Default values
  177. arg8=
  178. arg16=
  179. arg32=
  180. nojit=
  181. bigstack=
  182. sim=
  183. skip=
  184. valgrind=
  185. vjs=
  186. # This is in case the caller has set aliases (as I do - PH)
  187. unset cp ls mv rm
  188. # Process options and select which tests to run; for those that are explicitly
  189. # requested, check that the necessary optional facilities are available.
  190. do0=no
  191. do1=no
  192. do2=no
  193. do3=no
  194. do4=no
  195. do5=no
  196. do6=no
  197. do7=no
  198. do8=no
  199. do9=no
  200. do10=no
  201. do11=no
  202. do12=no
  203. do13=no
  204. do14=no
  205. do15=no
  206. do16=no
  207. do17=no
  208. do18=no
  209. do19=no
  210. do20=no
  211. do21=no
  212. do22=no
  213. do23=no
  214. do24=no
  215. do25=no
  216. while [ $# -gt 0 ] ; do
  217. case $1 in
  218. 0) do0=yes;;
  219. 1) do1=yes;;
  220. 2) do2=yes;;
  221. 3) do3=yes;;
  222. 4) do4=yes;;
  223. 5) do5=yes;;
  224. 6) do6=yes;;
  225. 7) do7=yes;;
  226. 8) do8=yes;;
  227. 9) do9=yes;;
  228. 10) do10=yes;;
  229. 11) do11=yes;;
  230. 12) do12=yes;;
  231. 13) do13=yes;;
  232. 14) do14=yes;;
  233. 15) do15=yes;;
  234. 16) do16=yes;;
  235. 17) do17=yes;;
  236. 18) do18=yes;;
  237. 19) do19=yes;;
  238. 20) do20=yes;;
  239. 21) do21=yes;;
  240. 22) do22=yes;;
  241. 23) do23=yes;;
  242. 24) do24=yes;;
  243. 25) do25=yes;;
  244. -8) arg8=yes;;
  245. -16) arg16=yes;;
  246. -32) arg32=yes;;
  247. bigstack|-bigstack) bigstack=yes;;
  248. nojit|-nojit) nojit=yes;;
  249. sim|-sim) shift; sim=$1;;
  250. valgrind|-valgrind) valgrind="valgrind --tool=memcheck -q --smc-check=all-non-file";;
  251. 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 ";;
  252. ~*)
  253. if expr "$1" : '~[0-9][0-9]*$' >/dev/null; then
  254. skip="$skip `expr "$1" : '~\([0-9]*\)*$'`"
  255. else
  256. echo "Unknown option or test selector '$1'"; exit 1
  257. fi
  258. ;;
  259. *-*)
  260. if expr "$1" : '[0-9][0-9]*-[0-9]*$' >/dev/null; then
  261. tf=`expr "$1" : '\([0-9]*\)'`
  262. tt=`expr "$1" : '.*-\([0-9]*\)'`
  263. if [ "$tt" = "" ] ; then tt=$maxtest; fi
  264. if expr \( "$tt" ">" "$maxtest" \) >/dev/null; then
  265. echo "Invalid test range '$1'"; exit 1
  266. fi
  267. while expr "$tf" "<=" "$tt" >/dev/null; do
  268. eval do${tf}=yes
  269. tf=`expr $tf + 1`
  270. done
  271. else
  272. echo "Invalid test range '$1'"; exit 1
  273. fi
  274. ;;
  275. *) echo "Unknown option or test selector '$1'"; exit 1;;
  276. esac
  277. shift
  278. done
  279. # Find which optional facilities are available.
  280. $sim ./pcre2test -C linksize >/dev/null
  281. link_size=$?
  282. if [ $link_size -lt 2 ] ; then
  283. echo "RunTest: Failed to find internal link size"
  284. exit 1
  285. fi
  286. if [ $link_size -gt 4 ] ; then
  287. echo "RunTest: Failed to find internal link size"
  288. exit 1
  289. fi
  290. # If it is possible to set the system stack size and -bigstack was given,
  291. # set up a large stack.
  292. $sim ./pcre2test -S 64 /dev/null /dev/null
  293. if [ $? -eq 0 -a "$bigstack" != "" ] ; then
  294. setstack="-S 64"
  295. else
  296. setstack=""
  297. fi
  298. # All of 8-bit, 16-bit, and 32-bit character strings may be supported, but only
  299. # one need be.
  300. $sim ./pcre2test -C pcre2-8 >/dev/null
  301. support8=$?
  302. $sim ./pcre2test -C pcre2-16 >/dev/null
  303. support16=$?
  304. $sim ./pcre2test -C pcre2-32 >/dev/null
  305. support32=$?
  306. # \C may be disabled
  307. $sim ./pcre2test -C backslash-C >/dev/null
  308. supportBSC=$?
  309. # Initialize all bitsizes skipped
  310. test8=skip
  311. test16=skip
  312. test32=skip
  313. # If no bitsize arguments, select all that are available
  314. if [ "$arg8$arg16$arg32" = "" ] ; then
  315. if [ $support8 -ne 0 ] ; then
  316. test8=-8
  317. fi
  318. if [ $support16 -ne 0 ] ; then
  319. test16=-16
  320. fi
  321. if [ $support32 -ne 0 ] ; then
  322. test32=-32
  323. fi
  324. # Otherwise, select requested bit sizes
  325. else
  326. if [ "$arg8" = yes ] ; then
  327. if [ $support8 -eq 0 ] ; then
  328. echo "Cannot run 8-bit library tests: 8-bit library not compiled"
  329. exit 1
  330. fi
  331. test8=-8
  332. fi
  333. if [ "$arg16" = yes ] ; then
  334. if [ $support16 -eq 0 ] ; then
  335. echo "Cannot run 16-bit library tests: 16-bit library not compiled"
  336. exit 1
  337. fi
  338. test16=-16
  339. fi
  340. if [ "$arg32" = yes ] ; then
  341. if [ $support32 -eq 0 ] ; then
  342. echo "Cannot run 32-bit library tests: 32-bit library not compiled"
  343. exit 1
  344. fi
  345. test32=-32
  346. fi
  347. fi
  348. # UTF support is implied by Unicode support, and it always applies to all bit
  349. # sizes if both are supported; we can't have UTF-8 support without UTF-16 or
  350. # UTF-32 support.
  351. $sim ./pcre2test -C unicode >/dev/null
  352. utf=$?
  353. # When JIT is used with valgrind, we need to set up valgrind suppressions as
  354. # otherwise there are a lot of false positive valgrind reports when the
  355. # the hardware supports SSE2.
  356. jitopt=
  357. $sim ./pcre2test -C jit >/dev/null
  358. jit=$?
  359. if [ $jit -ne 0 -a "$nojit" != "yes" ] ; then
  360. jitopt=-jit
  361. if [ "$valgrind" != "" ] ; then
  362. vjs="--suppressions=$testdata/valgrind-jit.supp"
  363. fi
  364. fi
  365. # If no specific tests were requested, select all. Those that are not
  366. # relevant will be automatically skipped.
  367. if [ $do0 = no -a $do1 = no -a $do2 = no -a $do3 = no -a \
  368. $do4 = no -a $do5 = no -a $do6 = no -a $do7 = no -a \
  369. $do8 = no -a $do9 = no -a $do10 = no -a $do11 = no -a \
  370. $do12 = no -a $do13 = no -a $do14 = no -a $do15 = no -a \
  371. $do16 = no -a $do17 = no -a $do18 = no -a $do19 = no -a \
  372. $do20 = no -a $do21 = no -a $do22 = no -a $do23 = no -a \
  373. $do24 = no -a $do25 = no \
  374. ]; then
  375. do0=yes
  376. do1=yes
  377. do2=yes
  378. do3=yes
  379. do4=yes
  380. do5=yes
  381. do6=yes
  382. do7=yes
  383. do8=yes
  384. do9=yes
  385. do10=yes
  386. do11=yes
  387. do12=yes
  388. do13=yes
  389. do14=yes
  390. do15=yes
  391. do16=yes
  392. do17=yes
  393. do18=yes
  394. do19=yes
  395. do20=yes
  396. do21=yes
  397. do22=yes
  398. do23=yes
  399. do24=yes
  400. do25=yes
  401. fi
  402. # Handle any explicit skips at this stage, so that an argument list may consist
  403. # only of explicit skips.
  404. for i in $skip; do eval do$i=no; done
  405. # Show which release and which test data
  406. echo ""
  407. echo PCRE2 C library tests using test data from $testdata
  408. $sim ./pcre2test /dev/null
  409. echo ""
  410. for bmode in "$test8" "$test16" "$test32"; do
  411. case "$bmode" in
  412. skip) continue;;
  413. -16) if [ "$test8$test32" != "skipskip" ] ; then echo ""; fi
  414. bits=16; echo "---- Testing 16-bit library ----"; echo "";;
  415. -32) if [ "$test8$test16" != "skipskip" ] ; then echo ""; fi
  416. bits=32; echo "---- Testing 32-bit library ----"; echo "";;
  417. -8) bits=8; echo "---- Testing 8-bit library ----"; echo "";;
  418. esac
  419. # Test 0 is a special test. Its output is not checked, because it will
  420. # be different on different hardware and with different configurations.
  421. # Running this test just exercises the code.
  422. if [ $do0 = yes ] ; then
  423. echo $title0
  424. echo '/abc/jit,memory,framesize' >testSinput
  425. echo ' abc' >>testSinput
  426. echo '' >testtry
  427. checkspecial '-C'
  428. checkspecial '--help'
  429. checkspecial '-S 1 -t 10 testSinput'
  430. echo " OK"
  431. fi
  432. # Primary non-UTF test, compatible with JIT and all versions of Perl >= 5.8
  433. if [ $do1 = yes ] ; then
  434. echo $title1
  435. for opt in "" $jitopt; do
  436. $sim $valgrind ${opt:+$vjs} ./pcre2test -q $setstack $bmode $opt $testdata/testinput1 testtry
  437. checkresult $? 1 "$opt"
  438. done
  439. fi
  440. # PCRE2 tests that are not Perl-compatible: API, errors, internals. We copy
  441. # the testbtables file to the current directory for use by this test.
  442. if [ $do2 = yes ] ; then
  443. echo $title2 "(excluding UTF-$bits)"
  444. cp $testdata/testbtables .
  445. for opt in "" $jitopt; do
  446. $sim $valgrind ${opt:+$vjs} ./pcre2test -q $setstack $bmode $opt $testdata/testinput2 testtry
  447. saverc=$?
  448. if [ $saverc = 0 ] ; then
  449. $sim $valgrind ${opt:+$vjs} ./pcre2test -q $bmode $opt -error -70,-62,-2,-1,0,100,101,191,200 >>testtry
  450. checkresult $? 2 "$opt"
  451. else
  452. checkresult $saverc 2 "$opt"
  453. fi
  454. done
  455. fi
  456. # Locale-specific tests, provided that either the "fr_FR", "fr_CA", "french"
  457. # or "fr" locale is available. The first two are Unix-like standards; the
  458. # last two are for Windows. Unfortunately, different versions of the French
  459. # locale give different outputs for some items. This test passes if the
  460. # output matches any one of the alternative output files.
  461. if [ $do3 = yes ] ; then
  462. locale=
  463. # In some environments locales that are listed by the "locale -a"
  464. # command do not seem to work with setlocale(). Therefore, we do
  465. # a preliminary test to see if pcre2test can set one before going
  466. # on to use it.
  467. for loc in 'fr_FR' 'french' 'fr' 'fr_CA'; do
  468. locale -a | grep "^$loc\$" >/dev/null
  469. if [ $? -eq 0 ] ; then
  470. echo "/a/locale=$loc" | \
  471. $sim $valgrind ./pcre2test -q $bmode | \
  472. grep "Failed to set locale" >/dev/null
  473. if [ $? -ne 0 ] ; then
  474. locale=$loc
  475. if [ "$locale" = "fr_FR" ] ; then
  476. infile=$testdata/testinput3
  477. outfile=$testdata/testoutput3
  478. outfile2=$testdata/testoutput3A
  479. outfile3=$testdata/testoutput3B
  480. else
  481. infile=test3input
  482. outfile=test3output
  483. outfile2=test3outputA
  484. outfile3=test3outputB
  485. sed "s/fr_FR/$loc/" $testdata/testinput3 >test3input
  486. sed "s/fr_FR/$loc/" $testdata/testoutput3 >test3output
  487. sed "s/fr_FR/$loc/" $testdata/testoutput3A >test3outputA
  488. sed "s/fr_FR/$loc/" $testdata/testoutput3B >test3outputB
  489. fi
  490. break
  491. fi
  492. fi
  493. done
  494. if [ "$locale" != "" ] ; then
  495. echo $title3 "(using '$locale' locale)"
  496. for opt in "" $jitopt; do
  497. $sim $valgrind ${opt:+$vjs} ./pcre2test -q $setstack $bmode $opt $infile testtry
  498. if [ $? = 0 ] ; then
  499. case "$opt" in
  500. -jit) with=" with JIT";;
  501. *) with="";;
  502. esac
  503. if $cf $outfile testtry >teststdout || \
  504. $cf $outfile2 testtry >teststdout || \
  505. $cf $outfile3 testtry >teststdout
  506. then
  507. echo " OK$with"
  508. else
  509. echo "** Locale test did not run successfully$with. The output did not match"
  510. echo " $outfile, $outfile2 or $outfile3."
  511. echo " This may mean that there is a problem with the locale settings rather"
  512. echo " than a bug in PCRE2."
  513. exit 1
  514. fi
  515. else exit 1
  516. fi
  517. done
  518. else
  519. echo "Cannot test locale-specific features - none of the 'fr_FR', 'fr_CA',"
  520. echo "'fr' or 'french' locales can be set, or the \"locale\" command is"
  521. echo "not available to check for them."
  522. echo " "
  523. fi
  524. fi
  525. # Tests for UTF and Unicode property support
  526. if [ $do4 = yes ] ; then
  527. echo ${title4A}-${bits}${title4B}
  528. if [ $utf -eq 0 ] ; then
  529. echo " Skipped because UTF-$bits support is not available"
  530. else
  531. for opt in "" $jitopt; do
  532. $sim $valgrind ${opt:+$vjs} ./pcre2test -q $setstack $bmode $opt $testdata/testinput4 testtry
  533. checkresult $? 4 "$opt"
  534. done
  535. fi
  536. fi
  537. if [ $do5 = yes ] ; then
  538. echo ${title5A}-${bits}$title5B
  539. if [ $utf -eq 0 ] ; then
  540. echo " Skipped because UTF-$bits support is not available"
  541. else
  542. for opt in "" $jitopt; do
  543. $sim $valgrind ${opt:+$vjs} ./pcre2test -q $setstack $bmode $opt $testdata/testinput5 testtry
  544. checkresult $? 5 "$opt"
  545. done
  546. fi
  547. fi
  548. # Tests for DFA matching support
  549. if [ $do6 = yes ] ; then
  550. echo $title6
  551. $sim $valgrind ./pcre2test -q $setstack $bmode $testdata/testinput6 testtry
  552. checkresult $? 6 ""
  553. fi
  554. if [ $do7 = yes ] ; then
  555. echo ${title7A}-${bits}$title7B
  556. if [ $utf -eq 0 ] ; then
  557. echo " Skipped because UTF-$bits support is not available"
  558. else
  559. $sim $valgrind ./pcre2test -q $setstack $bmode $opt $testdata/testinput7 testtry
  560. checkresult $? 7 ""
  561. fi
  562. fi
  563. # Test of internal offsets and code sizes. This test is run only when there
  564. # is UTF/UCP support. The actual tests are mostly the same as in some of the
  565. # above, but in this test we inspect some offsets and sizes. This is a
  566. # doublecheck for the maintainer, just in case something changes unexpectely.
  567. # The output from this test is different in 8-bit, 16-bit, and 32-bit modes
  568. # and for different link sizes, so there are different output files for each
  569. # mode and link size.
  570. if [ $do8 = yes ] ; then
  571. echo $title8
  572. if [ $utf -eq 0 ] ; then
  573. echo " Skipped because UTF-$bits support is not available"
  574. else
  575. $sim $valgrind ./pcre2test -q $setstack $bmode $testdata/testinput8 testtry
  576. checkresult $? 8-$bits-$link_size ""
  577. fi
  578. fi
  579. # Tests for 8-bit-specific features
  580. if [ "$do9" = yes ] ; then
  581. echo $title9
  582. if [ "$bits" = "16" -o "$bits" = "32" ] ; then
  583. echo " Skipped when running 16/32-bit tests"
  584. else
  585. for opt in "" $jitopt; do
  586. $sim $valgrind ${opt:+$vjs} ./pcre2test -q $setstack $bmode $opt $testdata/testinput9 testtry
  587. checkresult $? 9 "$opt"
  588. done
  589. fi
  590. fi
  591. # Tests for UTF-8 and UCP 8-bit-specific features
  592. if [ "$do10" = yes ] ; then
  593. echo $title10
  594. if [ "$bits" = "16" -o "$bits" = "32" ] ; then
  595. echo " Skipped when running 16/32-bit tests"
  596. elif [ $utf -eq 0 ] ; then
  597. echo " Skipped because UTF-$bits support is not available"
  598. else
  599. for opt in "" $jitopt; do
  600. $sim $valgrind ${opt:+$vjs} ./pcre2test -q $setstack $bmode $opt $testdata/testinput10 testtry
  601. checkresult $? 10 "$opt"
  602. done
  603. fi
  604. fi
  605. # Tests for 16-bit and 32-bit features. Output is different for the two widths.
  606. if [ $do11 = yes ] ; then
  607. echo $title11
  608. if [ "$bits" = "8" ] ; then
  609. echo " Skipped when running 8-bit tests"
  610. else
  611. for opt in "" $jitopt; do
  612. $sim $valgrind ${opt:+$vjs} ./pcre2test -q $setstack $bmode $opt $testdata/testinput11 testtry
  613. checkresult $? 11-$bits "$opt"
  614. done
  615. fi
  616. fi
  617. # Tests for 16-bit and 32-bit features with UTF-16/32 and UCP support. Output
  618. # is different for the two widths.
  619. if [ $do12 = yes ] ; then
  620. echo $title12
  621. if [ "$bits" = "8" ] ; then
  622. echo " Skipped when running 8-bit tests"
  623. elif [ $utf -eq 0 ] ; then
  624. echo " Skipped because UTF-$bits support is not available"
  625. else
  626. for opt in "" $jitopt; do
  627. $sim $valgrind ${opt:+$vjs} ./pcre2test -q $setstack $bmode $opt $testdata/testinput12 testtry
  628. checkresult $? 12-$bits "$opt"
  629. done
  630. fi
  631. fi
  632. # Tests for 16/32-bit-specific features in DFA non-UTF modes
  633. if [ $do13 = yes ] ; then
  634. echo $title13
  635. if [ "$bits" = "8" ] ; then
  636. echo " Skipped when running 8-bit tests"
  637. else
  638. $sim $valgrind ./pcre2test -q $setstack $bmode $testdata/testinput13 testtry
  639. checkresult $? 13 ""
  640. fi
  641. fi
  642. # Tests for DFA UTF and UCP features. Output is different for the different widths.
  643. if [ $do14 = yes ] ; then
  644. echo $title14
  645. if [ $utf -eq 0 ] ; then
  646. echo " Skipped because UTF-$bits support is not available"
  647. else
  648. $sim $valgrind ./pcre2test -q $setstack $bmode $opt $testdata/testinput14 testtry
  649. checkresult $? 14-$bits ""
  650. fi
  651. fi
  652. # Test non-JIT match and recursion limits
  653. if [ $do15 = yes ] ; then
  654. echo $title15
  655. $sim $valgrind ./pcre2test -q $setstack $bmode $testdata/testinput15 testtry
  656. checkresult $? 15 ""
  657. fi
  658. # Test JIT-specific features when JIT is not available
  659. if [ $do16 = yes ] ; then
  660. echo $title16
  661. if [ $jit -ne 0 ] ; then
  662. echo " Skipped because JIT is available"
  663. else
  664. $sim $valgrind ./pcre2test -q $setstack $bmode $testdata/testinput16 testtry
  665. checkresult $? 16 ""
  666. fi
  667. fi
  668. # Test JIT-specific features when JIT is available
  669. if [ $do17 = yes ] ; then
  670. echo $title17
  671. if [ $jit -eq 0 -o "$nojit" = "yes" ] ; then
  672. echo " Skipped because JIT is not available or nojit was specified"
  673. else
  674. $sim $valgrind $vjs ./pcre2test -q $setstack $bmode $testdata/testinput17 testtry
  675. checkresult $? 17 ""
  676. fi
  677. fi
  678. # Tests for the POSIX interface without UTF/UCP (8-bit only)
  679. if [ $do18 = yes ] ; then
  680. echo $title18
  681. if [ "$bits" = "16" -o "$bits" = "32" ] ; then
  682. echo " Skipped when running 16/32-bit tests"
  683. else
  684. $sim $valgrind ./pcre2test -q $setstack $bmode $testdata/testinput18 testtry
  685. checkresult $? 18 ""
  686. fi
  687. fi
  688. # Tests for the POSIX interface with UTF/UCP (8-bit only)
  689. if [ $do19 = yes ] ; then
  690. echo $title19
  691. if [ "$bits" = "16" -o "$bits" = "32" ] ; then
  692. echo " Skipped when running 16/32-bit tests"
  693. elif [ $utf -eq 0 ] ; then
  694. echo " Skipped because UTF-$bits support is not available"
  695. else
  696. $sim $valgrind ./pcre2test -q $setstack $bmode $testdata/testinput19 testtry
  697. checkresult $? 19 ""
  698. fi
  699. fi
  700. # Serialization tests
  701. if [ $do20 = yes ] ; then
  702. echo $title20
  703. $sim $valgrind ./pcre2test -q $setstack $bmode $testdata/testinput20 testtry
  704. checkresult $? 20 ""
  705. fi
  706. # \C tests without UTF - DFA matching is supported
  707. if [ "$do21" = yes ] ; then
  708. echo $title21
  709. if [ $supportBSC -eq 0 ] ; then
  710. echo " Skipped because \C is disabled"
  711. else
  712. for opt in "" $jitopt -dfa; do
  713. $sim $valgrind ${opt:+$vjs} ./pcre2test -q $setstack $bmode $opt $testdata/testinput21 testtry
  714. checkresult $? 21 "$opt"
  715. done
  716. fi
  717. fi
  718. # \C tests with UTF - DFA matching is not supported for \C in UTF mode
  719. if [ "$do22" = yes ] ; then
  720. echo $title22
  721. if [ $supportBSC -eq 0 ] ; then
  722. echo " Skipped because \C is disabled"
  723. elif [ $utf -eq 0 ] ; then
  724. echo " Skipped because UTF-$bits support is not available"
  725. else
  726. for opt in "" $jitopt; do
  727. $sim $valgrind ${opt:+$vjs} ./pcre2test -q $setstack $bmode $opt $testdata/testinput22 testtry
  728. checkresult $? 22-$bits "$opt"
  729. done
  730. fi
  731. fi
  732. # Test when \C is disabled
  733. if [ "$do23" = yes ] ; then
  734. echo $title23
  735. if [ $supportBSC -ne 0 ] ; then
  736. echo " Skipped because \C is not disabled"
  737. else
  738. $sim $valgrind ./pcre2test -q $setstack $bmode $testdata/testinput23 testtry
  739. checkresult $? 23 ""
  740. fi
  741. fi
  742. # Non-UTF pattern conversion tests
  743. if [ "$do24" = yes ] ; then
  744. echo $title24
  745. $sim $valgrind ./pcre2test -q $setstack $bmode $testdata/testinput24 testtry
  746. checkresult $? 24 ""
  747. fi
  748. # UTF pattern conversion tests
  749. if [ "$do25" = yes ] ; then
  750. echo $title25
  751. if [ $utf -eq 0 ] ; then
  752. echo " Skipped because UTF-$bits support is not available"
  753. else
  754. $sim $valgrind ./pcre2test -q $setstack $bmode $testdata/testinput25 testtry
  755. checkresult $? 25 ""
  756. fi
  757. fi
  758. # End of loop for 8/16/32-bit tests
  759. done
  760. # Clean up local working files
  761. rm -f testbtables testSinput test3input testsaved1 testsaved2 test3output test3outputA test3outputB teststdout teststderr testtry
  762. # End