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>
This commit is contained in:
Thomas Wood 2015-09-24 11:35:19 +01:00
parent 9edf293c45
commit 2442f595d2

View File

@ -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: