summaryrefslogtreecommitdiffstats
path: root/debian/run-regression-tests.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 20:45:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 20:45:25 +0000
commit0779334c7ef83d40fc0cef69b454a2c2e3b5ed57 (patch)
treedb4c81ea6e91d3bcb5c31f512dc16abdde6b3655 /debian/run-regression-tests.sh
parentAdding upstream version 1.14.0. (diff)
downloadlibfido2-0779334c7ef83d40fc0cef69b454a2c2e3b5ed57.tar.xz
libfido2-0779334c7ef83d40fc0cef69b454a2c2e3b5ed57.zip
Adding debian version 1.14.0-1.debian/1.14.0-1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-xdebian/run-regression-tests.sh63
1 files changed, 63 insertions, 0 deletions
diff --git a/debian/run-regression-tests.sh b/debian/run-regression-tests.sh
new file mode 100755
index 0000000..89cb32c
--- /dev/null
+++ b/debian/run-regression-tests.sh
@@ -0,0 +1,63 @@
+#!/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
+
+eval "$(dpkg-buildflags --export=sh)"
+export CFLAGS="$CFLAGS $CPPFLAGS"
+export CXXFLAGS="$CFLAGS $CXXFLAGS"
+
+# 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
+make regress
+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
+cd ${regression_test_dir}
+make
+result=0
+make regress || 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