diff options
Diffstat (limited to 'src/tests/qemu/init.c')
-rw-r--r-- | src/tests/qemu/init.c | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/src/tests/qemu/init.c b/src/tests/qemu/init.c index 8d783e9..51e5dde 100644 --- a/src/tests/qemu/init.c +++ b/src/tests/qemu/init.c @@ -1,6 +1,6 @@ -/* SPDX-License-Identifier: GPL-2.0 - * - * Copyright (C) 2015-2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. */ #define _GNU_SOURCE @@ -111,17 +111,23 @@ static void enable_logging(void) int fd; pretty_message("[+] Enabling logging..."); fd = open("/proc/sys/kernel/printk", O_WRONLY); - if (fd < 0) - panic("open(printk)"); - if (write(fd, "9\n", 2) != 2) - panic("write(printk)"); - close(fd); + if (fd >= 0) { + if (write(fd, "9\n", 2) != 2) + panic("write(printk)"); + close(fd); + } + fd = open("/proc/sys/debug/exception-trace", O_WRONLY); + if (fd >= 0) { + if (write(fd, "1\n", 2) != 2) + panic("write(exception-trace)"); + close(fd); + } fd = open("/proc/sys/kernel/panic_on_warn", O_WRONLY); - if (fd < 0) - return; /* < 3.18 doesn't have it */ - if (write(fd, "1\n", 2) != 2) - panic("write(panic_on_warn)"); - close(fd); + if (fd >= 0) { + if (write(fd, "1\n", 2) != 2) + panic("write(panic_on_warn)"); + close(fd); + } } static void kmod_selftests(void) @@ -152,7 +158,7 @@ static void kmod_selftests(void) } fclose(file); if (!success) { - puts("\x1b[31m\x1b[1m[-] Tests failed! :-(\x1b[0m"); + puts("\x1b[31m\x1b[1m[-] Tests failed! \u2639\x1b[0m"); poweroff(); } } @@ -197,8 +203,19 @@ static void launch_tests(void) if (write(fd, "success\n", 8) != 8) panic("write(success_dev)"); close(fd); - } else - puts("\x1b[31m\x1b[1m[-] Tests failed! :-(\x1b[0m"); + } else { + const char *why = "unknown cause"; + int what = -1; + + if (WIFEXITED(status)) { + why = "exit code"; + what = WEXITSTATUS(status); + } else if (WIFSIGNALED(status)) { + why = "signal"; + what = WTERMSIG(status); + } + printf("\x1b[31m\x1b[1m[-] Tests failed with %s %d! \u2639\x1b[0m\n", why, what); + } } static void ensure_console(void) |