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"
18 # define EXECVP(file, argv) execvp (file, argv)
24 prepare (int argc
, char *argv
[])
28 asprintf (&buf
, "cp %s %n%s-copy", argv
[0], &off
, argv
[0]);
31 puts ("asprintf failed");
34 if (system (buf
) != 0)
36 puts ("system failed");
40 /* Make it not executable. */
42 if (chmod (copy
, 0666) != 0)
44 puts ("chmod failed");
55 /* Make sure we do not find a binary with the name we are going to
57 char *bindir
= strdupa (copy
);
58 bindir
= canonicalize_file_name (dirname (bindir
));
61 puts ("canonicalize_file_name failed");
65 asprintf (&path
, "%s:../libio:../elf", bindir
);
68 puts ("asprintf failed");
72 setenv ("PATH", path
, 1);
74 char *argv
[] = { basename (copy
), NULL
};
76 EXECVP (argv
[0], argv
);
80 printf ("errno = %d (%m), expected EACCES\n", errno
);