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