github的一些开源项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

528 lines
14 KiB

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