blob: 531fab227b6eca5ca5744d84bd1b9cf05430c0c9 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#include <errno.h>
2#include <stdio.h>
3#include <stdlib.h>
4#include <string.h>
5#include <unistd.h>
6#include <sys/stat.h>
7
8static int
9do_test (void)
10{
11 char buf[40] = "/usr/bin/does-not-exist";
12 size_t stemlen = strlen (buf);
13 struct stat64 st;
14 int cnt = 0;
15 while (stat64 (buf, &st) != -1 || errno != ENOENT
16 || stat64 (buf + 4, &st) != -1 || errno != ENOENT)
17 {
18 if (cnt++ == 100)
19 {
20 puts ("cannot find a unique file name");
21 return 0;
22 }
23
24 strcpy (buf + stemlen, ".XXXXXX");
25 mktemp (buf);
26 }
27
28 unsetenv ("PATH");
29 char *argv[] = { buf + 9, NULL };
30 execvp (argv[0], argv);
31 return 0;
32}
33
34#define TEST_FUNCTION do_test ()
35#include "../test-skeleton.c"