Add MAP_SHARED_VALIDATE from Linux 4.15.
[glibc.git] / posix / tst-execl2.c
blob5b74959ef81d905188fb961ac23079b0acc98f12
1 #include <errno.h>
2 #include <stdio.h>
3 #include <unistd.h>
4 #include <sys/stat.h>
7 static void prepare (int argc, char *argv[]);
8 static int do_test (void);
9 #define PREPARE(argc, argv) prepare (argc, argv)
10 #define TEST_FUNCTION do_test ()
11 #include "../test-skeleton.c"
14 static char *copy;
16 static void
17 prepare (int argc, char *argv[])
19 char *buf;
20 int off;
21 asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]);
22 if (buf == NULL)
24 puts ("asprintf failed");
25 exit (1);
27 if (system (buf) != 0)
29 puts ("system failed");
30 exit (1);
33 /* Make it not executable. */
34 copy = buf + off;
35 if (chmod (copy, 0666) != 0)
37 puts ("chmod failed");
38 exit (1);
41 add_temp_file (copy);
45 static int
46 do_test (void)
48 errno = 0;
49 execl (copy, copy, NULL);
51 if (errno != EACCES)
53 printf ("errno = %d (%m), expected EACCES\n", errno);
54 return 1;
57 return 0;