1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Copyright (c) 2018 Cyril Hrubis <chrubis@suse.cz>
4 */
5
6/*
7 * Assert that tst_res() from child started by exec() is propagated to the main
8 * test process.
9 *
10 * This test should be executed as:
11 * $ PATH=$PATH:$PWD ./test_exec
12 */
13
14#define _GNU_SOURCE
15#include <unistd.h>
16#include "tst_test.h"
17
18static void do_test(void)
19{
20	char *const argv[] = {"test_exec_child", NULL};
21	char path[4096];
22
23	if (tst_get_path("test_exec_child", path, sizeof(path)))
24		tst_brk(TCONF, "Couldn't find test_exec_child in $PATH");
25
26	execve(path, argv, environ);
27
28	tst_res(TFAIL | TERRNO, "EXEC!");
29}
30
31static struct tst_test test = {
32	.test_all = do_test,
33	.child_needs_reinit = 1,
34};
35