RunTest.bat 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. @echo off
  2. @rem
  3. @rem MS Windows batch file to run pcre2test on testfiles with the correct
  4. @rem options. This file must use CRLF linebreaks to function properly,
  5. @rem and requires both pcre2test and pcre2grep.
  6. @rem
  7. @rem ------------------------ HISTORY ----------------------------------
  8. @rem This file was originally contributed to PCRE1 by Ralf Junker, and touched
  9. @rem up by Daniel Richard G. Tests 10-12 added by Philip H.
  10. @rem Philip H also changed test 3 to use "wintest" files.
  11. @rem
  12. @rem Updated by Tom Fortmann to support explicit test numbers on the command
  13. @rem line. Added argument validation and added error reporting.
  14. @rem
  15. @rem Sheri Pierce added logic to skip feature dependent tests
  16. @rem tests 4 5 7 10 12 14 19 and 22 require Unicode support
  17. @rem 8 requires Unicode and link size 2
  18. @rem 16 requires absence of jit support
  19. @rem 17 requires presence of jit support
  20. @rem Sheri P also added override tests for study and jit testing
  21. @rem Zoltan Herczeg added libpcre16 support
  22. @rem Zoltan Herczeg added libpcre32 support
  23. @rem -------------------------------------------------------------------
  24. @rem
  25. @rem The file was converted for PCRE2 by PH, February 2015.
  26. @rem Updated for new test 14 (moving others up a number), August 2015.
  27. @rem Tidied and updated for new tests 21, 22, 23 by PH, October 2015.
  28. @rem PH added missing "set type" for test 22, April 2016.
  29. @rem PH added copy command for new testbtables file, November 2020
  30. setlocal enabledelayedexpansion
  31. if [%srcdir%]==[] (
  32. if exist testdata\ set srcdir=.)
  33. if [%srcdir%]==[] (
  34. if exist ..\testdata\ set srcdir=..)
  35. if [%srcdir%]==[] (
  36. if exist ..\..\testdata\ set srcdir=..\..)
  37. if NOT exist %srcdir%\testdata\ (
  38. Error: echo distribution testdata folder not found!
  39. call :conferror
  40. exit /b 1
  41. goto :eof
  42. )
  43. if [%pcre2test%]==[] set pcre2test=.\pcre2test.exe
  44. echo source dir is %srcdir%
  45. echo pcre2test=%pcre2test%
  46. if NOT exist %pcre2test% (
  47. echo Error: %pcre2test% not found!
  48. echo.
  49. call :conferror
  50. exit /b 1
  51. )
  52. %pcre2test% -C linksize >NUL
  53. set link_size=%ERRORLEVEL%
  54. %pcre2test% -C pcre2-8 >NUL
  55. set support8=%ERRORLEVEL%
  56. %pcre2test% -C pcre2-16 >NUL
  57. set support16=%ERRORLEVEL%
  58. %pcre2test% -C pcre2-32 >NUL
  59. set support32=%ERRORLEVEL%
  60. %pcre2test% -C unicode >NUL
  61. set unicode=%ERRORLEVEL%
  62. %pcre2test% -C jit >NUL
  63. set jit=%ERRORLEVEL%
  64. %pcre2test% -C backslash-C >NUL
  65. set supportBSC=%ERRORLEVEL%
  66. if %support8% EQU 1 (
  67. if not exist testout8 md testout8
  68. if not exist testoutjit8 md testoutjit8
  69. )
  70. if %support16% EQU 1 (
  71. if not exist testout16 md testout16
  72. if not exist testoutjit16 md testoutjit16
  73. )
  74. if %support16% EQU 1 (
  75. if not exist testout32 md testout32
  76. if not exist testoutjit32 md testoutjit32
  77. )
  78. set do1=no
  79. set do2=no
  80. set do3=no
  81. set do4=no
  82. set do5=no
  83. set do6=no
  84. set do7=no
  85. set do8=no
  86. set do9=no
  87. set do10=no
  88. set do11=no
  89. set do12=no
  90. set do13=no
  91. set do14=no
  92. set do15=no
  93. set do16=no
  94. set do17=no
  95. set do18=no
  96. set do19=no
  97. set do20=no
  98. set do21=no
  99. set do22=no
  100. set do23=no
  101. set all=yes
  102. for %%a in (%*) do (
  103. set valid=no
  104. for %%v in (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23) do if %%v == %%a set valid=yes
  105. if "!valid!" == "yes" (
  106. set do%%a=yes
  107. set all=no
  108. ) else (
  109. echo Invalid test number - %%a!
  110. echo Usage %0 [ test_number ] ...
  111. echo Where test_number is one or more optional test numbers 1 through 23, default is all tests.
  112. exit /b 1
  113. )
  114. )
  115. set failed="no"
  116. if "%all%" == "yes" (
  117. set do1=yes
  118. set do2=yes
  119. set do3=yes
  120. set do4=yes
  121. set do5=yes
  122. set do6=yes
  123. set do7=yes
  124. set do8=yes
  125. set do9=yes
  126. set do10=yes
  127. set do11=yes
  128. set do12=yes
  129. set do13=yes
  130. set do14=yes
  131. set do15=yes
  132. set do16=yes
  133. set do17=yes
  134. set do18=yes
  135. set do19=yes
  136. set do20=yes
  137. set do21=yes
  138. set do22=yes
  139. set do23=yes
  140. )
  141. @echo RunTest.bat's pcre2test output is written to newly created subfolders
  142. @echo named testout{8,16,32} and testoutjit{8,16,32}.
  143. @echo.
  144. set mode=
  145. set bits=8
  146. :nextMode
  147. if "%mode%" == "" (
  148. if %support8% EQU 0 goto modeSkip
  149. echo.
  150. echo ---- Testing 8-bit library ----
  151. echo.
  152. )
  153. if "%mode%" == "-16" (
  154. if %support16% EQU 0 goto modeSkip
  155. echo.
  156. echo ---- Testing 16-bit library ----
  157. echo.
  158. )
  159. if "%mode%" == "-32" (
  160. if %support32% EQU 0 goto modeSkip
  161. echo.
  162. echo ---- Testing 32-bit library ----
  163. echo.
  164. )
  165. if "%do1%" == "yes" call :do1
  166. if "%do2%" == "yes" call :do2
  167. if "%do3%" == "yes" call :do3
  168. if "%do4%" == "yes" call :do4
  169. if "%do5%" == "yes" call :do5
  170. if "%do6%" == "yes" call :do6
  171. if "%do7%" == "yes" call :do7
  172. if "%do8%" == "yes" call :do8
  173. if "%do9%" == "yes" call :do9
  174. if "%do10%" == "yes" call :do10
  175. if "%do11%" == "yes" call :do11
  176. if "%do12%" == "yes" call :do12
  177. if "%do13%" == "yes" call :do13
  178. if "%do14%" == "yes" call :do14
  179. if "%do15%" == "yes" call :do15
  180. if "%do16%" == "yes" call :do16
  181. if "%do17%" == "yes" call :do17
  182. if "%do18%" == "yes" call :do18
  183. if "%do19%" == "yes" call :do19
  184. if "%do20%" == "yes" call :do20
  185. if "%do21%" == "yes" call :do21
  186. if "%do22%" == "yes" call :do22
  187. if "%do23%" == "yes" call :do23
  188. :modeSkip
  189. if "%mode%" == "" (
  190. set mode=-16
  191. set bits=16
  192. goto nextMode
  193. )
  194. if "%mode%" == "-16" (
  195. set mode=-32
  196. set bits=32
  197. goto nextMode
  198. )
  199. @rem If mode is -32, testing is finished
  200. if %failed% == "yes" (
  201. echo In above output, one or more of the various tests failed!
  202. exit /b 1
  203. )
  204. echo All OK
  205. goto :eof
  206. :runsub
  207. @rem Function to execute pcre2test and compare the output
  208. @rem Arguments are as follows:
  209. @rem
  210. @rem 1 = test number
  211. @rem 2 = outputdir
  212. @rem 3 = test name use double quotes
  213. @rem 4 - 9 = pcre2test options
  214. if [%1] == [] (
  215. echo Missing test number argument!
  216. exit /b 1
  217. )
  218. if [%2] == [] (
  219. echo Missing outputdir!
  220. exit /b 1
  221. )
  222. if [%3] == [] (
  223. echo Missing test name argument!
  224. exit /b 1
  225. )
  226. if %1 == 8 (
  227. set outnum=8-%bits%-%link_size%
  228. ) else (
  229. set outnum=%1
  230. )
  231. set testinput=testinput%1
  232. set testoutput=testoutput%outnum%
  233. if exist %srcdir%\testdata\win%testinput% (
  234. set testinput=wintestinput%1
  235. set testoutput=wintestoutput%outnum%
  236. )
  237. echo Test %1: %3
  238. %pcre2test% %mode% %4 %5 %6 %7 %8 %9 %srcdir%\testdata\%testinput% >%2%bits%\%testoutput%
  239. if errorlevel 1 (
  240. echo. failed executing command-line:
  241. echo. %pcre2test% %mode% %4 %5 %6 %7 %8 %9 %srcdir%\testdata\%testinput% ^>%2%bits%\%testoutput%
  242. set failed="yes"
  243. goto :eof
  244. ) else if [%1]==[2] (
  245. %pcre2test% %mode% %4 %5 %6 %7 %8 %9 -error -70,-62,-2,-1,0,100,101,191,200 >>%2%bits%\%testoutput%
  246. )
  247. set type=
  248. if [%1]==[11] (
  249. set type=-%bits%
  250. )
  251. if [%1]==[12] (
  252. set type=-%bits%
  253. )
  254. if [%1]==[14] (
  255. set type=-%bits%
  256. )
  257. if [%1]==[22] (
  258. set type=-%bits%
  259. )
  260. fc /n %srcdir%\testdata\%testoutput%%type% %2%bits%\%testoutput% >NUL
  261. if errorlevel 1 (
  262. echo. failed comparison: fc /n %srcdir%\testdata\%testoutput% %2%bits%\%testoutput%
  263. if [%1]==[3] (
  264. echo.
  265. echo ** Test 3 failure usually means french locale is not
  266. echo ** available on the system, rather than a bug or problem with PCRE2.
  267. echo.
  268. goto :eof
  269. )
  270. set failed="yes"
  271. goto :eof
  272. )
  273. echo. Passed.
  274. goto :eof
  275. :do1
  276. call :runsub 1 testout "Main non-UTF, non-UCP functionality (Compatible with Perl >= 5.10)" -q
  277. if %jit% EQU 1 call :runsub 1 testoutjit "Test with JIT Override" -q -jit
  278. goto :eof
  279. :do2
  280. copy /y %srcdir%\testdata\testbtables testbtables
  281. call :runsub 2 testout "API, errors, internals, and non-Perl stuff" -q
  282. if %jit% EQU 1 call :runsub 2 testoutjit "Test with JIT Override" -q -jit
  283. goto :eof
  284. :do3
  285. call :runsub 3 testout "Locale-specific features" -q
  286. if %jit% EQU 1 call :runsub 3 testoutjit "Test with JIT Override" -q -jit
  287. goto :eof
  288. :do4
  289. if %unicode% EQU 0 (
  290. echo Test 4 Skipped due to absence of Unicode support.
  291. goto :eof
  292. )
  293. call :runsub 4 testout "UTF-%bits% and Unicode property support - (Compatible with Perl >= 5.10)" -q
  294. if %jit% EQU 1 call :runsub 4 testoutjit "Test with JIT Override" -q -jit
  295. goto :eof
  296. :do5
  297. if %unicode% EQU 0 (
  298. echo Test 5 Skipped due to absence of Unicode support.
  299. goto :eof
  300. )
  301. call :runsub 5 testout "API, internals, and non-Perl stuff for UTF-%bits% and UCP" -q
  302. if %jit% EQU 1 call :runsub 5 testoutjit "Test with JIT Override" -q -jit
  303. goto :eof
  304. :do6
  305. call :runsub 6 testout "DFA matching main non-UTF, non-UCP functionality" -q
  306. goto :eof
  307. :do7
  308. if %unicode% EQU 0 (
  309. echo Test 7 Skipped due to absence of Unicode support.
  310. goto :eof
  311. )
  312. call :runsub 7 testout "DFA matching with UTF-%bits% and Unicode property support" -q
  313. goto :eof
  314. :do8
  315. if NOT %link_size% EQU 2 (
  316. echo Test 8 Skipped because link size is not 2.
  317. goto :eof
  318. )
  319. if %unicode% EQU 0 (
  320. echo Test 8 Skipped due to absence of Unicode support.
  321. goto :eof
  322. )
  323. call :runsub 8 testout "Internal offsets and code size tests" -q
  324. goto :eof
  325. :do9
  326. if NOT %bits% EQU 8 (
  327. echo Test 9 Skipped when running 16/32-bit tests.
  328. goto :eof
  329. )
  330. call :runsub 9 testout "Specials for the basic 8-bit library" -q
  331. if %jit% EQU 1 call :runsub 9 testoutjit "Test with JIT Override" -q -jit
  332. goto :eof
  333. :do10
  334. if NOT %bits% EQU 8 (
  335. echo Test 10 Skipped when running 16/32-bit tests.
  336. goto :eof
  337. )
  338. if %unicode% EQU 0 (
  339. echo Test 10 Skipped due to absence of Unicode support.
  340. goto :eof
  341. )
  342. call :runsub 10 testout "Specials for the 8-bit library with Unicode support" -q
  343. if %jit% EQU 1 call :runsub 10 testoutjit "Test with JIT Override" -q -jit
  344. goto :eof
  345. :do11
  346. if %bits% EQU 8 (
  347. echo Test 11 Skipped when running 8-bit tests.
  348. goto :eof
  349. )
  350. call :runsub 11 testout "Specials for the basic 16/32-bit library" -q
  351. if %jit% EQU 1 call :runsub 11 testoutjit "Test with JIT Override" -q -jit
  352. goto :eof
  353. :do12
  354. if %bits% EQU 8 (
  355. echo Test 12 Skipped when running 8-bit tests.
  356. goto :eof
  357. )
  358. if %unicode% EQU 0 (
  359. echo Test 12 Skipped due to absence of Unicode support.
  360. goto :eof
  361. )
  362. call :runsub 12 testout "Specials for the 16/32-bit library with Unicode support" -q
  363. if %jit% EQU 1 call :runsub 12 testoutjit "Test with JIT Override" -q -jit
  364. goto :eof
  365. :do13
  366. if %bits% EQU 8 (
  367. echo Test 13 Skipped when running 8-bit tests.
  368. goto :eof
  369. )
  370. call :runsub 13 testout "DFA specials for the basic 16/32-bit library" -q
  371. goto :eof
  372. :do14
  373. if %unicode% EQU 0 (
  374. echo Test 14 Skipped due to absence of Unicode support.
  375. goto :eof
  376. )
  377. call :runsub 14 testout "DFA specials for UTF and UCP support" -q
  378. goto :eof
  379. :do15
  380. call :runsub 15 testout "Non-JIT limits and other non_JIT tests" -q
  381. goto :eof
  382. :do16
  383. if %jit% EQU 1 (
  384. echo Test 16 Skipped due to presence of JIT support.
  385. goto :eof
  386. )
  387. call :runsub 16 testout "JIT-specific features when JIT is not available" -q
  388. goto :eof
  389. :do17
  390. if %jit% EQU 0 (
  391. echo Test 17 Skipped due to absence of JIT support.
  392. goto :eof
  393. )
  394. call :runsub 17 testout "JIT-specific features when JIT is available" -q
  395. goto :eof
  396. :do18
  397. if %bits% EQU 16 (
  398. echo Test 18 Skipped when running 16-bit tests.
  399. goto :eof
  400. )
  401. if %bits% EQU 32 (
  402. echo Test 18 Skipped when running 32-bit tests.
  403. goto :eof
  404. )
  405. call :runsub 18 testout "POSIX interface, excluding UTF-8 and UCP" -q
  406. goto :eof
  407. :do19
  408. if %bits% EQU 16 (
  409. echo Test 19 Skipped when running 16-bit tests.
  410. goto :eof
  411. )
  412. if %bits% EQU 32 (
  413. echo Test 19 Skipped when running 32-bit tests.
  414. goto :eof
  415. )
  416. if %unicode% EQU 0 (
  417. echo Test 19 Skipped due to absence of Unicode support.
  418. goto :eof
  419. )
  420. call :runsub 19 testout "POSIX interface with UTF-8 and UCP" -q
  421. goto :eof
  422. :do20
  423. call :runsub 20 testout "Serialization tests" -q
  424. goto :eof
  425. :do21
  426. if %supportBSC% EQU 0 (
  427. echo Test 21 Skipped due to absence of backslash-C support.
  428. goto :eof
  429. )
  430. call :runsub 21 testout "Backslash-C tests without UTF" -q
  431. call :runsub 21 testout "Backslash-C tests without UTF (DFA)" -q -dfa
  432. if %jit% EQU 1 call :runsub 21 testoutjit "Test with JIT Override" -q -jit
  433. goto :eof
  434. :do22
  435. if %supportBSC% EQU 0 (
  436. echo Test 22 Skipped due to absence of backslash-C support.
  437. goto :eof
  438. )
  439. if %unicode% EQU 0 (
  440. echo Test 22 Skipped due to absence of Unicode support.
  441. goto :eof
  442. )
  443. call :runsub 22 testout "Backslash-C tests with UTF" -q
  444. if %jit% EQU 1 call :runsub 22 testoutjit "Test with JIT Override" -q -jit
  445. goto :eof
  446. :do23
  447. if %supportBSC% EQU 1 (
  448. echo Test 23 Skipped due to presence of backslash-C support.
  449. goto :eof
  450. )
  451. call :runsub 23 testout "Backslash-C disabled test" -q
  452. goto :eof
  453. :conferror
  454. @echo.
  455. @echo Either your build is incomplete or you have a configuration error.
  456. @echo.
  457. @echo If configured with cmake and executed via "make test" or the MSVC "RUN_TESTS"
  458. @echo project, pcre2_test.bat defines variables and automatically calls RunTest.bat.
  459. @echo For manual testing of all available features, after configuring with cmake
  460. @echo and building, you can run the built pcre2_test.bat. For best results with
  461. @echo cmake builds and tests avoid directories with full path names that include
  462. @echo spaces for source or build.
  463. @echo.
  464. @echo Otherwise, if the build dir is in a subdir of the source dir, testdata needed
  465. @echo for input and verification should be found automatically when (from the
  466. @echo location of the the built exes) you call RunTest.bat. By default RunTest.bat
  467. @echo runs all tests compatible with the linked pcre2 library but it can be given
  468. @echo a test number as an argument.
  469. @echo.
  470. @echo If the build dir is not under the source dir you can either copy your exes
  471. @echo to the source folder or copy RunTest.bat and the testdata folder to the
  472. @echo location of your built exes and then run RunTest.bat.
  473. @echo.
  474. goto :eof