Adapt collation in th_TH locale to use the iso14651_t1_common file and sync the colla...
[glibc.git] / posix / tst-execvp2.c
blobf6c0cb4d989a965b003691ca2ce67a59350812e3
1 #include <errno.h>
2 #include <libgen.h>
3 #undef basename
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include <unistd.h>
8 #include <sys/stat.h>
11 static void prepare (int argc, char *argv[]);
12 static int do_test (void);
13 #define PREPARE(argc, argv) prepare (argc, argv)
14 #define TEST_FUNCTION do_test ()
15 #include "../test-skeleton.c"
17 #ifndef EXECVP
18 # define EXECVP(file, argv) execvp (file, argv)
19 #endif
21 static char *copy;
23 static void
24 prepare (int argc, char *argv[])
26 char *buf;
27 int off;
29 buf = xasprintf ("cp %s %n%s-copy", argv[0], &off, argv[0]);
30 if (system (buf) != 0)
32 puts ("system failed");
33 exit (1);
36 /* Make it not executable. */
37 copy = buf + off;
38 if (chmod (copy, 0666) != 0)
40 puts ("chmod failed");
41 exit (1);
44 add_temp_file (copy);
48 static int
49 do_test (void)
51 /* Make sure we do not find a binary with the name we are going to
52 use. */
53 char *bindir = strdupa (copy);
54 bindir = canonicalize_file_name (dirname (bindir));
55 if (bindir == NULL)
57 puts ("canonicalize_file_name failed");
58 return 1;
61 char *path = xasprintf ("%s:../libio:../elf", bindir);
63 setenv ("PATH", path, 1);
65 char *argv[] = { basename (copy), NULL };
66 errno = 0;
67 EXECVP (argv[0], argv);
69 if (errno != EACCES)
71 printf ("errno = %d (%m), expected EACCES\n", errno);
72 return 1;
75 return 0;