From 2442f595d23b919bdc61d117b85a55304d6535a5 Mon Sep 17 00:00:00 2001 From: Thomas Wood Date: Thu, 24 Sep 2015 11:35:19 +0100 Subject: lib/tests: explicitly raise SIGSEGV Dereferencing a NULL pointer is undefined behaviour and may not always result in a segmentation fault. Explicitly raise the SIGSEGV signal to test handling of this signal. v2: include signal.h (Derek Morton) Signed-off-by: Thomas Wood --- lib/tests/igt_segfault.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/tests') diff --git a/lib/tests/igt_segfault.c b/lib/tests/igt_segfault.c index b420b1a2..d07677da 100644 --- a/lib/tests/igt_segfault.c +++ b/lib/tests/igt_segfault.c @@ -34,6 +34,7 @@ * 4. Test a crashing subtest preceeding a passing subtest is reported. */ +#include #include #include #include @@ -57,11 +58,15 @@ bool runc; char test[] = "test"; char *argv_run[] = { test }; +static void crashme(void) +{ + raise(SIGSEGV); +} + static int do_fork(void) { int pid, status; int argc; - void (*crashme)(void) = NULL; switch (pid = fork()) { case -1: -- cgit v1.2.3