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