Exemplo n.º 1
0
Arquivo: mmap1.c Projeto: kraj/ltp
static void setup(void)
{
	struct sigaction sigptr;

	page_sz = getpagesize();

	/*
	 * Used as hint for mmap thread, so it doesn't interfere
	 * with other potential (temporary) mappings from libc
	 */
	distant_area = SAFE_MMAP(0, DISTANT_MMAP_SIZE, PROT_WRITE | PROT_READ,
			MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
	SAFE_MUNMAP(distant_area, (size_t)DISTANT_MMAP_SIZE);
	distant_area += DISTANT_MMAP_SIZE / 2;

	if (tst_parse_float(str_exec_time, &exec_time, 0, FLT_MAX)) {
		tst_brk(TBROK, "Invalid number for exec_time '%s'",
			str_exec_time);
	}

	sigptr.sa_sigaction = sig_handler;
	sigemptyset(&sigptr.sa_mask);
	sigptr.sa_flags = SA_SIGINFO | SA_NODEFER;
	SAFE_SIGACTION(SIGSEGV, &sigptr, NULL);

	tst_set_timeout((int)(exec_time * 3600));
}
Exemplo n.º 2
0
static int fork_testrun(void)
{
	int status;

	if (tst_test->timeout)
		tst_set_timeout(tst_test->timeout);
	else
		tst_set_timeout(300);

	SAFE_SIGNAL(SIGINT, sigint_handler);

	test_pid = fork();
	if (test_pid < 0)
		tst_brk(TBROK | TERRNO, "fork()");

	if (!test_pid) {
		SAFE_SIGNAL(SIGALRM, SIG_DFL);
		SAFE_SIGNAL(SIGUSR1, SIG_DFL);
		SAFE_SIGNAL(SIGINT, SIG_DFL);
		SAFE_SETPGID(0, 0);
		testrun();
	}

	SAFE_WAITPID(test_pid, &status, 0);
	alarm(0);
	SAFE_SIGNAL(SIGINT, SIG_DFL);

	if (WIFEXITED(status) && WEXITSTATUS(status))
		return WEXITSTATUS(status);

	if (WIFSIGNALED(status) && WTERMSIG(status) == SIGKILL) {
		tst_res(TINFO, "If you are running on slow machine, "
			       "try exporting LTP_TIMEOUT_MUL > 1");
		tst_brk(TBROK, "Test killed! (timeout?)");
	}

	if (WIFSIGNALED(status))
		tst_brk(TBROK, "Test killed by %s!", tst_strsig(WTERMSIG(status)));

	return 0;
}