new upstream release (3.3.0); modify package compatibility for Stretch
[ossec-hids.git] / src / external / pcre2-10.32 / RunTest.bat
diff --git a/src/external/pcre2-10.32/RunTest.bat b/src/external/pcre2-10.32/RunTest.bat
new file mode 100644 (file)
index 0000000..9474434
--- /dev/null
@@ -0,0 +1,523 @@
+@echo off\r
+@rem\r
+@rem MS Windows batch file to run pcre2test on testfiles with the correct\r
+@rem options. This file must use CRLF linebreaks to function properly,\r
+@rem and requires both pcre2test and pcre2grep.\r
+@rem\r
+@rem ------------------------ HISTORY ----------------------------------\r
+@rem This file was originally contributed to PCRE1 by Ralf Junker, and touched\r
+@rem up by Daniel Richard G. Tests 10-12 added by Philip H.\r
+@rem Philip H also changed test 3 to use "wintest" files.\r
+@rem\r
+@rem Updated by Tom Fortmann to support explicit test numbers on the command\r
+@rem line. Added argument validation and added error reporting.\r
+@rem\r
+@rem Sheri Pierce added logic to skip feature dependent tests\r
+@rem tests 4 5 7 10 12 14 19 and 22 require Unicode support\r
+@rem 8 requires Unicode and link size 2\r
+@rem 16 requires absence of jit support\r
+@rem 17 requires presence of jit support\r
+@rem Sheri P also added override tests for study and jit testing\r
+@rem Zoltan Herczeg added libpcre16 support\r
+@rem Zoltan Herczeg added libpcre32 support\r
+@rem -------------------------------------------------------------------\r
+@rem\r
+@rem The file was converted for PCRE2 by PH, February 2015.\r
+@rem Updated for new test 14 (moving others up a number), August 2015.\r
+@rem Tidied and updated for new tests 21, 22, 23 by PH, October 2015.\r
+@rem PH added missing "set type" for test 22, April 2016.\r
+\r
+\r
+setlocal enabledelayedexpansion\r
+if [%srcdir%]==[] (\r
+if exist testdata\ set srcdir=.)\r
+if [%srcdir%]==[] (\r
+if exist ..\testdata\ set srcdir=..)\r
+if [%srcdir%]==[] (\r
+if exist ..\..\testdata\ set srcdir=..\..)\r
+if NOT exist %srcdir%\testdata\ (\r
+Error: echo distribution testdata folder not found!\r
+call :conferror\r
+exit /b 1\r
+goto :eof\r
+)\r
+\r
+if [%pcre2test%]==[] set pcre2test=.\pcre2test.exe\r
+\r
+echo source dir is %srcdir%\r
+echo pcre2test=%pcre2test%\r
+\r
+if NOT exist %pcre2test% (\r
+echo Error: %pcre2test% not found!\r
+echo.\r
+call :conferror\r
+exit /b 1\r
+)\r
+\r
+%pcre2test% -C linksize >NUL\r
+set link_size=%ERRORLEVEL%\r
+%pcre2test% -C pcre2-8 >NUL\r
+set support8=%ERRORLEVEL%\r
+%pcre2test% -C pcre2-16 >NUL\r
+set support16=%ERRORLEVEL%\r
+%pcre2test% -C pcre2-32 >NUL\r
+set support32=%ERRORLEVEL%\r
+%pcre2test% -C unicode >NUL\r
+set unicode=%ERRORLEVEL%\r
+%pcre2test% -C jit >NUL\r
+set jit=%ERRORLEVEL%\r
+%pcre2test% -C backslash-C >NUL\r
+set supportBSC=%ERRORLEVEL%\r
+\r
+if %support8% EQU 1 (\r
+if not exist testout8 md testout8\r
+if not exist testoutjit8 md testoutjit8\r
+)\r
+\r
+if %support16% EQU 1 (\r
+if not exist testout16 md testout16\r
+if not exist testoutjit16 md testoutjit16\r
+)\r
+\r
+if %support16% EQU 1 (\r
+if not exist testout32 md testout32\r
+if not exist testoutjit32 md testoutjit32\r
+)\r
+\r
+set do1=no\r
+set do2=no\r
+set do3=no\r
+set do4=no\r
+set do5=no\r
+set do6=no\r
+set do7=no\r
+set do8=no\r
+set do9=no\r
+set do10=no\r
+set do11=no\r
+set do12=no\r
+set do13=no\r
+set do14=no\r
+set do15=no\r
+set do16=no\r
+set do17=no\r
+set do18=no\r
+set do19=no\r
+set do20=no\r
+set do21=no\r
+set do22=no\r
+set do23=no\r
+set all=yes\r
+\r
+for %%a in (%*) do (\r
+  set valid=no\r
+  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
+  if "!valid!" == "yes" (\r
+    set do%%a=yes\r
+    set all=no\r
+) else (\r
+    echo Invalid test number - %%a!\r
+        echo Usage %0 [ test_number ] ...\r
+        echo Where test_number is one or more optional test numbers 1 through 23, default is all tests.\r
+        exit /b 1\r
+)\r
+)\r
+set failed="no"\r
+\r
+if "%all%" == "yes" (\r
+  set do1=yes\r
+  set do2=yes\r
+  set do3=yes\r
+  set do4=yes\r
+  set do5=yes\r
+  set do6=yes\r
+  set do7=yes\r
+  set do8=yes\r
+  set do9=yes\r
+  set do10=yes\r
+  set do11=yes\r
+  set do12=yes\r
+  set do13=yes\r
+  set do14=yes\r
+  set do15=yes\r
+  set do16=yes\r
+  set do17=yes\r
+  set do18=yes\r
+  set do19=yes\r
+  set do20=yes\r
+  set do21=yes\r
+  set do22=yes\r
+  set do23=yes\r
+)\r
+\r
+@echo RunTest.bat's pcre2test output is written to newly created subfolders\r
+@echo named testout{8,16,32} and testoutjit{8,16,32}.\r
+@echo.\r
+\r
+set mode=\r
+set bits=8\r
+\r
+:nextMode\r
+if "%mode%" == "" (\r
+  if %support8% EQU 0 goto modeSkip\r
+  echo.\r
+  echo ---- Testing 8-bit library ----\r
+  echo.\r
+)\r
+if "%mode%" == "-16" (\r
+  if %support16% EQU 0 goto modeSkip\r
+  echo.\r
+  echo ---- Testing 16-bit library ----\r
+  echo.\r
+)\r
+if "%mode%" == "-32" (\r
+  if %support32% EQU 0 goto modeSkip\r
+  echo.\r
+  echo ---- Testing 32-bit library ----\r
+  echo.\r
+)\r
+if "%do1%" == "yes" call :do1\r
+if "%do2%" == "yes" call :do2\r
+if "%do3%" == "yes" call :do3\r
+if "%do4%" == "yes" call :do4\r
+if "%do5%" == "yes" call :do5\r
+if "%do6%" == "yes" call :do6\r
+if "%do7%" == "yes" call :do7\r
+if "%do8%" == "yes" call :do8\r
+if "%do9%" == "yes" call :do9\r
+if "%do10%" == "yes" call :do10\r
+if "%do11%" == "yes" call :do11\r
+if "%do12%" == "yes" call :do12\r
+if "%do13%" == "yes" call :do13\r
+if "%do14%" == "yes" call :do14\r
+if "%do15%" == "yes" call :do15\r
+if "%do16%" == "yes" call :do16\r
+if "%do17%" == "yes" call :do17\r
+if "%do18%" == "yes" call :do18\r
+if "%do19%" == "yes" call :do19\r
+if "%do20%" == "yes" call :do20\r
+if "%do21%" == "yes" call :do21\r
+if "%do22%" == "yes" call :do22\r
+if "%do23%" == "yes" call :do23\r
+:modeSkip\r
+if "%mode%" == "" (\r
+  set mode=-16\r
+  set bits=16\r
+  goto nextMode\r
+)\r
+if "%mode%" == "-16" (\r
+  set mode=-32\r
+  set bits=32\r
+  goto nextMode\r
+)\r
+\r
+@rem If mode is -32, testing is finished\r
+if %failed% == "yes" (\r
+echo In above output, one or more of the various tests failed!\r
+exit /b 1\r
+)\r
+echo All OK\r
+goto :eof\r
+\r
+:runsub\r
+@rem Function to execute pcre2test and compare the output\r
+@rem Arguments are as follows:\r
+@rem\r
+@rem       1 = test number\r
+@rem       2 = outputdir\r
+@rem       3 = test name use double quotes\r
+@rem   4 - 9 = pcre2test options\r
+\r
+if [%1] == [] (\r
+  echo Missing test number argument!\r
+  exit /b 1\r
+)\r
+\r
+if [%2] == [] (\r
+  echo Missing outputdir!\r
+  exit /b 1\r
+)\r
+\r
+if [%3] == [] (\r
+  echo Missing test name argument!\r
+  exit /b 1\r
+)\r
+\r
+if %1 == 8 (\r
+  set outnum=8-%bits%-%link_size%\r
+) else (\r
+  set outnum=%1\r
+)\r
+set testinput=testinput%1\r
+set testoutput=testoutput%outnum%\r
+if exist %srcdir%\testdata\win%testinput% (\r
+  set testinput=wintestinput%1\r
+  set testoutput=wintestoutput%outnum%\r
+)\r
+\r
+echo Test %1: %3\r
+%pcre2test% %mode% %4 %5 %6 %7 %8 %9 %srcdir%\testdata\%testinput% >%2%bits%\%testoutput%\r
+if errorlevel 1 (\r
+  echo.          failed executing command-line:\r
+  echo.            %pcre2test% %mode% %4 %5 %6 %7 %8 %9 %srcdir%\testdata\%testinput% ^>%2%bits%\%testoutput%\r
+  set failed="yes"\r
+  goto :eof\r
+) else if [%1]==[2] (\r
+  %pcre2test% %mode% %4 %5 %6 %7 %8 %9 -error -70,-62,-2,-1,0,100,101,191,200 >>%2%bits%\%testoutput%\r
+)\r
+\r
+set type=\r
+if [%1]==[11] (\r
+  set type=-%bits%\r
+)\r
+if [%1]==[12] (\r
+  set type=-%bits%\r
+)\r
+if [%1]==[14] (\r
+  set type=-%bits%\r
+)\r
+if [%1]==[22] (\r
+  set type=-%bits%\r
+)\r
+\r
+fc /n %srcdir%\testdata\%testoutput%%type% %2%bits%\%testoutput% >NUL\r
+\r
+if errorlevel 1 (\r
+  echo.          failed comparison: fc /n %srcdir%\testdata\%testoutput% %2%bits%\%testoutput%\r
+  if [%1]==[3] (\r
+    echo.\r
+    echo ** Test 3 failure usually means french locale is not\r
+    echo ** available on the system, rather than a bug or problem with PCRE2.\r
+    echo.\r
+    goto :eof\r
+)\r
+\r
+  set failed="yes"\r
+  goto :eof\r
+)\r
+\r
+echo.          Passed.\r
+goto :eof\r
+\r
+:do1\r
+call :runsub 1 testout "Main non-UTF, non-UCP functionality (Compatible with Perl >= 5.10)" -q\r
+if %jit% EQU 1 call :runsub 1 testoutjit "Test with JIT Override" -q -jit\r
+goto :eof\r
+\r
+:do2\r
+  call :runsub 2 testout "API, errors, internals, and non-Perl stuff" -q\r
+  if %jit% EQU 1 call :runsub 2 testoutjit "Test with JIT Override" -q -jit\r
+goto :eof\r
+\r
+:do3\r
+  call :runsub 3 testout "Locale-specific features" -q\r
+  if %jit% EQU 1 call :runsub 3 testoutjit "Test with JIT Override" -q -jit\r
+goto :eof\r
+\r
+:do4\r
+if %unicode% EQU 0 (\r
+  echo Test 4 Skipped due to absence of Unicode support.\r
+  goto :eof\r
+)\r
+  call :runsub 4 testout "UTF-%bits% and Unicode property support - (Compatible with Perl >= 5.10)" -q\r
+  if %jit% EQU 1 call :runsub 4 testoutjit "Test with JIT Override" -q -jit\r
+goto :eof\r
+\r
+:do5\r
+if %unicode% EQU 0 (\r
+  echo Test 5 Skipped due to absence of Unicode support.\r
+  goto :eof\r
+)\r
+  call :runsub 5 testout "API, internals, and non-Perl stuff for UTF-%bits% and UCP" -q\r
+  if %jit% EQU 1 call :runsub 5 testoutjit "Test with JIT Override" -q -jit\r
+goto :eof\r
+\r
+:do6\r
+  call :runsub 6 testout "DFA matching main non-UTF, non-UCP functionality" -q\r
+goto :eof\r
+\r
+:do7\r
+if %unicode% EQU 0 (\r
+  echo Test 7 Skipped due to absence of Unicode support.\r
+  goto :eof\r
+)\r
+  call :runsub 7 testout "DFA matching with UTF-%bits% and Unicode property support" -q\r
+  goto :eof\r
+\r
+:do8\r
+if NOT %link_size% EQU 2 (\r
+  echo Test 8 Skipped because link size is not 2.\r
+  goto :eof\r
+)\r
+if %unicode% EQU 0 (\r
+  echo Test 8 Skipped due to absence of Unicode support.\r
+  goto :eof\r
+)\r
+  call :runsub 8 testout "Internal offsets and code size tests" -q\r
+goto :eof\r
+\r
+:do9\r
+if NOT %bits% EQU 8 (\r
+  echo Test 9 Skipped when running 16/32-bit tests.\r
+  goto :eof\r
+)\r
+  call :runsub 9 testout "Specials for the basic 8-bit library" -q\r
+  if %jit% EQU 1 call :runsub 9 testoutjit "Test with JIT Override" -q -jit\r
+goto :eof\r
+\r
+:do10\r
+if NOT %bits% EQU 8 (\r
+  echo Test 10 Skipped when running 16/32-bit tests.\r
+  goto :eof\r
+)\r
+if %unicode% EQU 0 (\r
+  echo Test 10 Skipped due to absence of Unicode support.\r
+  goto :eof\r
+)\r
+  call :runsub 10 testout "Specials for the 8-bit library with Unicode support" -q\r
+  if %jit% EQU 1 call :runsub 10 testoutjit "Test with JIT Override" -q -jit\r
+goto :eof\r
+\r
+:do11\r
+if %bits% EQU 8 (\r
+  echo Test 11 Skipped when running 8-bit tests.\r
+  goto :eof\r
+)\r
+  call :runsub 11 testout "Specials for the basic 16/32-bit library" -q\r
+  if %jit% EQU 1 call :runsub 11 testoutjit "Test with JIT Override" -q -jit\r
+goto :eof\r
+\r
+:do12\r
+if %bits% EQU 8 (\r
+  echo Test 12 Skipped when running 8-bit tests.\r
+  goto :eof\r
+)\r
+if %unicode% EQU 0 (\r
+  echo Test 12 Skipped due to absence of Unicode support.\r
+  goto :eof\r
+)\r
+  call :runsub 12 testout "Specials for the 16/32-bit library with Unicode support" -q\r
+  if %jit% EQU 1 call :runsub 12 testoutjit "Test with JIT Override" -q -jit\r
+goto :eof\r
+\r
+:do13\r
+if %bits% EQU 8 (\r
+  echo Test 13 Skipped when running 8-bit tests.\r
+  goto :eof\r
+)\r
+  call :runsub 13 testout "DFA specials for the basic 16/32-bit library" -q\r
+goto :eof\r
+\r
+:do14\r
+if %unicode% EQU 0 (\r
+  echo Test 14 Skipped due to absence of Unicode support.\r
+  goto :eof\r
+)\r
+  call :runsub 14 testout "DFA specials for UTF and UCP support" -q\r
+  goto :eof\r
+\r
+:do15\r
+call :runsub 15 testout "Non-JIT limits and other non_JIT tests" -q\r
+goto :eof\r
+\r
+:do16\r
+if %jit% EQU 1 (\r
+  echo Test 16 Skipped due to presence of JIT support.\r
+  goto :eof\r
+)\r
+  call :runsub 16 testout "JIT-specific features when JIT is not available" -q\r
+goto :eof\r
+\r
+:do17\r
+if %jit% EQU 0 (\r
+  echo Test 17 Skipped due to absence of JIT support.\r
+  goto :eof\r
+)\r
+  call :runsub 17 testout "JIT-specific features when JIT is available" -q\r
+goto :eof\r
+\r
+:do18\r
+if %bits% EQU 16 (\r
+  echo Test 18 Skipped when running 16-bit tests.\r
+  goto :eof\r
+)\r
+if %bits% EQU 32 (\r
+  echo Test 18 Skipped when running 32-bit tests.\r
+  goto :eof\r
+)\r
+  call :runsub 18 testout "POSIX interface, excluding UTF-8 and UCP" -q\r
+goto :eof\r
+\r
+:do19\r
+if %bits% EQU 16 (\r
+  echo Test 19 Skipped when running 16-bit tests.\r
+  goto :eof\r
+)\r
+if %bits% EQU 32 (\r
+  echo Test 19 Skipped when running 32-bit tests.\r
+  goto :eof\r
+)\r
+if %unicode% EQU 0 (\r
+  echo Test 19 Skipped due to absence of Unicode support.\r
+  goto :eof\r
+)\r
+  call :runsub 19 testout "POSIX interface with UTF-8 and UCP" -q\r
+goto :eof\r
+\r
+:do20\r
+call :runsub 20 testout "Serialization tests" -q\r
+goto :eof\r
+\r
+:do21\r
+if %supportBSC% EQU 0 (\r
+  echo Test 21 Skipped due to absence of backslash-C support.\r
+  goto :eof\r
+)\r
+  call :runsub 21 testout "Backslash-C tests without UTF" -q\r
+  call :runsub 21 testout "Backslash-C tests without UTF (DFA)" -q -dfa\r
+  if %jit% EQU 1 call :runsub 21 testoutjit "Test with JIT Override" -q -jit\r
+goto :eof\r
+\r
+:do22\r
+if %supportBSC% EQU 0 (\r
+  echo Test 22 Skipped due to absence of backslash-C support.\r
+  goto :eof\r
+)\r
+if %unicode% EQU 0 (\r
+  echo Test 22 Skipped due to absence of Unicode support.\r
+  goto :eof\r
+)\r
+  call :runsub 22 testout "Backslash-C tests with UTF" -q\r
+  if %jit% EQU 1 call :runsub 22 testoutjit "Test with JIT Override" -q -jit\r
+goto :eof\r
+\r
+:do23\r
+if %supportBSC% EQU 1 (\r
+  echo Test 23 Skipped due to presence of backslash-C support.\r
+  goto :eof\r
+)\r
+  call :runsub 23 testout "Backslash-C disabled test" -q\r
+goto :eof\r
+\r
+:conferror\r
+@echo.\r
+@echo Either your build is incomplete or you have a configuration error.\r
+@echo.\r
+@echo If configured with cmake and executed via "make test" or the MSVC "RUN_TESTS"\r
+@echo project, pcre2_test.bat defines variables and automatically calls RunTest.bat.\r
+@echo For manual testing of all available features, after configuring with cmake\r
+@echo and building, you can run the built pcre2_test.bat. For best results with\r
+@echo cmake builds and tests avoid directories with full path names that include\r
+@echo spaces for source or build.\r
+@echo.\r
+@echo Otherwise, if the build dir is in a subdir of the source dir, testdata needed\r
+@echo for input and verification should be found automatically when (from the\r
+@echo location of the the built exes) you call RunTest.bat. By default RunTest.bat\r
+@echo runs all tests compatible with the linked pcre2 library but it can be given\r
+@echo a test number as an argument.\r
+@echo.\r
+@echo If the build dir is not under the source dir you can either copy your exes\r
+@echo to the source folder or copy RunTest.bat and the testdata folder to the\r
+@echo location of your built exes and then run RunTest.bat.\r
+@echo.\r
+goto :eof\r