ModSecurity/test/test-suite.sh
Eduardo Arias e6e2989bd5 Configure test fixture using CTest for Windows build
- Added new test/test_suite.in with list of regression and unit tests
  previously in Makefile.am, to be shared between Unix and Windows
  builds.
- Updated regression.cc & unit.cc to return the number of failed tests
  to indicate to CTest that the test failed. Similarly, a crash or
  unhandled exception terminates the process with a non-zero exit code.
  - This change doesn't affect running the tests with autotest in Unix
    builds because this processes test output from custom-test-driver &
    test-suite.sh, and ignores the exit code of the test runner.
- Removed comment in test/test-cases/regression-offset-variable.json as
  this is not supported by JSON and prevents strict parsers to read and
  process the file.
- Minor change in regression.cc's clearAuditLog to replace std::ifstream
  with std::ofstream as the mode to open the flag applies to an output
  stream.
- Minor change in unit.cc to simplify code that deletes tests.
- Minor changes to test/custom-test-driver to correct usage information.
2024-05-13 10:22:12 -07:00

41 lines
971 B
Bash
Executable File

#!/usr/bin/env bash
cd test 1> /dev/null
length=$(($#-1))
array=${@:1:$length}
PARAM=$array
FILE=${@: -1}
if [[ $FILE == *"test-cases/regression/"* ]]
then
AMOUNT=$(./regression_tests countall ../$FILE)
RET=$?
if [ $RET -ne 0 ]; then
echo ":test-result: SKIP: json is not enabled. (regression/$RET) ../$FILE"
exit 0
fi
for i in `seq 1 $AMOUNT`; do
$VALGRIND $PARAM ./regression_tests ../$FILE:$i
RET=$?
if [ $RET -ne 0 ]; then
echo ":test-result: FAIL possible segfault/$RET: ../$FILE:$i"
fi
echo $VALGRIND $PARAM ./regression_tests ../$FILE:$i
done;
else
$VALGRIND $PARAM ./unit_tests ../$FILE
RET=$?
if [ $RET -eq 127 ]
then
echo ":test-result: SKIP: json is not enabled. (unit/$RET) ../$FILE"
elif [ $RET -ne 0 ]
then
echo ":test-result: FAIL possible segfault: (unit/$RET) ../$FILE"
fi
fi
cd - 1> /dev/null