summaryrefslogtreecommitdiffhomepage
path: root/src/tests/qemu/init.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2016-11-05 17:43:58 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2016-11-05 17:48:46 +0100
commit52846a7ca04b0e0f1541c0db71ead44a422a9fb4 (patch)
treeedd6bf9c003602407f6893163931ff8058d431e2 /src/tests/qemu/init.c
parent8772b00d3ad7bb74abf69ba72d71c52e4656f545 (diff)
qemu: fail if module selftests fail
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/tests/qemu/init.c')
-rw-r--r--src/tests/qemu/init.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/tests/qemu/init.c b/src/tests/qemu/init.c
index a8a4a4b..04ab8fd 100644
--- a/src/tests/qemu/init.c
+++ b/src/tests/qemu/init.c
@@ -109,7 +109,8 @@ static void enable_logging(void)
static void kmod_selftests(void)
{
FILE *file;
- char line[2048], *start;
+ char line[2048], *start, *pass;
+ bool success = true;
pretty_message("[+] Module self-tests:");
file = fopen("/proc/kmsg", "r");
if (!file)
@@ -124,9 +125,18 @@ static void kmod_selftests(void)
*strchrnul(start, '\n') = '\0';
if (strstr(start, "WireGuard loaded."))
break;
- printf(" \x1b[32m* %s\x1b[0m\n", start);
+ pass = strstr(start, ": pass");
+ if (!pass || pass[6] != '\0') {
+ success = false;
+ printf(" \x1b[31m* %s\x1b[0m\n", start);
+ } else
+ printf(" \x1b[32m* %s\x1b[0m\n", start);
}
fclose(file);
+ if (!success) {
+ puts("\x1b[31m\x1b[1m[-] Tests failed! :-(\x1b[0m");
+ poweroff();
+ }
}
static void launch_tests(void)