• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2018 Linux Test Project
3  * Copyright (C) 2015 Cyril Hrubis <chrubis@suse.cz>
4  * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
5  *    AUTHOR		: William Roske
6  *    CO-PILOT		: Dave Fenner
7  *    DATE STARTED	: 06/01/02
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #include <errno.h>
24 #include <string.h>
25 #include <signal.h>
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <sys/types.h>
29 #include <sys/wait.h>
30 
31 #include "tst_test.h"
32 
33 #define IPC_ENV_VAR "LTP_IPC_PATH"
34 
verify_execve(void)35 static void verify_execve(void)
36 {
37 	pid_t pid;
38 	char *const args[] = {"execve01_child", "canary", NULL};
39 	char path[512];
40 
41 	char ipc_env_var[1024];
42 	sprintf(ipc_env_var, IPC_ENV_VAR "=%s", getenv(IPC_ENV_VAR));
43 
44 	char *const envp[] = { "LTP_TEST_ENV_VAR=test", ipc_env_var, NULL };
45 
46 	if (tst_get_path("execve01_child", path, sizeof(path)))
47 		tst_brk(TCONF, "Couldn't find execve01_child in $PATH");
48 
49 	pid = SAFE_FORK();
50 	if (pid == 0) {
51 		execve(path, args, envp);
52 		tst_brk(TFAIL | TERRNO, "Failed to execute execl01_child");
53 	}
54 }
55 
56 static struct tst_test test = {
57 	.forks_child = 1,
58 	.child_needs_reinit = 1,
59 	.test_all = verify_execve,
60 };
61