blob: 38f1eae9852f954c797ea7a7aec00355e88179ed [file] [log] [blame]
Tristan Matthews04616462013-11-14 16:09:34 -05001@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 8 and 12 require utf8 support
16@rem tests 6 9 13 require ucp support
17@rem 10 requires ucp and link size 2
18@rem 14 requires presense of jit support
19@rem 15 requires absence of jit support
20@rem Sheri P also added override tests for study and jit testing
21@rem JIT testing n/a for tests 7-10, removed JIT override test for them
22@rem removed override tests for 14-15
23
24setlocal enabledelayedexpansion
25if [%srcdir%]==[] (
26if exist testdata\ set srcdir=.)
27if [%srcdir%]==[] (
28if exist ..\testdata\ set srcdir=..)
29if [%srcdir%]==[] (
30if exist ..\..\testdata\ set srcdir=..\..)
31if NOT exist "%srcdir%\testdata\" (
32Error: echo distribution testdata folder not found!
33call :conferror
34exit /b 1
35goto :eof
36)
37
38if "%pcregrep%"=="" set pcregrep=.\pcregrep.exe
39if "%pcretest%"=="" set pcretest=.\pcretest.exe
40
41echo source dir is %srcdir%
42echo pcretest=%pcretest%
43echo pcregrep=%pcregrep%
44
45if NOT exist "%pcregrep%" (
46echo Error: "%pcregrep%" not found!
47echo.
48call :conferror
49exit /b 1
50)
51
52if NOT exist "%pcretest%" (
53echo Error: "%pcretest%" not found!
54echo.
55call :conferror
56exit /b 1
57)
58
59"%pcretest%" -C|"%pcregrep%" --no-jit "No UTF-8 support">NUL
60set utf8=%ERRORLEVEL%
61"%pcretest%" -C|"%pcregrep%" --no-jit "No Unicode properties support">NUL
62set ucp=%ERRORLEVEL%
63"%pcretest%" -C|"%pcregrep%" --no-jit "No just-in-time compiler support">NUL
64set jit=%ERRORLEVEL%
65"%pcretest%" -C|"%pcregrep%" --no-jit "Internal link size = 2">NUL
66set link2=%ERRORLEVEL%
67set ucpandlink2=0
68if %ucp% EQU 1 (
69 if %link2% EQU 0 set ucpandlink2=1
70)
71
72if not exist testout md testout
73if not exist testoutstudy md testoutstudy
74if not exist testoutjit md testoutjit
75
76set do1=no
77set do2=no
78set do3=no
79set do4=no
80set do5=no
81set do6=no
82set do7=no
83set do8=no
84set do9=no
85set do10=no
86set do11=no
87set do12=no
88set do13=no
89set do14=no
90set do15=no
91set all=yes
92
93for %%a in (%*) do (
94 set valid=no
95 for %%v in (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15) do if %%v == %%a set valid=yes
96 if "!valid!" == "yes" (
97 set do%%a=yes
98 set all=no
99) else (
100 echo Invalid test number - %%a!
101 echo Usage %0 [ test_number ] ...
102 echo Where test_number is one or more optional test numbers 1 through 15, default is all tests.
103 exit /b 1
104)
105)
106set failed="no"
107
108if "%all%" == "yes" (
109 set do1=yes
110 set do2=yes
111 set do3=yes
112 set do4=yes
113 set do5=yes
114 set do6=yes
115 set do7=yes
116 set do8=yes
117 set do9=yes
118 set do10=yes
119 set do11=yes
120 set do12=yes
121 set do13=yes
122 set do14=yes
123 set do15=yes
124)
125
126@echo RunTest.bat's pcretest output is written to newly created subfolders named
127@echo testout, testoutstudy and testoutjit.
128@echo.
129if "%do1%" == "yes" call :do1
130if "%do2%" == "yes" call :do2
131if "%do3%" == "yes" call :do3
132if "%do4%" == "yes" call :do4
133if "%do5%" == "yes" call :do5
134if "%do6%" == "yes" call :do6
135if "%do7%" == "yes" call :do7
136if "%do8%" == "yes" call :do8
137if "%do9%" == "yes" call :do9
138if "%do10%" == "yes" call :do10
139if "%do11%" == "yes" call :do11
140if "%do12%" == "yes" call :do12
141if "%do13%" == "yes" call :do13
142if "%do14%" == "yes" call :do14
143if "%do15%" == "yes" call :do15
144if %failed% == "yes" (
145echo In above output, one or more of the various tests failed!
146exit /b 1
147)
148echo All OK
149goto :eof
150
151:runsub
152@rem Function to execute pcretest and compare the output
153@rem Arguments are as follows:
154@rem
155@rem 1 = test number
156@rem 2 = outputdir
157@rem 3 = test name use double quotes
158@rem 4 - 9 = pcretest options
159
160if [%1] == [] (
161 echo Missing test number argument!
162 exit /b 1
163)
164
165if [%2] == [] (
166 echo Missing outputdir!
167 exit /b 1
168)
169
170if [%3] == [] (
171 echo Missing test name argument!
172 exit /b 1
173)
174
175set testinput=testinput%1
176set testoutput=testoutput%1
177if exist %srcdir%\testdata\win%testinput% (
178 set testinput=wintestinput%1
179 set testoutput=wintestoutput%1
180)
181
182echo Test %1: %3
183"%pcretest%" %4 %5 %6 %7 %8 %9 "%srcdir%\testdata\%testinput%">%2\%testoutput%
184if errorlevel 1 (
185 echo. failed executing command-line:
186 echo. "%pcretest%" %4 %5 %6 %7 %8 %9 "%srcdir%\testdata\%testinput%"^>%2\%testoutput%
187 set failed="yes"
188 goto :eof
189)
190
191fc /n "%srcdir%\testdata\%testoutput%" "%2\%testoutput%">NUL
192if errorlevel 1 (
193 echo. failed comparison: fc /n "%srcdir%\testdata\%testoutput%" "%2\%testoutput%"
194 set failed="yes"
195 if [%1]==[2] (
196 echo.
197 echo ** Test 2 requires a lot of stack. PCRE can be configured to
198 echo ** use heap for recursion. Otherwise, to pass Test 2
199 echo ** you generally need to allocate 8 mb stack to PCRE.
200 echo ** See the 'pcrestack' page for a discussion of PCRE's
201 echo ** stack usage.
202 echo.
203)
204 if [%1]==[3] (
205 echo.
206 echo ** Test 3 failure usually means french locale is not
207 echo ** available on the system, rather than a bug or problem with PCRE.
208 echo.
209)
210
211 goto :eof
212)
213
214echo. Passed.
215goto :eof
216
217:do1
218call :runsub 1 testout "Main functionality - Compatible with Perl 5.8 and above" -q
219call :runsub 1 testoutstudy "Test with Study Override" -q -s
220if %jit% EQU 1 call :runsub 1 testoutjit "Test with JIT Override" -q -s+
221goto :eof
222
223:do2
224 call :runsub 2 testout "API, errors, internals, and non-Perl stuff (not UTF-8)" -q
225 call :runsub 2 testoutstudy "Test with Study Override" -q -s
226 if %jit% EQU 1 call :runsub 2 testoutjit "Test with JIT Override" -q -s+
227goto :eof
228
229:do3
230 call :runsub 3 testout "Locale-specific features" -q
231 call :runsub 3 testoutstudy "Test with Study Override" -q -s
232 if %jit% EQU 1 call :runsub 3 testoutjit "Test with JIT Override" -q -s+
233goto :eof
234
235:do4
236 if %utf8% EQU 0 (
237 echo Test 4 Skipped due to absence of UTF-8 support.
238 goto :eof
239)
240 call :runsub 4 testout "UTF-8 support - Compatible with Perl 5.8 and above" -q
241 call :runsub 4 testoutstudy "Test with Study Override" -q -s
242 if %jit% EQU 1 call :runsub 4 testoutjit "Test with JIT Override" -q -s+
243goto :eof
244
245:do5
246 if %utf8% EQU 0 (
247 echo Test 5 Skipped due to absence of UTF-8 support.
248 goto :eof
249)
250 call :runsub 5 testout "API, internals, and non-Perl stuff for UTF-8 support" -q
251 call :runsub 5 testoutstudy "Test with Study Override" -q -s
252 if %jit% EQU 1 call :runsub 5 testoutjit "Test with JIT Override" -q -s+
253goto :eof
254
255:do6
256if %ucp% EQU 0 (
257 echo Test 6 Skipped due to absence of ucp support.
258 goto :eof
259)
260 call :runsub 6 testout "Unicode property support - Compatible with Perl 5.10 and above" -q
261 call :runsub 6 testoutstudy "Test with Study Override" -q -s
262 if %jit% EQU 1 call :runsub 6 testoutjit "Test with JIT Override" -q -s+
263goto :eof
264
265:do7
266 call :runsub 7 testout "DFA matching" -q -dfa
267 call :runsub 7 testoutstudy "Test with Study Override" -q -dfa -s
268goto :eof
269
270:do8
271 if %utf8% EQU 0 (
272 echo Test 8 Skipped due to absence of UTF-8 support.
273 goto :eof
274)
275 call :runsub 8 testout "DFA matching with UTF-8" -q -dfa
276 call :runsub 8 testoutstudy "Test with Study Override" -q -dfa -s
277 goto :eof
278
279:do9
280 if %ucp% EQU 0 (
281 echo Test 9 Skipped due to absence of ucp support.
282 goto :eof
283)
284 call :runsub 9 testout "DFA matching with Unicode properties" -q -dfa
285 call :runsub 9 testoutstudy "Test with Study Override" -q -dfa -s
286goto :eof
287
288:do10
289 if %ucpandlink2% EQU 0 (
290 echo Test 10 Skipped due to requirements of ucp support AND link size 2.
291 goto :eof
292)
293 call :runsub 10 testout "Internal offsets and code size tests" -q
294 call :runsub 10 testoutstudy "Test with Study Override" -q -s
295goto :eof
296
297:do11
298 call :runsub 11 testout "Features from Perl 5.10 and above" -q
299 call :runsub 11 testoutstudy "Test with Study Override" -q -s
300 if %jit% EQU 1 call :runsub 11 testoutjit "Test with JIT Override" -q -s+
301goto :eof
302
303:do12
304 if %utf8% EQU 0 (
305 echo Test 12 Skipped due to absence of UTF-8 support.
306 goto :eof
307)
308 call :runsub 12 testout "Features from Perl 5.10 and above w UTF-8" -q
309 call :runsub 12 testoutstudy "Test with Study Override" -q -s
310 if %jit% EQU 1 call :runsub 12 testoutjit "Test with JIT Override" -q -s+
311goto :eof
312
313:do13
314 if %ucp% EQU 0 (
315 echo Test 13 Skipped due to absence of ucp support.
316 goto :eof
317)
318call :runsub 13 testout "API internals and non-Perl stuff for Unicode property support" -q
319call :runsub 13 testoutstudy "Test with Study Override" -q -s
320if %jit% EQU 1 call :runsub 13 testoutjit "Test with JIT Override" -q -s+
321goto :eof
322
323:do14
324if %jit% EQU 0 (
325 echo Test 14 Skipped due to absence of JIT support.
326 goto :eof
327)
328 call :runsub 14 testout "JIT-specific features - have JIT" -q
329goto :eof
330
331:do15
332 if %jit% EQU 1 (
333 echo Test 15 Skipped due to presence of JIT support.
334 goto :eof
335)
336 call :runsub 15 testout "JIT-specific features - no JIT" -q
337goto :eof
338
339:conferror
340@echo.
341@echo Either your build is incomplete or you have a configuration error.
342@echo.
343@echo If configured with cmake and executed via "make test" or the MSVC "RUN_TESTS"
344@echo project, pcre_test.bat defines variables and automatically calls RunTest.bat.
345@echo For manual testing of all available features, after configuring with cmake
346@echo and building, you can run the built pcre_test.bat. For best results with
347@echo cmake builds and tests avoid directories with full path names that include
348@echo spaces for source or build.
349@echo.
350@echo Otherwise, if the build dir is in a subdir of the source dir, testdata needed
351@echo for input and verification should be found automatically when (from the
352@echo location of the the built exes) you call RunTest.bat. By default RunTest.bat
353@echo runs all tests compatible with the linked pcre library but it can be given
354@echo a test number as an argument.
355@echo.
356@echo If the build dir is not under the source dir you can either copy your exes
357@echo to the source folder or copy RunTest.bat and the testdata folder to the
358@echo location of your built exes and then run RunTest.bat.
359@echo.
360goto :eof