1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include <unistd.h>
5#include <sys/stat.h>
6
7
8static void do_prepare (void);
9#define PREPARE(argc, argv) do_prepare ()
10static int do_test (void);
11#define TEST_FUNCTION do_test ()
12
13#include "../test-skeleton.c"
14
15#ifndef EXECVP
16# define EXECVP(file, argv) execvp (file, argv)
17#endif
18
19static char *fname;
20
21static void
22do_prepare (void)
23{
24 int fd = create_temp_file (base: "testscript", filename: &fname);
25 dprintf (fd, "echo foo\n");
26 fchmod (fd: fd, mode: 0700);
27 close (fd: fd);
28}
29
30
31static int
32do_test (void)
33{
34 if (setenv (name: "PATH", value: test_dir, replace: 1) != 0)
35 {
36 puts (s: "setenv failed");
37 return 1;
38 }
39
40 char *argv[] = { fname, NULL };
41 EXECVP (basename (fname), argv);
42
43 /* If we come here, the execvp call failed. */
44 return 1;
45}
46

source code of glibc/posix/tst-execvp3.c