summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2020-05-27 08:12:05 +0000
committerColin Watson <cjwatson@debian.org>2020-05-27 08:12:05 +0000
commit27fd39a8aa267abbcf321ff8d1005f8e0cf03349 (patch)
tree63ce78520ad51bed7261fa1e2ecfe2a5ce259258
parent60f77b13db055394afc9bb066525f6003027aa9c (diff)
parent6bd7c73e6075656083b0e523ac605bce9c638db6 (diff)
Merge branch 'debian-test-at-buildtime' into 'debian/sid'
Run regression tests at build time See merge request auth-team/libfido2!4
-rwxr-xr-xdebian/rules3
-rwxr-xr-xdebian/run-regression-tests.sh60
2 files changed, 63 insertions, 0 deletions
diff --git a/debian/rules b/debian/rules
index 34a5a60..e51a8cc 100755
--- a/debian/rules
+++ b/debian/rules
@@ -14,3 +14,6 @@ override_dh_missing:
14 14
15override_dh_makeshlibs: 15override_dh_makeshlibs:
16 dh_makeshlibs -- -c4 16 dh_makeshlibs -- -c4
17
18override_dh_auto_test:
19 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 @@
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