summaryrefslogtreecommitdiff
path: root/lib/tests
diff options
context:
space:
mode:
authorThomas Wood <thomas.wood@intel.com>2015-09-24 11:35:19 +0100
committerThomas Wood <thomas.wood@intel.com>2015-09-24 14:23:44 +0100
commit2442f595d23b919bdc61d117b85a55304d6535a5 (patch)
tree90cf4ac66d37a1bf581da7f1bc85815b719d12a8 /lib/tests
parent9edf293c4566ffdc0937c800035dd2d215355674 (diff)
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 <thomas.wood@intel.com>
Diffstat (limited to 'lib/tests')
-rw-r--r--lib/tests/igt_segfault.c7
1 files changed, 6 insertions, 1 deletions
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 <signal.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <sys/types.h>
@@ -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: