1 | #include <stdio.h> |
---|---|
2 | #include <stdlib.h> |
3 | #include <string.h> |
4 | #include <unistd.h> |
5 | #include <sys/stat.h> |
6 | |
7 | |
8 | static void do_prepare (void); |
9 | #define PREPARE(argc, argv) do_prepare () |
10 | static 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 | |
19 | static char *fname; |
20 | |
21 | static void |
22 | do_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 | |
31 | static int |
32 | do_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 |