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

extern int helper_segfault_pid;

# define TEST_ASSERT_SEGFAULT(code) do {    \
	fflush(stdout);                         \
	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