]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
2005-07-24 Ulrich Drepper <drepper@redhat.com>
authorRoland McGrath <roland@gnu.org>
Mon, 17 Oct 2005 09:05:20 +0000 (09:05 +0000)
committerRoland McGrath <roland@gnu.org>
Mon, 17 Oct 2005 09:05:20 +0000 (09:05 +0000)
[BZ #1125]
* posix/Makefile (tests): Add tst-execvp4.
* posix/tst-execvp4.c: New file.

posix/Makefile
posix/tst-execvp4.c [new file with mode: 0644]

index 6bccab98318194bce166ce1b1e93fd9dc3110c06..a048831416273c19475d6598a3faa113a4527bcf 100644 (file)
@@ -87,7 +87,7 @@ tests         := tstgetopt testfnm runtests runptests      \
                   tst-execvp1 tst-execvp2 tst-execlp1 tst-execlp2 \
                   tst-execv1 tst-execv2 tst-execl1 tst-execl2 \
                   tst-execve1 tst-execve2 tst-execle1 tst-execle2 \
-                  tst-execvp3
+                  tst-execvp3 tst-execvp4
 xtests         := bug-ga2
 ifeq (yes,$(build-shared))
 test-srcs      := globtest
diff --git a/posix/tst-execvp4.c b/posix/tst-execvp4.c
new file mode 100644 (file)
index 0000000..531fab2
--- /dev/null
@@ -0,0 +1,35 @@
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+static int
+do_test (void)
+{
+  char buf[40] = "/usr/bin/does-not-exist";
+  size_t stemlen = strlen (buf);
+  struct stat64 st;
+  int cnt = 0;
+  while (stat64 (buf, &st) != -1 || errno != ENOENT
+        || stat64 (buf + 4, &st) != -1 || errno != ENOENT)
+    {
+      if (cnt++ == 100)
+       {
+         puts ("cannot find a unique file name");
+         return 0;
+       }
+
+      strcpy (buf + stemlen, ".XXXXXX");
+      mktemp (buf);
+    }
+
+  unsetenv ("PATH");
+  char *argv[] = { buf + 9, NULL };
+  execvp (argv[0], argv);
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"