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.
8 @rem Updated by Tom Fortmann to support explicit test numbers on the command line.
9 @rem Added argument validation and added error reporting.
11 @rem MS Windows batch file to run pcretest on testfiles with the correct
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 presense 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
24 setlocal enabledelayedexpansion
26 if exist testdata\ set srcdir=.)
28 if exist ..\testdata\ set srcdir=..)
30 if exist ..\..\testdata\ set srcdir=..\..)
31 if NOT exist %srcdir%\testdata\ (
32 Error: echo distribution testdata folder not found!
38 if [%pcretest%]==[] set pcretest=.\pcretest.exe
40 echo source dir is %srcdir%
41 echo pcretest=%pcretest%
43 if NOT exist %pcretest% (
44 echo Error: %pcretest% not found!
50 %pcretest% -C linksize >NUL
51 set link_size=%ERRORLEVEL%
52 %pcretest% -C pcre8 >NUL
53 set support8=%ERRORLEVEL%
54 %pcretest% -C pcre16 >NUL
55 set support16=%ERRORLEVEL%
56 %pcretest% -C pcre32 >NUL
57 set support32=%ERRORLEVEL%
58 %pcretest% -C utf >NUL
60 %pcretest% -C ucp >NUL
62 %pcretest% -C jit >NUL
66 if not exist testout8 md testout8
67 if not exist testoutstudy8 md testoutstudy8
68 if not exist testoutjit8 md testoutjit8
71 if %support16% EQU 1 (
72 if not exist testout16 md testout16
73 if not exist testoutstudy16 md testoutstudy16
74 if not exist testoutjit16 md testoutjit16
77 if %support16% EQU 1 (
78 if not exist testout32 md testout32
79 if not exist testoutstudy32 md testoutstudy32
80 if not exist testoutjit32 md testoutjit32
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" (
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.
126 if "%all%" == "yes" (
155 @echo RunTest.bat's pcretest output is written to newly created subfolders named
156 @echo testout, testoutstudy and testoutjit.
164 if %support8% EQU 0 goto modeSkip
166 echo ---- Testing 8-bit library ----
169 if "%mode%" == "-16" (
170 if %support16% EQU 0 goto modeSkip
172 echo ---- Testing 16-bit library ----
175 if "%mode%" == "-32" (
176 if %support32% EQU 0 goto modeSkip
178 echo ---- Testing 32-bit library ----
181 if "%do1%" == "yes" call :do1
182 if "%do2%" == "yes" call :do2
183 if "%do3%" == "yes" call :do3
184 if "%do4%" == "yes" call :do4
185 if "%do5%" == "yes" call :do5
186 if "%do6%" == "yes" call :do6
187 if "%do7%" == "yes" call :do7
188 if "%do8%" == "yes" call :do8
189 if "%do9%" == "yes" call :do9
190 if "%do10%" == "yes" call :do10
191 if "%do11%" == "yes" call :do11
192 if "%do12%" == "yes" call :do12
193 if "%do13%" == "yes" call :do13
194 if "%do14%" == "yes" call :do14
195 if "%do15%" == "yes" call :do15
196 if "%do16%" == "yes" call :do16
197 if "%do17%" == "yes" call :do17
198 if "%do18%" == "yes" call :do18
199 if "%do19%" == "yes" call :do19
200 if "%do20%" == "yes" call :do20
201 if "%do21%" == "yes" call :do21
202 if "%do22%" == "yes" call :do22
203 if "%do23%" == "yes" call :do23
204 if "%do24%" == "yes" call :do24
205 if "%do25%" == "yes" call :do25
206 if "%do26%" == "yes" call :do26
213 if "%mode%" == "-16" (
219 @rem If mode is -32, testing is finished
220 if %failed% == "yes" (
221 echo In above output, one or more of the various tests failed!
228 @rem Function to execute pcretest and compare the output
229 @rem Arguments are as follows:
233 @rem 3 = test name use double quotes
234 @rem 4 - 9 = pcretest options
237 echo Missing test number argument!
242 echo Missing outputdir!
247 echo Missing test name argument!
251 set testinput=testinput%1
252 set testoutput=testoutput%1
253 if exist %srcdir%\testdata\win%testinput% (
254 set testinput=wintestinput%1
255 set testoutput=wintestoutput%1
259 %pcretest% %mode% %4 %5 %6 %7 %8 %9 %srcdir%\testdata\%testinput% >%2%bits%\%testoutput%
261 echo. failed executing command-line:
262 echo. %pcretest% %mode% %4 %5 %6 %7 %8 %9 %srcdir%\testdata\%testinput% ^>%2%bits%\%testoutput%
281 fc /n %srcdir%\testdata\%testoutput%%type% %2%bits%\%testoutput% >NUL
284 echo. failed comparison: fc /n %srcdir%\testdata\%testoutput% %2%bits%\%testoutput%
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
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.
310 call :runsub 1 testout "Main functionality (Compatible with Perl >= 5.10)" -q
311 call :runsub 1 testoutstudy "Test with Study Override" -q -s
312 if %jit% EQU 1 call :runsub 1 testoutjit "Test with JIT Override" -q -s+
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+
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+
329 echo Test 4 Skipped due to absence of UTF-%bits% support.
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+
339 echo Test 5 Skipped due to absence of UTF-%bits% support.
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+
349 echo Test 6 Skipped due to absence of Unicode property support.
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+
359 echo Test 7 Skipped due to absence of Unicode property support.
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+
368 call :runsub 8 testout "DFA matching main functionality" -q -dfa
369 call :runsub 8 testoutstudy "Test with Study Override" -q -dfa -s
374 echo Test 9 Skipped due to absence of UTF-%bits% support.
377 call :runsub 9 testout "DFA matching with UTF-%bits%" -q -dfa
378 call :runsub 9 testoutstudy "Test with Study Override" -q -dfa -s
383 echo Test 10 Skipped due to absence of Unicode property support.
386 call :runsub 10 testout "DFA matching with Unicode properties" -q -dfa
387 call :runsub 10 testoutstudy "Test with Study Override" -q -dfa -s
391 if NOT %link_size% EQU 2 (
392 echo Test 11 Skipped because link size is not 2.
396 echo Test 11 Skipped due to absence of Unicode property support.
399 call :runsub 11 testout "Internal offsets and code size tests" -q
400 call :runsub 11 testoutstudy "Test with Study Override" -q -s
405 echo Test 12 Skipped due to absence of JIT support.
408 call :runsub 12 testout "JIT-specific features (JIT available)" -q
413 echo Test 13 Skipped due to presence of JIT support.
416 call :runsub 13 testout "JIT-specific features (JIT not available)" -q
420 if NOT %bits% EQU 8 (
421 echo Test 14 Skipped when running 16/32-bit tests.
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+
432 if NOT %bits% EQU 8 (
433 echo Test 15 Skipped when running 16/32-bit tests.
437 echo Test 15 Skipped due to absence of UTF-%bits% support.
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+
446 if NOT %bits% EQU 8 (
447 echo Test 16 Skipped when running 16/32-bit tests.
451 echo Test 16 Skipped due to absence of Unicode property support.
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+
461 echo Test 17 Skipped when running 8-bit tests.
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+
471 echo Test 18 Skipped when running 8-bit tests.
475 echo Test 18 Skipped due to absence of UTF-%bits% support.
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+
485 echo Test 19 Skipped when running 8-bit tests.
489 echo Test 19 Skipped due to absence of Unicode property support.
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+
499 echo Test 20 Skipped when running 8-bit tests.
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
508 echo Test 21 Skipped when running 8-bit tests.
511 if NOT %link_size% EQU 2 (
512 echo Test 21 Skipped because link size is not 2.
515 copy /Y %srcdir%\testdata\saved8 testsaved8
516 copy /Y %srcdir%\testdata\saved16LE-1 testsaved16LE-1
517 copy /Y %srcdir%\testdata\saved16BE-1 testsaved16BE-1
518 copy /Y %srcdir%\testdata\saved32LE-1 testsaved32LE-1
519 copy /Y %srcdir%\testdata\saved32BE-1 testsaved32BE-1
520 call :runsub 21 testout "Reloads for the basic 16/32-bit library" -q
521 call :runsub 21 testoutstudy "Test with Study Override" -q -s
522 if %jit% EQU 1 call :runsub 21 testoutjit "Test with JIT Override" -q -s+
527 echo Test 22 Skipped when running 8-bit tests.
531 echo Test 22 Skipped due to absence of UTF-%bits% support.
534 if NOT %link_size% EQU 2 (
535 echo Test 22 Skipped because link size is not 2.
538 copy /Y %srcdir%\testdata\saved16LE-2 testsaved16LE-2
539 copy /Y %srcdir%\testdata\saved16BE-2 testsaved16BE-2
540 copy /Y %srcdir%\testdata\saved32LE-2 testsaved32LE-2
541 copy /Y %srcdir%\testdata\saved32BE-2 testsaved32BE-2
542 call :runsub 22 testout "Reloads for the 16/32-bit library with UTF-16/32 support" -q
543 call :runsub 22 testoutstudy "Test with Study Override" -q -s
544 if %jit% EQU 1 call :runsub 22 testoutjit "Test with JIT Override" -q -s+
548 if NOT %bits% EQU 16 (
549 echo Test 23 Skipped when running 8/32-bit tests.
552 call :runsub 23 testout "Specials for the 16-bit library" -q
553 call :runsub 23 testoutstudy "Test with Study Override" -q -s
554 if %jit% EQU 1 call :runsub 23 testoutjit "Test with JIT Override" -q -s+
558 if NOT %bits% EQU 16 (
559 echo Test 24 Skipped when running 8/32-bit tests.
563 echo Test 24 Skipped due to absence of UTF-%bits% support.
566 call :runsub 24 testout "Specials for the 16-bit library with UTF-16 support" -q
567 call :runsub 24 testoutstudy "Test with Study Override" -q -s
568 if %jit% EQU 1 call :runsub 24 testoutjit "Test with JIT Override" -q -s+
572 if NOT %bits% EQU 32 (
573 echo Test 25 Skipped when running 8/16-bit tests.
576 call :runsub 25 testout "Specials for the 32-bit library" -q
577 call :runsub 25 testoutstudy "Test with Study Override" -q -s
578 if %jit% EQU 1 call :runsub 25 testoutjit "Test with JIT Override" -q -s+
582 if NOT %bits% EQU 32 (
583 echo Test 26 Skipped when running 8/16-bit tests.
587 echo Test 26 Skipped due to absence of UTF-%bits% support.
590 call :runsub 26 testout "Specials for the 32-bit library with UTF-32 support" -q
591 call :runsub 26 testoutstudy "Test with Study Override" -q -s
592 if %jit% EQU 1 call :runsub 26 testoutjit "Test with JIT Override" -q -s+
597 @echo Either your build is incomplete or you have a configuration error.
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.
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.
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.