summaryrefslogtreecommitdiff
path: root/debian/run-regression-tests.sh
diff options
context:
space:
mode:
Diffstat (limited to 'debian/run-regression-tests.sh')
-rwxr-xr-xdebian/run-regression-tests.sh60
1 files changed, 60 insertions, 0 deletions
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 @@
1#!/bin/sh
2
3set -e
4
5saved_dir=$(pwd)
6regression_test_dir="debian/regression-test-output"
7
8cleanup() {
9 cd ${saved_dir}
10 rm -rf ${regression_test_dir}
11 if [ -f regress/cred.c.bak ]; then
12 mv -f regress/cred.c.bak regress/cred.c
13 fi
14}
15
16trap cleanup 0 INT QUIT ABRT PIPE TERM
17
18# regress/ tests are only included when the build type is set to Debug, so
19# we build it again in a separate directory as we don't want a Debug build
20# in the shipped packages
21rm -rf ${regression_test_dir}
22mkdir ${regression_test_dir}
23echo "Running regression tests"
24cd ${regression_test_dir}
25cmake -DCMAKE_BUILD_TYPE=Debug ../../
26make
27echo "SUCCESS: regression tests passed"
28
29# the way the tests are run, by just calling the built binary in a
30# post-build hook, makes them super silent. The fact that a binary is even
31# being called after the build is not shown. To be sure we really ran the
32# tests, let's do it one more time but with an injected failure
33cd ${saved_dir}
34echo "Injecting a failure and running regression tests again"
35sed -r -i.bak 's,exit\(0\);,assert(1 == 0); exit(0); /* force failure */,' regress/cred.c
36# if the next grep fails, then the sed above didn't make any changes, and
37# we should bail as the "force failure" case isn't valid anymore
38result=0
39grep "force failure" -q regress/cred.c || result=$?
40if [ "$result" -ne 0 ]; then
41 echo "ERROR: failure was not injected correctly into regress/cred.c"
42 exit $result
43fi
44rm -rf ${regression_test_dir}
45mkdir ${regression_test_dir}
46cd ${regression_test_dir}
47cmake -DCMAKE_BUILD_TYPE=Debug ../../
48result=0
49make || result=$?
50if [ "$result" -ne 0 ]; then
51 echo "SUCCESS: the expected failure happened"
52 result=0
53else
54 echo "ERROR: Expected regression test failure did not happen"
55 result=1
56fi
57cd ${saved_dir}
58rm -rf ${regression_test_dir}
59mv -f regress/cred.c.bak regress/cred.c
60exit $result