source: branches/libc-0.6/src/libctests/glibc/posix/tst-execvp3.c

Last change on this file was 2135, checked in by bird, 20 years ago

libc adjustments / config.

  • Property cvs2svn:cvs-rev set to 1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 838 bytes
Line 
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
16static char *fname;
17
18static void
19do_prepare (void)
20{
21 int fd = create_temp_file ("testscript", &fname);
22#if 0
23 dprintf (fd, "echo foo\n");
24 fchmod (fd, 0700);
25 close (fd);
26#else
27 FILE *pf = fdopen (fd, "w+");
28 fprintf (pf, "echo foo\n");
29 fflush (pf);
30 fchmod (fd, 0700);
31 fclose (pf);
32#endif
33}
34
35
36static int
37do_test (void)
38{
39 if (setenv ("PATH", test_dir, 1) != 0)
40 {
41 puts ("setenv failed");
42 return 1;
43 }
44
45 char *argv[] = { fname, NULL };
46 execvp (basename (fname), argv);
47
48 /* If we come here, the execvp call failed. */
49 return 1;
50}
Note: See TracBrowser for help on using the repository browser.