summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Hasenack <andreas@canonical.com>2020-04-27 17:09:27 -0300
committerAndreas Hasenack <andreas@canonical.com>2020-04-27 17:38:15 -0300
commit6bd7c73e6075656083b0e523ac605bce9c638db6 (patch)
tree63ce78520ad51bed7261fa1e2ecfe2a5ce259258
parent175264ca17ec8838adfb570d72cabcf5cf2a560f (diff)
* d/rules, d/run-regression-tests.sh: run regression tests with
a script
-rwxr-xr-xdebian/rules21
-rwxr-xr-xdebian/run-regression-tests.sh60
2 files changed, 61 insertions, 20 deletions
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:
16 dh_makeshlibs -- -c4 16 dh_makeshlibs -- -c4
17 17
18override_dh_auto_test: 18override_dh_auto_test:
19 # regress/ tests are only included when the build type is set to Debug, so 19 debian/run-regression-tests.sh
20 # we build it again in a separate directory as we don't want a Debug build
21 # in the shipped packages
22 mkdir good-case
23 echo "Running regression tests"
24 cd good-case; cmake -DCMAKE_BUILD_TYPE=Debug ..; make
25 echo "SUCCESS: regression tests passed"
26 # the way the tests are run, by just calling the built binary in a
27 # post-build hook, makes them super silent. The fact that a binary is even
28 # being called after the build is not shown. To be sure we really ran the
29 # tests, let's do it one more time but with an injected failure
30 echo "Injecting a failure and running regression tests again"
31 sed -r -i 's,exit\(0\);,assert(1 == 0); exit(0); /* force failure */,' regress/cred.c
32 # if the next grep fails, then the sed above didn't make any changes, and
33 # we should bail as the "force failure" case isn't valid anymore
34 grep "force failure" -q regress/cred.c
35 mkdir bad-case
36 cd bad-case; cmake -DCMAKE_BUILD_TYPE=Debug ..; \
37 make && { echo "ERROR: Expected regression test failure did not happen"; exit 1; } \
38 || echo "SUCCESS: the expected failure happened"
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