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.sh64
1 files changed, 64 insertions, 0 deletions
diff --git a/debian/run-regression-tests.sh b/debian/run-regression-tests.sh
new file mode 100755
index 0000000..1ce5bf8
--- /dev/null
+++ b/debian/run-regression-tests.sh
@@ -0,0 +1,64 @@
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
18eval "$(dpkg-buildflags --export=sh)"
19export CFLAGS="$CFLAGS $CPPFLAGS"
20export CXXFLAGS="$CFLAGS $CXXFLAGS"
21
22# regress/ tests are only included when the build type is set to Debug, so
23# we build it again in a separate directory as we don't want a Debug build
24# in the shipped packages
25rm -rf ${regression_test_dir}
26mkdir ${regression_test_dir}
27echo "Running regression tests"
28cd ${regression_test_dir}
29cmake -DCMAKE_BUILD_TYPE=Debug ../../
30make
31echo "SUCCESS: regression tests passed"
32
33# the way the tests are run, by just calling the built binary in a
34# post-build hook, makes them super silent. The fact that a binary is even
35# being called after the build is not shown. To be sure we really ran the
36# tests, let's do it one more time but with an injected failure
37cd ${saved_dir}
38echo "Injecting a failure and running regression tests again"
39sed -r -i.bak 's,exit\(0\);,assert(1 == 0); exit(0); /* force failure */,' regress/cred.c
40# if the next grep fails, then the sed above didn't make any changes, and
41# we should bail as the "force failure" case isn't valid anymore
42result=0
43grep "force failure" -q regress/cred.c || result=$?
44if [ "$result" -ne 0 ]; then
45 echo "ERROR: failure was not injected correctly into regress/cred.c"
46 exit $result
47fi
48rm -rf ${regression_test_dir}
49mkdir ${regression_test_dir}
50cd ${regression_test_dir}
51cmake -DCMAKE_BUILD_TYPE=Debug ../../
52result=0
53make || result=$?
54if [ "$result" -ne 0 ]; then
55 echo "SUCCESS: the expected failure happened"
56 result=0
57else
58 echo "ERROR: Expected regression test failure did not happen"
59 result=1
60fi
61cd ${saved_dir}
62rm -rf ${regression_test_dir}
63mv -f regress/cred.c.bak regress/cred.c
64exit $result