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"
21 prepare (int argc
, char *argv
[])
25 asprintf (&buf
, "cp %s %n%s-copy", argv
[0], &off
, argv
[0]);
28 puts ("asprintf failed");
31 if (system (buf
) != 0)
33 puts ("system failed");
37 /* Make it not executable. */
39 if (chmod (copy
, 0666) != 0)
41 puts ("chmod failed");
52 /* Make sure we do not find a binary with the name we are going to
54 char *bindir
= strdupa (copy
);
55 bindir
= canonicalize_file_name (dirname (bindir
));
58 puts ("canonicalize_file_name failed");
62 asprintf (&path
, "%s:../libio:../elf", bindir
);
65 puts ("asprintf failed");
69 setenv ("PATH", path
, 1);
71 char *argv
[] = { basename (copy
), NULL
};
73 execvp (argv
[0], argv
);
77 printf ("errno = %d (%m), expected EACCES\n", errno
);