aboutsummaryrefslogtreecommitdiff
path: root/test/include/helper/helper_segfault.h
blob: 99351af716cc4671515a7fc2d5e0ef3782f11950 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef HELPER_SEGFAULT_H
# define HELPER_SEGFAULT_H

extern int helper_segfault_pid;

# define TEST_ASSERT_SEGFAULT(code) do {    \
	if ((helper_segfault_pid = fork()) < 0) \
		exit(EXIT_FAILURE);                 \
	if (helper_segfault_pid == 0)           \
	{                                       \
		do { code; } while (0);             \
		exit(EXIT_FAILURE);                 \
	}                                       \
	wait(&helper_segfault_pid);             \
	if (WIFSIGNALED(helper_segfault_pid))   \
		TEST_FAIL_MESSAGE("Segfault");      \
} while (0)

#endif