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 Linux Test Project
4*49cdfc7eSAndroid Build Coastguard Worker * Copyright (C) 2015 Cyril Hrubis <[email protected]>
5*49cdfc7eSAndroid Build Coastguard Worker * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
6*49cdfc7eSAndroid Build Coastguard Worker * AUTHOR : William Roske
7*49cdfc7eSAndroid Build Coastguard Worker * CO-PILOT : Dave Fenner
8*49cdfc7eSAndroid Build Coastguard Worker */
9*49cdfc7eSAndroid Build Coastguard Worker
10*49cdfc7eSAndroid Build Coastguard Worker #include <sys/types.h>
11*49cdfc7eSAndroid Build Coastguard Worker #include <sys/wait.h>
12*49cdfc7eSAndroid Build Coastguard Worker #include <errno.h>
13*49cdfc7eSAndroid Build Coastguard Worker #include <stdlib.h>
14*49cdfc7eSAndroid Build Coastguard Worker #include <string.h>
15*49cdfc7eSAndroid Build Coastguard Worker #include <stdio.h>
16*49cdfc7eSAndroid Build Coastguard Worker
17*49cdfc7eSAndroid Build Coastguard Worker #include "tst_test.h"
18*49cdfc7eSAndroid Build Coastguard Worker
verify_execle(void)19*49cdfc7eSAndroid Build Coastguard Worker static void verify_execle(void)
20*49cdfc7eSAndroid Build Coastguard Worker {
21*49cdfc7eSAndroid Build Coastguard Worker pid_t pid;
22*49cdfc7eSAndroid Build Coastguard Worker char path[512];
23*49cdfc7eSAndroid Build Coastguard Worker char ipc_env_var[1024];
24*49cdfc7eSAndroid Build Coastguard Worker
25*49cdfc7eSAndroid Build Coastguard Worker sprintf(ipc_env_var, IPC_ENV_VAR "=%s", getenv(IPC_ENV_VAR));
26*49cdfc7eSAndroid Build Coastguard Worker char *const envp[] = { "LTP_TEST_ENV_VAR=test", ipc_env_var, NULL };
27*49cdfc7eSAndroid Build Coastguard Worker
28*49cdfc7eSAndroid Build Coastguard Worker if (tst_get_path("execle01_child", path, sizeof(path)))
29*49cdfc7eSAndroid Build Coastguard Worker tst_brk(TCONF, "Couldn't find execle01_child in $PATH");
30*49cdfc7eSAndroid Build Coastguard Worker
31*49cdfc7eSAndroid Build Coastguard Worker pid = SAFE_FORK();
32*49cdfc7eSAndroid Build Coastguard Worker if (pid == 0) {
33*49cdfc7eSAndroid Build Coastguard Worker TEST(execle(path, "execle01_child", "canary", NULL, envp));
34*49cdfc7eSAndroid Build Coastguard Worker tst_brk(TFAIL | TTERRNO,
35*49cdfc7eSAndroid Build Coastguard Worker "Failed to execute execl01_child");
36*49cdfc7eSAndroid Build Coastguard Worker }
37*49cdfc7eSAndroid Build Coastguard Worker }
38*49cdfc7eSAndroid Build Coastguard Worker
39*49cdfc7eSAndroid Build Coastguard Worker static struct tst_test test = {
40*49cdfc7eSAndroid Build Coastguard Worker .forks_child = 1,
41*49cdfc7eSAndroid Build Coastguard Worker .child_needs_reinit = 1,
42*49cdfc7eSAndroid Build Coastguard Worker .test_all = verify_execle,
43*49cdfc7eSAndroid Build Coastguard Worker };
44