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