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
19static void verify_execle(void)
20{
21	pid_t pid;
22	char path[512];
23	char ipc_env_var[1024];
24
25	sprintf(ipc_env_var, IPC_ENV_VAR "=%s", getenv(IPC_ENV_VAR));
26	char *const envp[] = { "LTP_TEST_ENV_VAR=test", ipc_env_var, NULL };
27
28	if (tst_get_path("execle01_child", path, sizeof(path)))
29		tst_brk(TCONF, "Couldn't find execle01_child in $PATH");
30
31	pid = SAFE_FORK();
32	if (pid == 0) {
33		TEST(execle(path, "execle01_child", "canary", NULL, envp));
34		tst_brk(TFAIL | TTERRNO,
35			"Failed to execute execl01_child");
36	}
37}
38
39static struct tst_test test = {
40	.forks_child = 1,
41	.child_needs_reinit = 1,
42	.test_all = verify_execle,
43};
44