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