diff options
author | Andreas Hasenack <andreas@canonical.com> | 2020-03-24 16:09:12 -0300 |
---|---|---|
committer | Andreas Hasenack <andreas@canonical.com> | 2020-04-20 09:51:58 -0300 |
commit | 175264ca17ec8838adfb570d72cabcf5cf2a560f (patch) | |
tree | 8ed07558e96f52a29e4ac1c5630f6ae3176fc51e | |
parent | 60f77b13db055394afc9bb066525f6003027aa9c (diff) |
* d/rules: run regression tests at build time, and one more time
with an injected failure to verify it's caught.
-rwxr-xr-x | debian/rules | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/debian/rules b/debian/rules index 34a5a60..aa20f30 100755 --- a/debian/rules +++ b/debian/rules | |||
@@ -14,3 +14,25 @@ override_dh_missing: | |||
14 | 14 | ||
15 | override_dh_makeshlibs: | 15 | override_dh_makeshlibs: |
16 | dh_makeshlibs -- -c4 | 16 | dh_makeshlibs -- -c4 |
17 | |||
18 | override_dh_auto_test: | ||
19 | # regress/ tests are only included when the build type is set to Debug, so | ||
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" | ||