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