usbmodeswitch: Updated to v.1.2.6 from shibby's branch.
[tomato.git] / release / src / router / pcre / RunTest.bat
blobe09b2d296d5e70a959efa8afe057f2938e322893
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 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
25 if [%srcdir%]==[] (
26 if exist testdata\ set srcdir=.)
27 if [%srcdir%]==[] (
28 if exist ..\testdata\ set srcdir=..)
29 if [%srcdir%]==[] (
30 if exist ..\..\testdata\ set srcdir=..\..)
31 if NOT exist %srcdir%\testdata\ (
32 Error: echo distribution testdata folder not found!
33 call :conferror
34 exit /b 1
35 goto :eof
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!
45 echo.
46 call :conferror
47 exit /b 1
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
59 set utf=%ERRORLEVEL%
60 %pcretest% -C ucp >NUL
61 set ucp=%ERRORLEVEL%
62 %pcretest% -C jit >NUL
63 set jit=%ERRORLEVEL%
65 if %support8% EQU 1 (
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
83 set do1=no
84 set do2=no
85 set do3=no
86 set do4=no
87 set do5=no
88 set do6=no
89 set do7=no
90 set do8=no
91 set do9=no
92 set do10=no
93 set do11=no
94 set do12=no
95 set do13=no
96 set do14=no
97 set do15=no
98 set do16=no
99 set do17=no
100 set do18=no
101 set do19=no
102 set do20=no
103 set do21=no
104 set do22=no
105 set do23=no
106 set do24=no
107 set do25=no
108 set do26=no
109 set all=yes
111 for %%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
124 set failed="no"
126 if "%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
155 @echo RunTest.bat's pcretest output is written to newly created subfolders named
156 @echo testout, testoutstudy and testoutjit.
157 @echo.
159 set mode=
160 set bits=8
162 :nextMode
163 if "%mode%" == "" (
164   if %support8% EQU 0 goto modeSkip
165   echo.
166   echo ---- Testing 8-bit library ----
167   echo.
169 if "%mode%" == "-16" (
170   if %support16% EQU 0 goto modeSkip
171   echo.
172   echo ---- Testing 16-bit library ----
173   echo.
175 if "%mode%" == "-32" (
176   if %support32% EQU 0 goto modeSkip
177   echo.
178   echo ---- Testing 32-bit library ----
179   echo.
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
207 :modeSkip
208 if "%mode%" == "" (
209   set mode=-16
210   set bits=16
211   goto nextMode
213 if "%mode%" == "-16" (
214   set mode=-32
215   set bits=32
216   goto nextMode
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!
222 exit /b 1
224 echo All OK
225 goto :eof
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
236 if [%1] == [] (
237   echo Missing test number argument!
238   exit /b 1
241 if [%2] == [] (
242   echo Missing outputdir!
243   exit /b 1
246 if [%3] == [] (
247   echo Missing test name argument!
248   exit /b 1
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
258 echo Test %1: %3
259 %pcretest% %mode% %4 %5 %6 %7 %8 %9 %srcdir%\testdata\%testinput% >%2%bits%\%testoutput%
260 if 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
267 set type=
268 if [%1]==[11] (
269   set type=-%bits%
271 if [%1]==[18] (
272   set type=-%bits%
274 if [%1]==[21] (
275   set type=-%bits%
277 if [%1]==[22] (
278   set type=-%bits%
281 fc /n %srcdir%\testdata\%testoutput%%type% %2%bits%\%testoutput% >NUL
283 if 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.
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
302   set failed="yes"
303   goto :eof
306 echo.          Passed.
307 goto :eof
309 :do1
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+
313 goto :eof
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+
319 goto :eof
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+
325 goto :eof
327 :do4
328 if %utf% EQU 0 (
329   echo Test 4 Skipped due to absence of UTF-%bits% support.
330   goto :eof
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+
335 goto :eof
337 :do5
338 if %utf% EQU 0 (
339   echo Test 5 Skipped due to absence of UTF-%bits% support.
340   goto :eof
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+
345 goto :eof
347 :do6
348 if %ucp% EQU 0 (
349   echo Test 6 Skipped due to absence of Unicode property support.
350   goto :eof
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+
355 goto :eof
357 :do7
358 if %ucp% EQU 0 (
359   echo Test 7 Skipped due to absence of Unicode property support.
360   goto :eof
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+
365 goto :eof
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
370 goto :eof
372 :do9
373 if %utf% EQU 0 (
374   echo Test 9 Skipped due to absence of UTF-%bits% support.
375   goto :eof
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
381 :do10
382 if %ucp% EQU 0 (
383   echo Test 10 Skipped due to absence of Unicode property support.
384   goto :eof
386   call :runsub 10 testout "DFA matching with Unicode properties" -q -dfa
387   call :runsub 10 testoutstudy "Test with Study Override" -q -dfa -s
388 goto :eof
390 :do11
391 if NOT %link_size% EQU 2 (
392   echo Test 11 Skipped because link size is not 2.
393   goto :eof
395 if %ucp% EQU 0 (
396   echo Test 11 Skipped due to absence of Unicode property support.
397   goto :eof
399   call :runsub 11 testout "Internal offsets and code size tests" -q
400   call :runsub 11 testoutstudy "Test with Study Override" -q -s
401 goto :eof
403 :do12
404 if %jit% EQU 0 (
405   echo Test 12 Skipped due to absence of JIT support.
406   goto :eof
408   call :runsub 12 testout "JIT-specific features (JIT available)" -q
409 goto :eof
411 :do13
412 if %jit% EQU 1 (
413   echo Test 13 Skipped due to presence of JIT support.
414   goto :eof
416   call :runsub 13 testout "JIT-specific features (JIT not available)" -q
417 goto :eof
419 :do14
420 if NOT %bits% EQU 8 (
421   echo Test 14 Skipped when running 16/32-bit tests.
422   goto :eof
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+
429 goto :eof
431 :do15
432 if NOT %bits% EQU 8 (
433   echo Test 15 Skipped when running 16/32-bit tests.
434   goto :eof
436 if %utf% EQU 0 (
437   echo Test 15 Skipped due to absence of UTF-%bits% support.
438   goto :eof
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+
443 goto :eof
445 :do16
446 if NOT %bits% EQU 8 (
447   echo Test 16 Skipped when running 16/32-bit tests.
448   goto :eof
450 if %ucp% EQU 0 (
451   echo Test 16 Skipped due to absence of Unicode property support.
452   goto :eof
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+
457 goto :eof
459 :do17
460 if %bits% EQU 8 (
461   echo Test 17 Skipped when running 8-bit tests.
462   goto :eof
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+
467 goto :eof
469 :do18
470 if %bits% EQU 8 (
471   echo Test 18 Skipped when running 8-bit tests.
472   goto :eof
474 if %utf% EQU 0 (
475   echo Test 18 Skipped due to absence of UTF-%bits% support.
476   goto :eof
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+
481 goto :eof
483 :do19
484 if %bits% EQU 8 (
485   echo Test 19 Skipped when running 8-bit tests.
486   goto :eof
488 if %ucp% EQU 0 (
489   echo Test 19 Skipped due to absence of Unicode property support.
490   goto :eof
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+
495 goto :eof
497 :do20
498 if %bits% EQU 8 (
499   echo Test 20 Skipped when running 8-bit tests.
500   goto :eof
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
504 goto :eof
506 :do21
507 if %bits% EQU 8 (
508   echo Test 21 Skipped when running 8-bit tests.
509   goto :eof
511 if NOT %link_size% EQU 2 (
512   echo Test 21 Skipped because link size is not 2.
513   goto :eof
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+
523 goto :eof
525 :do22
526 if %bits% EQU 8 (
527   echo Test 22 Skipped when running 8-bit tests.
528   goto :eof
530 if %utf% EQU 0 (
531   echo Test 22 Skipped due to absence of UTF-%bits% support.
532   goto :eof
534 if NOT %link_size% EQU 2 (
535   echo Test 22 Skipped because link size is not 2.
536   goto :eof
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+
545 goto :eof
547 :do23
548 if NOT %bits% EQU 16 (
549   echo Test 23 Skipped when running 8/32-bit tests.
550   goto :eof
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+
555 goto :eof
557 :do24
558 if NOT %bits% EQU 16 (
559   echo Test 24 Skipped when running 8/32-bit tests.
560   goto :eof
562 if %utf% EQU 0 (
563   echo Test 24 Skipped due to absence of UTF-%bits% support.
564   goto :eof
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+
569 goto :eof
571 :do25
572 if NOT %bits% EQU 32 (
573   echo Test 25 Skipped when running 8/16-bit tests.
574   goto :eof
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+
579 goto :eof
581 :do26
582 if NOT %bits% EQU 32 (
583   echo Test 26 Skipped when running 8/16-bit tests.
584   goto :eof
586 if %utf% EQU 0 (
587   echo Test 26 Skipped due to absence of UTF-%bits% support.
588   goto :eof
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+
593 goto :eof
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.
616 goto :eof