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);
36 fname = mktemp (fname);
38 close(mkstemp(fname));
41 if (fname == NULL || *fname == '\0')
42 error (EXIT_FAILURE, errno, "cannot create temp file name");
43 if (symlink ("bug-glob1-does-not-exist", fname) != 0)
48 error (EXIT_FAILURE, errno, "cannot create symlink");
50 add_temp_file (fname);
61 e = glob (fname, 0, NULL, &gl);
64 printf ("glob(\"%s\") succeeded when it should not have\n", fname);
69 size_t fnamelen = strlen (fname);
70 char buf[fnamelen + 2];
73 buf[fnamelen - 1] = '?';
74 e = glob (buf, 0, NULL, &gl);
77 printf ("glob(\"%s\") succeeded when it should not have\n", buf);
84 buf[fnamelen + 1] = '\0';
85 e = glob (buf, 0, NULL, &gl);
88 printf ("glob(\"%s\") succeeded when it should not have\n", buf);