RunTest 29 KB

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