From 52846a7ca04b0e0f1541c0db71ead44a422a9fb4 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sat, 5 Nov 2016 17:43:58 +0100 Subject: qemu: fail if module selftests fail Signed-off-by: Jason A. Donenfeld --- src/tests/qemu/init.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/tests/qemu/init.c') 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) -- cgit v1.2.3