From 6bd7c73e6075656083b0e523ac605bce9c638db6 Mon Sep 17 00:00:00 2001 From: Andreas Hasenack Date: Mon, 27 Apr 2020 17:09:27 -0300 Subject: * d/rules, d/run-regression-tests.sh: run regression tests with a script --- debian/rules | 21 +-------------- debian/run-regression-tests.sh | 60 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 20 deletions(-) create mode 100755 debian/run-regression-tests.sh diff --git a/debian/rules b/debian/rules index aa20f30..e51a8cc 100755 --- a/debian/rules +++ b/debian/rules @@ -16,23 +16,4 @@ override_dh_makeshlibs: dh_makeshlibs -- -c4 override_dh_auto_test: - # regress/ tests are only included when the build type is set to Debug, so - # we build it again in a separate directory as we don't want a Debug build - # in the shipped packages - mkdir good-case - echo "Running regression tests" - cd good-case; cmake -DCMAKE_BUILD_TYPE=Debug ..; make - echo "SUCCESS: regression tests passed" - # the way the tests are run, by just calling the built binary in a - # post-build hook, makes them super silent. The fact that a binary is even - # being called after the build is not shown. To be sure we really ran the - # tests, let's do it one more time but with an injected failure - echo "Injecting a failure and running regression tests again" - sed -r -i 's,exit\(0\);,assert(1 == 0); exit(0); /* force failure */,' regress/cred.c - # if the next grep fails, then the sed above didn't make any changes, and - # we should bail as the "force failure" case isn't valid anymore - grep "force failure" -q regress/cred.c - mkdir bad-case - cd bad-case; cmake -DCMAKE_BUILD_TYPE=Debug ..; \ - make && { echo "ERROR: Expected regression test failure did not happen"; exit 1; } \ - || echo "SUCCESS: the expected failure happened" + debian/run-regression-tests.sh diff --git a/debian/run-regression-tests.sh b/debian/run-regression-tests.sh new file mode 100755 index 0000000..2271e5e --- /dev/null +++ b/debian/run-regression-tests.sh @@ -0,0 +1,60 @@ +#!/bin/sh + +set -e + +saved_dir=$(pwd) +regression_test_dir="debian/regression-test-output" + +cleanup() { + cd ${saved_dir} + rm -rf ${regression_test_dir} + if [ -f regress/cred.c.bak ]; then + mv -f regress/cred.c.bak regress/cred.c + fi +} + +trap cleanup 0 INT QUIT ABRT PIPE TERM + +# regress/ tests are only included when the build type is set to Debug, so +# we build it again in a separate directory as we don't want a Debug build +# in the shipped packages +rm -rf ${regression_test_dir} +mkdir ${regression_test_dir} +echo "Running regression tests" +cd ${regression_test_dir} +cmake -DCMAKE_BUILD_TYPE=Debug ../../ +make +echo "SUCCESS: regression tests passed" + +# the way the tests are run, by just calling the built binary in a +# post-build hook, makes them super silent. The fact that a binary is even +# being called after the build is not shown. To be sure we really ran the +# tests, let's do it one more time but with an injected failure +cd ${saved_dir} +echo "Injecting a failure and running regression tests again" +sed -r -i.bak 's,exit\(0\);,assert(1 == 0); exit(0); /* force failure */,' regress/cred.c +# if the next grep fails, then the sed above didn't make any changes, and +# we should bail as the "force failure" case isn't valid anymore +result=0 +grep "force failure" -q regress/cred.c || result=$? +if [ "$result" -ne 0 ]; then + echo "ERROR: failure was not injected correctly into regress/cred.c" + exit $result +fi +rm -rf ${regression_test_dir} +mkdir ${regression_test_dir} +cd ${regression_test_dir} +cmake -DCMAKE_BUILD_TYPE=Debug ../../ +result=0 +make || result=$? +if [ "$result" -ne 0 ]; then + echo "SUCCESS: the expected failure happened" + result=0 +else + echo "ERROR: Expected regression test failure did not happen" + result=1 +fi +cd ${saved_dir} +rm -rf ${regression_test_dir} +mv -f regress/cred.c.bak regress/cred.c +exit $result -- cgit v1.2.3