1@echo off 2@rem This file must use CRLF linebreaks to function properly 3@rem and requires both pcretest and pcregrep 4@rem This file was originally contributed by Ralf Junker, and touched up by 5@rem Daniel Richard G. Tests 10-12 added by Philip H. 6@rem Philip H also changed test 3 to use "wintest" files. 7@rem 8@rem Updated by Tom Fortmann to support explicit test numbers on the command line. 9@rem Added argument validation and added error reporting. 10@rem 11@rem MS Windows batch file to run pcretest on testfiles with the correct 12@rem options. 13@rem 14@rem Sheri Pierce added logic to skip feature dependent tests 15@rem tests 4 5 9 15 and 18 require utf support 16@rem tests 6 7 10 16 and 19 require ucp support 17@rem 11 requires ucp and link size 2 18@rem 12 requires presence of jit support 19@rem 13 requires absence 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 24setlocal enabledelayedexpansion 25if [%srcdir%]==[] ( 26if exist testdata\ set srcdir=.) 27if [%srcdir%]==[] ( 28if exist ..\testdata\ set srcdir=..) 29if [%srcdir%]==[] ( 30if exist ..\..\testdata\ set srcdir=..\..) 31if NOT exist %srcdir%\testdata\ ( 32Error: echo distribution testdata folder not found! 33call :conferror 34exit /b 1 35goto :eof 36) 37 38if [%pcretest%]==[] set pcretest=.\pcretest.exe 39 40echo source dir is %srcdir% 41echo pcretest=%pcretest% 42 43if NOT exist %pcretest% ( 44echo Error: %pcretest% not found! 45echo. 46call :conferror 47exit /b 1 48) 49 50%pcretest% -C linksize >NUL 51set link_size=%ERRORLEVEL% 52%pcretest% -C pcre8 >NUL 53set support8=%ERRORLEVEL% 54%pcretest% -C pcre16 >NUL 55set support16=%ERRORLEVEL% 56%pcretest% -C pcre32 >NUL 57set support32=%ERRORLEVEL% 58%pcretest% -C utf >NUL 59set utf=%ERRORLEVEL% 60%pcretest% -C ucp >NUL 61set ucp=%ERRORLEVEL% 62%pcretest% -C jit >NUL 63set jit=%ERRORLEVEL% 64 65if %support8% EQU 1 ( 66if not exist testout8 md testout8 67if not exist testoutstudy8 md testoutstudy8 68if not exist testoutjit8 md testoutjit8 69) 70 71if %support16% EQU 1 ( 72if not exist testout16 md testout16 73if not exist testoutstudy16 md testoutstudy16 74if not exist testoutjit16 md testoutjit16 75) 76 77if %support16% EQU 1 ( 78if not exist testout32 md testout32 79if not exist testoutstudy32 md testoutstudy32 80if not exist testoutjit32 md testoutjit32 81) 82 83set do1=no 84set do2=no 85set do3=no 86set do4=no 87set do5=no 88set do6=no 89set do7=no 90set do8=no 91set do9=no 92set do10=no 93set do11=no 94set do12=no 95set do13=no 96set do14=no 97set do15=no 98set do16=no 99set do17=no 100set do18=no 101set do19=no 102set do20=no 103set do21=no 104set do22=no 105set do23=no 106set do24=no 107set do25=no 108set do26=no 109set all=yes 110 111for %%a in (%*) do ( 112 set valid=no 113 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 24 25 26) do if %%v == %%a set valid=yes 114 if "!valid!" == "yes" ( 115 set do%%a=yes 116 set all=no 117) else ( 118 echo Invalid test number - %%a! 119 echo Usage %0 [ test_number ] ... 120 echo Where test_number is one or more optional test numbers 1 through 26, default is all tests. 121 exit /b 1 122) 123) 124set failed="no" 125 126if "%all%" == "yes" ( 127 set do1=yes 128 set do2=yes 129 set do3=yes 130 set do4=yes 131 set do5=yes 132 set do6=yes 133 set do7=yes 134 set do8=yes 135 set do9=yes 136 set do10=yes 137 set do11=yes 138 set do12=yes 139 set do13=yes 140 set do14=yes 141 set do15=yes 142 set do16=yes 143 set do17=yes 144 set do18=yes 145 set do19=yes 146 set do20=yes 147 set do21=yes 148 set do22=yes 149 set do23=yes 150 set do24=yes 151 set do25=yes 152 set do26=yes 153) 154 155@echo RunTest.bat's pcretest output is written to newly created subfolders named 156@echo testout, testoutstudy and testoutjit. 157@echo. 158 159set mode= 160set bits=8 161 162:nextMode 163if "%mode%" == "" ( 164 if %support8% EQU 0 goto modeSkip 165 echo. 166 echo ---- Testing 8-bit library ---- 167 echo. 168) 169if "%mode%" == "-16" ( 170 if %support16% EQU 0 goto modeSkip 171 echo. 172 echo ---- Testing 16-bit library ---- 173 echo. 174) 175if "%mode%" == "-32" ( 176 if %support32% EQU 0 goto modeSkip 177 echo. 178 echo ---- Testing 32-bit library ---- 179 echo. 180) 181if "%do1%" == "yes" call :do1 182if "%do2%" == "yes" call :do2 183if "%do3%" == "yes" call :do3 184if "%do4%" == "yes" call :do4 185if "%do5%" == "yes" call :do5 186if "%do6%" == "yes" call :do6 187if "%do7%" == "yes" call :do7 188if "%do8%" == "yes" call :do8 189if "%do9%" == "yes" call :do9 190if "%do10%" == "yes" call :do10 191if "%do11%" == "yes" call :do11 192if "%do12%" == "yes" call :do12 193if "%do13%" == "yes" call :do13 194if "%do14%" == "yes" call :do14 195if "%do15%" == "yes" call :do15 196if "%do16%" == "yes" call :do16 197if "%do17%" == "yes" call :do17 198if "%do18%" == "yes" call :do18 199if "%do19%" == "yes" call :do19 200if "%do20%" == "yes" call :do20 201if "%do21%" == "yes" call :do21 202if "%do22%" == "yes" call :do22 203if "%do23%" == "yes" call :do23 204if "%do24%" == "yes" call :do24 205if "%do25%" == "yes" call :do25 206if "%do26%" == "yes" call :do26 207:modeSkip 208if "%mode%" == "" ( 209 set mode=-16 210 set bits=16 211 goto nextMode 212) 213if "%mode%" == "-16" ( 214 set mode=-32 215 set bits=32 216 goto nextMode 217) 218 219@rem If mode is -32, testing is finished 220if %failed% == "yes" ( 221echo In above output, one or more of the various tests failed! 222exit /b 1 223) 224echo All OK 225goto :eof 226 227:runsub 228@rem Function to execute pcretest and compare the output 229@rem Arguments are as follows: 230@rem 231@rem 1 = test number 232@rem 2 = outputdir 233@rem 3 = test name use double quotes 234@rem 4 - 9 = pcretest options 235 236if [%1] == [] ( 237 echo Missing test number argument! 238 exit /b 1 239) 240 241if [%2] == [] ( 242 echo Missing outputdir! 243 exit /b 1 244) 245 246if [%3] == [] ( 247 echo Missing test name argument! 248 exit /b 1 249) 250 251set testinput=testinput%1 252set testoutput=testoutput%1 253if exist %srcdir%\testdata\win%testinput% ( 254 set testinput=wintestinput%1 255 set testoutput=wintestoutput%1 256) 257 258echo Test %1: %3 259%pcretest% %mode% %4 %5 %6 %7 %8 %9 %srcdir%\testdata\%testinput% >%2%bits%\%testoutput% 260if errorlevel 1 ( 261 echo. failed executing command-line: 262 echo. %pcretest% %mode% %4 %5 %6 %7 %8 %9 %srcdir%\testdata\%testinput% ^>%2%bits%\%testoutput% 263 set failed="yes" 264 goto :eof 265) 266 267set type= 268if [%1]==[11] ( 269 set type=-%bits% 270) 271if [%1]==[18] ( 272 set type=-%bits% 273) 274if [%1]==[21] ( 275 set type=-%bits% 276) 277if [%1]==[22] ( 278 set type=-%bits% 279) 280 281fc /n %srcdir%\testdata\%testoutput%%type% %2%bits%\%testoutput% >NUL 282 283if errorlevel 1 ( 284 echo. failed comparison: fc /n %srcdir%\testdata\%testoutput% %2%bits%\%testoutput% 285 if [%1]==[2] ( 286 echo. 287 echo ** Test 2 requires a lot of stack. PCRE can be configured to 288 echo ** use heap for recursion. Otherwise, to pass Test 2 289 echo ** you generally need to allocate 8 mb stack to PCRE. 290 echo ** See the 'pcrestack' page for a discussion of PCRE's 291 echo ** stack usage. 292 echo. 293) 294 if [%1]==[3] ( 295 echo. 296 echo ** Test 3 failure usually means french locale is not 297 echo ** available on the system, rather than a bug or problem with PCRE. 298 echo. 299 goto :eof 300) 301 302 set failed="yes" 303 goto :eof 304) 305 306echo. Passed. 307goto :eof 308 309:do1 310call :runsub 1 testout "Main functionality (Compatible with Perl >= 5.10)" -q 311call :runsub 1 testoutstudy "Test with Study Override" -q -s 312if %jit% EQU 1 call :runsub 1 testoutjit "Test with JIT Override" -q -s+ 313goto :eof 314 315:do2 316 call :runsub 2 testout "API, errors, internals, and non-Perl stuff" -q 317 call :runsub 2 testoutstudy "Test with Study Override" -q -s 318 if %jit% EQU 1 call :runsub 2 testoutjit "Test with JIT Override" -q -s+ 319goto :eof 320 321:do3 322 call :runsub 3 testout "Locale-specific features" -q 323 call :runsub 3 testoutstudy "Test with Study Override" -q -s 324 if %jit% EQU 1 call :runsub 3 testoutjit "Test with JIT Override" -q -s+ 325goto :eof 326 327:do4 328if %utf% EQU 0 ( 329 echo Test 4 Skipped due to absence of UTF-%bits% support. 330 goto :eof 331) 332 call :runsub 4 testout "UTF-%bits% support - (Compatible with Perl >= 5.10)" -q 333 call :runsub 4 testoutstudy "Test with Study Override" -q -s 334 if %jit% EQU 1 call :runsub 4 testoutjit "Test with JIT Override" -q -s+ 335goto :eof 336 337:do5 338if %utf% EQU 0 ( 339 echo Test 5 Skipped due to absence of UTF-%bits% support. 340 goto :eof 341) 342 call :runsub 5 testout "API, internals, and non-Perl stuff for UTF-%bits%" -q 343 call :runsub 5 testoutstudy "Test with Study Override" -q -s 344 if %jit% EQU 1 call :runsub 5 testoutjit "Test with JIT Override" -q -s+ 345goto :eof 346 347:do6 348if %ucp% EQU 0 ( 349 echo Test 6 Skipped due to absence of Unicode property support. 350 goto :eof 351) 352 call :runsub 6 testout "Unicode property support (Compatible with Perl >= 5.10)" -q 353 call :runsub 6 testoutstudy "Test with Study Override" -q -s 354 if %jit% EQU 1 call :runsub 6 testoutjit "Test with JIT Override" -q -s+ 355goto :eof 356 357:do7 358if %ucp% EQU 0 ( 359 echo Test 7 Skipped due to absence of Unicode property support. 360 goto :eof 361) 362 call :runsub 7 testout "API, internals, and non-Perl stuff for Unicode property support" -q 363 call :runsub 7 testoutstudy "Test with Study Override" -q -s 364 if %jit% EQU 1 call :runsub 7 testoutjit "Test with JIT Override" -q -s+ 365goto :eof 366 367:do8 368 call :runsub 8 testout "DFA matching main functionality" -q -dfa 369 call :runsub 8 testoutstudy "Test with Study Override" -q -dfa -s 370goto :eof 371 372:do9 373if %utf% EQU 0 ( 374 echo Test 9 Skipped due to absence of UTF-%bits% support. 375 goto :eof 376) 377 call :runsub 9 testout "DFA matching with UTF-%bits%" -q -dfa 378 call :runsub 9 testoutstudy "Test with Study Override" -q -dfa -s 379 goto :eof 380 381:do10 382if %ucp% EQU 0 ( 383 echo Test 10 Skipped due to absence of Unicode property support. 384 goto :eof 385) 386 call :runsub 10 testout "DFA matching with Unicode properties" -q -dfa 387 call :runsub 10 testoutstudy "Test with Study Override" -q -dfa -s 388goto :eof 389 390:do11 391if NOT %link_size% EQU 2 ( 392 echo Test 11 Skipped because link size is not 2. 393 goto :eof 394) 395if %ucp% EQU 0 ( 396 echo Test 11 Skipped due to absence of Unicode property support. 397 goto :eof 398) 399 call :runsub 11 testout "Internal offsets and code size tests" -q 400 call :runsub 11 testoutstudy "Test with Study Override" -q -s 401goto :eof 402 403:do12 404if %jit% EQU 0 ( 405 echo Test 12 Skipped due to absence of JIT support. 406 goto :eof 407) 408 call :runsub 12 testout "JIT-specific features (JIT available)" -q 409goto :eof 410 411:do13 412if %jit% EQU 1 ( 413 echo Test 13 Skipped due to presence of JIT support. 414 goto :eof 415) 416 call :runsub 13 testout "JIT-specific features (JIT not available)" -q 417goto :eof 418 419:do14 420if NOT %bits% EQU 8 ( 421 echo Test 14 Skipped when running 16/32-bit tests. 422 goto :eof 423) 424 copy /Y %srcdir%\testdata\saved16 testsaved16 425 copy /Y %srcdir%\testdata\saved32 testsaved32 426 call :runsub 14 testout "Specials for the basic 8-bit library" -q 427 call :runsub 14 testoutstudy "Test with Study Override" -q -s 428 if %jit% EQU 1 call :runsub 14 testoutjit "Test with JIT Override" -q -s+ 429goto :eof 430 431:do15 432if NOT %bits% EQU 8 ( 433 echo Test 15 Skipped when running 16/32-bit tests. 434 goto :eof 435) 436if %utf% EQU 0 ( 437 echo Test 15 Skipped due to absence of UTF-%bits% support. 438 goto :eof 439) 440 call :runsub 15 testout "Specials for the 8-bit library with UTF-%bits% support" -q 441 call :runsub 15 testoutstudy "Test with Study Override" -q -s 442 if %jit% EQU 1 call :runsub 15 testoutjit "Test with JIT Override" -q -s+ 443goto :eof 444 445:do16 446if NOT %bits% EQU 8 ( 447 echo Test 16 Skipped when running 16/32-bit tests. 448 goto :eof 449) 450if %ucp% EQU 0 ( 451 echo Test 16 Skipped due to absence of Unicode property support. 452 goto :eof 453) 454 call :runsub 16 testout "Specials for the 8-bit library with Unicode propery support" -q 455 call :runsub 16 testoutstudy "Test with Study Override" -q -s 456 if %jit% EQU 1 call :runsub 16 testoutjit "Test with JIT Override" -q -s+ 457goto :eof 458 459:do17 460if %bits% EQU 8 ( 461 echo Test 17 Skipped when running 8-bit tests. 462 goto :eof 463) 464 call :runsub 17 testout "Specials for the basic 16/32-bit library" -q 465 call :runsub 17 testoutstudy "Test with Study Override" -q -s 466 if %jit% EQU 1 call :runsub 17 testoutjit "Test with JIT Override" -q -s+ 467goto :eof 468 469:do18 470if %bits% EQU 8 ( 471 echo Test 18 Skipped when running 8-bit tests. 472 goto :eof 473) 474if %utf% EQU 0 ( 475 echo Test 18 Skipped due to absence of UTF-%bits% support. 476 goto :eof 477) 478 call :runsub 18 testout "Specials for the 16/32-bit library with UTF-%bits% support" -q 479 call :runsub 18 testoutstudy "Test with Study Override" -q -s 480 if %jit% EQU 1 call :runsub 18 testoutjit "Test with JIT Override" -q -s+ 481goto :eof 482 483:do19 484if %bits% EQU 8 ( 485 echo Test 19 Skipped when running 8-bit tests. 486 goto :eof 487) 488if %ucp% EQU 0 ( 489 echo Test 19 Skipped due to absence of Unicode property support. 490 goto :eof 491) 492 call :runsub 19 testout "Specials for the 16/32-bit library with Unicode property support" -q 493 call :runsub 19 testoutstudy "Test with Study Override" -q -s 494 if %jit% EQU 1 call :runsub 19 testoutjit "Test with JIT Override" -q -s+ 495goto :eof 496 497:do20 498if %bits% EQU 8 ( 499 echo Test 20 Skipped when running 8-bit tests. 500 goto :eof 501) 502 call :runsub 20 testout "DFA specials for the basic 16/32-bit library" -q -dfa 503 call :runsub 20 testoutstudy "Test with Study Override" -q -dfa -s 504goto :eof 505 506:do21 507if %bits% EQU 8 ( 508 echo Test 21 Skipped when running 8-bit tests. 509 goto :eof 510) 511if NOT %link_size% EQU 2 ( 512 echo Test 21 Skipped because link size is not 2. 513 goto :eof 514) 515copy /Y %srcdir%\testdata\saved8 testsaved8 516copy /Y %srcdir%\testdata\saved16LE-1 testsaved16LE-1 517copy /Y %srcdir%\testdata\saved16BE-1 testsaved16BE-1 518copy /Y %srcdir%\testdata\saved32LE-1 testsaved32LE-1 519copy /Y %srcdir%\testdata\saved32BE-1 testsaved32BE-1 520call :runsub 21 testout "Reloads for the basic 16/32-bit library" -q 521call :runsub 21 testoutstudy "Test with Study Override" -q -s 522if %jit% EQU 1 call :runsub 21 testoutjit "Test with JIT Override" -q -s+ 523goto :eof 524 525:do22 526if %bits% EQU 8 ( 527 echo Test 22 Skipped when running 8-bit tests. 528 goto :eof 529) 530if %utf% EQU 0 ( 531 echo Test 22 Skipped due to absence of UTF-%bits% support. 532 goto :eof 533) 534if NOT %link_size% EQU 2 ( 535 echo Test 22 Skipped because link size is not 2. 536 goto :eof 537) 538copy /Y %srcdir%\testdata\saved16LE-2 testsaved16LE-2 539copy /Y %srcdir%\testdata\saved16BE-2 testsaved16BE-2 540copy /Y %srcdir%\testdata\saved32LE-2 testsaved32LE-2 541copy /Y %srcdir%\testdata\saved32BE-2 testsaved32BE-2 542call :runsub 22 testout "Reloads for the 16/32-bit library with UTF-16/32 support" -q 543call :runsub 22 testoutstudy "Test with Study Override" -q -s 544if %jit% EQU 1 call :runsub 22 testoutjit "Test with JIT Override" -q -s+ 545goto :eof 546 547:do23 548if NOT %bits% EQU 16 ( 549 echo Test 23 Skipped when running 8/32-bit tests. 550 goto :eof 551) 552call :runsub 23 testout "Specials for the 16-bit library" -q 553call :runsub 23 testoutstudy "Test with Study Override" -q -s 554if %jit% EQU 1 call :runsub 23 testoutjit "Test with JIT Override" -q -s+ 555goto :eof 556 557:do24 558if NOT %bits% EQU 16 ( 559 echo Test 24 Skipped when running 8/32-bit tests. 560 goto :eof 561) 562if %utf% EQU 0 ( 563 echo Test 24 Skipped due to absence of UTF-%bits% support. 564 goto :eof 565) 566call :runsub 24 testout "Specials for the 16-bit library with UTF-16 support" -q 567call :runsub 24 testoutstudy "Test with Study Override" -q -s 568if %jit% EQU 1 call :runsub 24 testoutjit "Test with JIT Override" -q -s+ 569goto :eof 570 571:do25 572if NOT %bits% EQU 32 ( 573 echo Test 25 Skipped when running 8/16-bit tests. 574 goto :eof 575) 576call :runsub 25 testout "Specials for the 32-bit library" -q 577call :runsub 25 testoutstudy "Test with Study Override" -q -s 578if %jit% EQU 1 call :runsub 25 testoutjit "Test with JIT Override" -q -s+ 579goto :eof 580 581:do26 582if NOT %bits% EQU 32 ( 583 echo Test 26 Skipped when running 8/16-bit tests. 584 goto :eof 585) 586if %utf% EQU 0 ( 587 echo Test 26 Skipped due to absence of UTF-%bits% support. 588 goto :eof 589) 590call :runsub 26 testout "Specials for the 32-bit library with UTF-32 support" -q 591call :runsub 26 testoutstudy "Test with Study Override" -q -s 592if %jit% EQU 1 call :runsub 26 testoutjit "Test with JIT Override" -q -s+ 593goto :eof 594 595:conferror 596@echo. 597@echo Either your build is incomplete or you have a configuration error. 598@echo. 599@echo If configured with cmake and executed via "make test" or the MSVC "RUN_TESTS" 600@echo project, pcre_test.bat defines variables and automatically calls RunTest.bat. 601@echo For manual testing of all available features, after configuring with cmake 602@echo and building, you can run the built pcre_test.bat. For best results with 603@echo cmake builds and tests avoid directories with full path names that include 604@echo spaces for source or build. 605@echo. 606@echo Otherwise, if the build dir is in a subdir of the source dir, testdata needed 607@echo for input and verification should be found automatically when (from the 608@echo location of the the built exes) you call RunTest.bat. By default RunTest.bat 609@echo runs all tests compatible with the linked pcre library but it can be given 610@echo a test number as an argument. 611@echo. 612@echo If the build dir is not under the source dir you can either copy your exes 613@echo to the source folder or copy RunTest.bat and the testdata folder to the 614@echo location of your built exes and then run RunTest.bat. 615@echo. 616goto :eof 617