]> git.ipfire.org Git - thirdparty/glibc.git/blame - posix/tst-execvp3.c
Fix testing with read-only source directory.
[thirdparty/glibc.git] / posix / tst-execvp3.c
CommitLineData
506cbf1f
UD
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
1eb89306
AZ
15#ifndef EXECVP
16# define EXECVP(file, argv) execvp (file, argv)
17#endif
506cbf1f
UD
18
19static char *fname;
20
21static void
22do_prepare (void)
23{
24 int fd = create_temp_file ("testscript", &fname);
25 dprintf (fd, "echo foo\n");
26 fchmod (fd, 0700);
27 close (fd);
28}
29
30
31static int
32do_test (void)
33{
34 if (setenv ("PATH", test_dir, 1) != 0)
35 {
36 puts ("setenv failed");
37 return 1;
38 }
39
40 char *argv[] = { fname, NULL };
1eb89306 41 EXECVP (basename (fname), argv);
506cbf1f
UD
42
43 /* If we come here, the execvp call failed. */
44 return 1;
45}