Commit 2442f595 authored by Thomas Wood's avatar Thomas Wood

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: default avatarThomas Wood <thomas.wood@intel.com>
parent 9edf293c
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment