• 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 (
249  set outnum=%1
250)
251set testinput=testinput%1
252set testoutput=testoutput%outnum%
253if exist %srcdir%\testdata\win%testinput% (
254  set testinput=wintestinput%1
255  set testoutput=wintestoutput%outnum%
256)
257
258echo Test %1: %3
259%pcre2test% %mode% %4 %5 %6 %7 %8 %9 %srcdir%\testdata\%testinput% >%2%bits%\%testoutput%
260if errorlevel 1 (
261  echo.          failed executing command-line:
262  echo.            %pcre2test% %mode% %4 %5 %6 %7 %8 %9 %srcdir%\testdata\%testinput% ^>%2%bits%\%testoutput%
263  set failed="yes"
264  goto :eof
265) else if [%1]==[2] (
266  %pcre2test% %mode% %4 %5 %6 %7 %8 %9 -error -70,-62,-2,-1,0,100,101,191,200 >>%2%bits%\%testoutput%
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]==[3] (
288    echo.
289    echo ** Test 3 failure usually means french locale is not
290    echo ** available on the system, rather than a bug or problem with PCRE2.
291    echo.
292    goto :eof
293)
294
295  set failed="yes"
296  goto :eof
297)
298
299echo.          Passed.
300goto :eof
301
302:do1
303call :runsub 1 testout "Main non-UTF, non-UCP functionality (Compatible with Perl >= 5.10)" -q
304if %jit% EQU 1 call :runsub 1 testoutjit "Test with JIT Override" -q -jit
305goto :eof
306
307:do2
308  call :runsub 2 testout "API, errors, internals, and non-Perl stuff" -q
309  if %jit% EQU 1 call :runsub 2 testoutjit "Test with JIT Override" -q -jit
310goto :eof
311
312:do3
313  call :runsub 3 testout "Locale-specific features" -q
314  if %jit% EQU 1 call :runsub 3 testoutjit "Test with JIT Override" -q -jit
315goto :eof
316
317:do4
318if %unicode% EQU 0 (
319  echo Test 4 Skipped due to absence of Unicode support.
320  goto :eof
321)
322  call :runsub 4 testout "UTF-%bits% and Unicode property support - (Compatible with Perl >= 5.10)" -q
323  if %jit% EQU 1 call :runsub 4 testoutjit "Test with JIT Override" -q -jit
324goto :eof
325
326:do5
327if %unicode% EQU 0 (
328  echo Test 5 Skipped due to absence of Unicode support.
329  goto :eof
330)
331  call :runsub 5 testout "API, internals, and non-Perl stuff for UTF-%bits% and UCP" -q
332  if %jit% EQU 1 call :runsub 5 testoutjit "Test with JIT Override" -q -jit
333goto :eof
334
335:do6
336  call :runsub 6 testout "DFA matching main non-UTF, non-UCP functionality" -q
337goto :eof
338
339:do7
340if %unicode% EQU 0 (
341  echo Test 7 Skipped due to absence of Unicode support.
342  goto :eof
343)
344  call :runsub 7 testout "DFA matching with UTF-%bits% and Unicode property support" -q
345  goto :eof
346
347:do8
348if NOT %link_size% EQU 2 (
349  echo Test 8 Skipped because link size is not 2.
350  goto :eof
351)
352if %unicode% EQU 0 (
353  echo Test 8 Skipped due to absence of Unicode support.
354  goto :eof
355)
356  call :runsub 8 testout "Internal offsets and code size tests" -q
357goto :eof
358
359:do9
360if NOT %bits% EQU 8 (
361  echo Test 9 Skipped when running 16/32-bit tests.
362  goto :eof
363)
364  call :runsub 9 testout "Specials for the basic 8-bit library" -q
365  if %jit% EQU 1 call :runsub 9 testoutjit "Test with JIT Override" -q -jit
366goto :eof
367
368:do10
369if NOT %bits% EQU 8 (
370  echo Test 10 Skipped when running 16/32-bit tests.
371  goto :eof
372)
373if %unicode% EQU 0 (
374  echo Test 10 Skipped due to absence of Unicode support.
375  goto :eof
376)
377  call :runsub 10 testout "Specials for the 8-bit library with Unicode support" -q
378  if %jit% EQU 1 call :runsub 10 testoutjit "Test with JIT Override" -q -jit
379goto :eof
380
381:do11
382if %bits% EQU 8 (
383  echo Test 11 Skipped when running 8-bit tests.
384  goto :eof
385)
386  call :runsub 11 testout "Specials for the basic 16/32-bit library" -q
387  if %jit% EQU 1 call :runsub 11 testoutjit "Test with JIT Override" -q -jit
388goto :eof
389
390:do12
391if %bits% EQU 8 (
392  echo Test 12 Skipped when running 8-bit tests.
393  goto :eof
394)
395if %unicode% EQU 0 (
396  echo Test 12 Skipped due to absence of Unicode support.
397  goto :eof
398)
399  call :runsub 12 testout "Specials for the 16/32-bit library with Unicode support" -q
400  if %jit% EQU 1 call :runsub 12 testoutjit "Test with JIT Override" -q -jit
401goto :eof
402
403:do13
404if %bits% EQU 8 (
405  echo Test 13 Skipped when running 8-bit tests.
406  goto :eof
407)
408  call :runsub 13 testout "DFA specials for the basic 16/32-bit library" -q
409goto :eof
410
411:do14
412if %unicode% EQU 0 (
413  echo Test 14 Skipped due to absence of Unicode support.
414  goto :eof
415)
416  call :runsub 14 testout "DFA specials for UTF and UCP support" -q
417  goto :eof
418
419:do15
420call :runsub 15 testout "Non-JIT limits and other non_JIT tests" -q
421goto :eof
422
423:do16
424if %jit% EQU 1 (
425  echo Test 16 Skipped due to presence of JIT support.
426  goto :eof
427)
428  call :runsub 16 testout "JIT-specific features when JIT is not available" -q
429goto :eof
430
431:do17
432if %jit% EQU 0 (
433  echo Test 17 Skipped due to absence of JIT support.
434  goto :eof
435)
436  call :runsub 17 testout "JIT-specific features when JIT is available" -q
437goto :eof
438
439:do18
440if %bits% EQU 16 (
441  echo Test 18 Skipped when running 16-bit tests.
442  goto :eof
443)
444if %bits% EQU 32 (
445  echo Test 18 Skipped when running 32-bit tests.
446  goto :eof
447)
448  call :runsub 18 testout "POSIX interface, excluding UTF-8 and UCP" -q
449goto :eof
450
451:do19
452if %bits% EQU 16 (
453  echo Test 19 Skipped when running 16-bit tests.
454  goto :eof
455)
456if %bits% EQU 32 (
457  echo Test 19 Skipped when running 32-bit tests.
458  goto :eof
459)
460if %unicode% EQU 0 (
461  echo Test 19 Skipped due to absence of Unicode support.
462  goto :eof
463)
464  call :runsub 19 testout "POSIX interface with UTF-8 and UCP" -q
465goto :eof
466
467:do20
468call :runsub 20 testout "Serialization tests" -q
469goto :eof
470
471:do21
472if %supportBSC% EQU 0 (
473  echo Test 21 Skipped due to absence of backslash-C support.
474  goto :eof
475)
476  call :runsub 21 testout "Backslash-C tests without UTF" -q
477  call :runsub 21 testout "Backslash-C tests without UTF (DFA)" -q -dfa
478  if %jit% EQU 1 call :runsub 21 testoutjit "Test with JIT Override" -q -jit
479goto :eof
480
481:do22
482if %supportBSC% EQU 0 (
483  echo Test 22 Skipped due to absence of backslash-C support.
484  goto :eof
485)
486if %unicode% EQU 0 (
487  echo Test 22 Skipped due to absence of Unicode support.
488  goto :eof
489)
490  call :runsub 22 testout "Backslash-C tests with UTF" -q
491  if %jit% EQU 1 call :runsub 22 testoutjit "Test with JIT Override" -q -jit
492goto :eof
493
494:do23
495if %supportBSC% EQU 1 (
496  echo Test 23 Skipped due to presence of backslash-C support.
497  goto :eof
498)
499  call :runsub 23 testout "Backslash-C disabled test" -q
500goto :eof
501
502:conferror
503@echo.
504@echo Either your build is incomplete or you have a configuration error.
505@echo.
506@echo If configured with cmake and executed via "make test" or the MSVC "RUN_TESTS"
507@echo project, pcre2_test.bat defines variables and automatically calls RunTest.bat.
508@echo For manual testing of all available features, after configuring with cmake
509@echo and building, you can run the built pcre2_test.bat. For best results with
510@echo cmake builds and tests avoid directories with full path names that include
511@echo spaces for source or build.
512@echo.
513@echo Otherwise, if the build dir is in a subdir of the source dir, testdata needed
514@echo for input and verification should be found automatically when (from the
515@echo location of the the built exes) you call RunTest.bat. By default RunTest.bat
516@echo runs all tests compatible with the linked pcre2 library but it can be given
517@echo a test number as an argument.
518@echo.
519@echo If the build dir is not under the source dir you can either copy your exes
520@echo to the source folder or copy RunTest.bat and the testdata folder to the
521@echo location of your built exes and then run RunTest.bat.
522@echo.
523goto :eof
524