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