1 /* Test case for globbing dangling symlink. By Ulrich Drepper. */
11 static void prepare (int argc, char *argv[]);
12 #define PREPARE prepare
13 static int do_test (void);
14 #define TEST_FUNCTION do_test ()
16 #include "../test-skeleton.c"
22 prepare (int argc, char *argv[])
25 error (EXIT_FAILURE, 0, "missing argument");
27 size_t len = strlen (argv[1]);
28 static const char ext[] = "globXXXXXX";
29 fname = malloc (len + sizeof (ext));
31 error (EXIT_FAILURE, errno, "cannot create temp file");
33 strcpy (stpcpy (fname, argv[1]), ext);
34 fname = mktemp (fname);
35 if (fname == NULL || *fname == '\0')
36 error (EXIT_FAILURE, errno, "cannot create temp file name");
37 if (symlink ("bug-glob1-does-not-exist", fname) != 0)
42 error (EXIT_FAILURE, errno, "cannot create symlink");
44 add_temp_file (fname);
55 e = glob (fname, 0, NULL, &gl);
58 printf ("glob(\"%s\") succeeded\n", fname);
63 size_t fnamelen = strlen (fname);
64 char buf[fnamelen + 2];
67 buf[fnamelen - 1] = '?';
68 e = glob (buf, 0, NULL, &gl);
71 printf ("glob(\"%s\") succeeded\n", buf);
78 buf[fnamelen + 1] = '\0';
79 e = glob (buf, 0, NULL, &gl);
82 printf ("glob(\"%s\") succeeded\n", buf);