1 /* 2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 3 * AUTHOR : William Roske 4 * CO-PILOT : Dave Fenner 5 * DATE STARTED : 06/01/02 6 * Copyright (C) 2015 Cyril Hrubis <chrubis (at) suse.cz> 7 * 8 * This program is free software; you can redistribute it and/or modify it 9 * under the terms of version 2 of the GNU General Public License as 10 * published by the Free Software Foundation. 11 * 12 * This program is distributed in the hope that it would be useful, but 13 * WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 * 16 * Further, this software is distributed without any warranty that it is 17 * free of the rightful claim of any third person regarding infringement 18 * or the like. Any license provided herein, whether implied or 19 * otherwise, applies only to this software file. Patent licenses, if 20 * any, provided herein do not apply to combinations of this program with 21 * other software, or any other product whatsoever. 22 * 23 * You should have received a copy of the GNU General Public License along 24 * with this program; if not, write the Free Software Foundation, Inc., 25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 26 * 27 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 28 * Mountain View, CA 94043, or: 29 * 30 * http://www.sgi.com 31 * 32 * For further information regarding this notice, see: 33 * 34 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ 35 */ 36 #include <errno.h> 37 #include <string.h> 38 #include <signal.h> 39 #include <stdlib.h> 40 #include <sys/types.h> 41 #include <sys/wait.h> 42 43 #include "test.h" 44 45 static void setup(void); 46 47 char *TCID = "execve01"; 48 int TST_TOTAL = 1; 49 50 int main(int ac, char **av) 51 { 52 int lc; 53 pid_t pid; 54 char *const args[] = {"execve01_child", "canary", NULL}; 55 char *const env[] = {"LTP_TEST_ENV_VAR=test", NULL}; 56 char path[2048]; 57 58 tst_parse_opts(ac, av, NULL, NULL); 59 60 setup(); 61 62 if (tst_get_path("execve01_child", path, sizeof(path))) 63 tst_brkm(TCONF, NULL, "Couldn't find execve01_child in $PATH"); 64 65 for (lc = 0; TEST_LOOPING(lc); lc++) { 66 switch (pid = FORK_OR_VFORK()) { 67 case 0: 68 execve(path, args, env); 69 tst_brkm(TFAIL | TERRNO, NULL, 70 "Failed to execute execl01_child"); 71 case -1: 72 tst_brkm(TBROK, NULL, "fork failed"); 73 default: 74 tst_record_childstatus(NULL, pid); 75 } 76 } 77 78 tst_exit(); 79 } 80 81 static void setup(void) 82 { 83 tst_sig(FORK, DEF_HANDLER, NULL); 84 85 TEST_PAUSE; 86 } 87