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