]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Support run tst-exec and tst-spawn directly
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 10 Jan 2013 22:14:55 +0000 (14:14 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 10 Jan 2013 22:14:55 +0000 (14:14 -0800)
ChangeLog
posix/Makefile
posix/tst-exec-static.c [new file with mode: 0644]
posix/tst-exec.c
posix/tst-spawn-static.c [new file with mode: 0644]
posix/tst-spawn.c

index 08474f4594ab847da6921315e5ace088b2808916..147c82bbca48e54a41e38e08eef38778e3526d76 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2013-01-10  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * posix/Makefile (tests-static): New variable.
+       (tests): Add $(tests-static).
+       (tst-exec-static-ARGS): New variable.
+       (tst-spawn-static-ARGS): Likewise.
+       * posix/tst-exec-static.c: New file.
+       * posix/tst-spawn-static.c: Likewise.
+       * posix/tst-exec.c: Support run directly.
+       * posix/tst-spawn.c: Likewise.
+
 2013-01-10  Joseph Myers  <joseph@codesourcery.com>
 
        * elf/link.h (struct dl_phdr_info): Use __extension__ with long
index ce98c596d0641c769990c5f7785326f497b4bdf9..fda6e13bdac5dbc6e1d2a22384015bcd0023501d 100644 (file)
@@ -92,6 +92,8 @@ ifeq (yes,$(build-shared))
 test-srcs      := globtest
 tests           += wordexp-test tst-exec tst-spawn
 endif
+tests-static   = tst-exec-static tst-spawn-static
+tests          += $(tests-static)
 others         := getconf
 install-bin    := getconf
 install-others-programs        := $(inst_libexecdir)/getconf
@@ -172,7 +174,9 @@ tstgetopt-ARGS = -a -b -cfoobar --required foobar --optional=bazbug \
                --none random --col --color --colour
 
 tst-exec-ARGS = -- $(host-built-program-cmd)
+tst-exec-static-ARGS = $(tst-exec-ARGS)
 tst-spawn-ARGS = -- $(host-built-program-cmd)
+tst-spawn-static-ARGS = $(tst-spawn-ARGS)
 tst-dir-ARGS = `pwd` `cd $(common-objdir)/$(subdir); pwd` `cd $(common-objdir); pwd` $(objpfx)tst-dir
 tst-chmod-ARGS = $(objdir)
 tst-vfork3-ARGS = --test-dir=$(objpfx)
diff --git a/posix/tst-exec-static.c b/posix/tst-exec-static.c
new file mode 100644 (file)
index 0000000..bdd6369
--- /dev/null
@@ -0,0 +1 @@
+#include "tst-exec.c"
index 3a76b3229fc440d3924251a3a09662ba561e58da..a1a2c183c6b43cdd80fd49d30854b074f6fe9a27 100644 (file)
@@ -126,10 +126,10 @@ do_test (int argc, char *argv[])
   int status;
 
   /* We must have
-     - four parameters left of called initially
-       + path for ld.so
-       + "--library-path"
-       + the library path
+     - one or four parameters left if called initially
+       + path for ld.so                optional
+       + "--library-path"      optional
+       + the library path      optional
        + the application name
      - three parameters left if called through re-execution
        + file descriptor number which is supposed to be closed
@@ -145,7 +145,7 @@ do_test (int argc, char *argv[])
       return handle_restart (argv[1], argv[2], argv[3]);
     }
 
-  if (argc != 5)
+  if (argc != 2 && argc != 5)
     error (EXIT_FAILURE, 0, "wrong number of arguments (%d)", argc);
 
   /* Prepare the test.  We are creating two files: one which file descriptor
@@ -185,8 +185,12 @@ do_test (int argc, char *argv[])
       snprintf (fd2name, sizeof fd2name, "%d", fd2);
 
       /* This is the child.  Construct the command line.  */
-      execl (argv[1], argv[1], argv[2], argv[3], argv[4], "--direct",
-            "--restart", fd1name, fd2name, name1, NULL);
+      if (argc == 5)
+       execl (argv[1], argv[1], argv[2], argv[3], argv[4], "--direct",
+              "--restart", fd1name, fd2name, name1, NULL);
+      else
+       execl (argv[1], argv[1], "--direct",
+              "--restart", fd1name, fd2name, name1, NULL);
 
       error (EXIT_FAILURE, errno, "cannot exec");
     }
diff --git a/posix/tst-spawn-static.c b/posix/tst-spawn-static.c
new file mode 100644 (file)
index 0000000..1b1d34f
--- /dev/null
@@ -0,0 +1 @@
+#include "tst-spawn.c"
index 718602eb3ca64a4ec6d348986f6161e8bfe206eb..66fd26bba8373c02c92fc8269d8b55b4746691f6 100644 (file)
@@ -169,12 +169,13 @@ do_test (int argc, char *argv[])
   char fd3name[18];
   char fd4name[18];
   char *spargv[12];
+  int i;
 
   /* We must have
-     - four parameters left of called initially
-       + path for ld.so
-       + "--library-path"
-       + the library path
+     - one or four parameters left if called initially
+       + path for ld.so                optional
+       + "--library-path"      optional
+       + the library path      optional
        + the application name
      - five parameters left if called through re-execution
        + file descriptor number which is supposed to be closed
@@ -183,7 +184,7 @@ do_test (int argc, char *argv[])
        + thhe duped second descriptor
        + the name of the closed descriptor
   */
-  if (argc != (restart ? 6 : 5))
+  if (argc != (restart ? 6 : 2) && argc != (restart ? 6 : 5))
     error (EXIT_FAILURE, 0, "wrong number of arguments (%d)", argc);
 
   if (restart)
@@ -235,18 +236,16 @@ do_test (int argc, char *argv[])
    snprintf (fd3name, sizeof fd3name, "%d", fd3);
    snprintf (fd4name, sizeof fd4name, "%d", fd4);
 
-   spargv[0] = argv[1];
-   spargv[1] = argv[2];
-   spargv[2] = argv[3];
-   spargv[3] = argv[4];
-   spargv[4] = (char *) "--direct";
-   spargv[5] = (char *) "--restart";
-   spargv[6] = fd1name;
-   spargv[7] = fd2name;
-   spargv[8] = fd3name;
-   spargv[9] = fd4name;
-   spargv[10] = name1;
-   spargv[11] = NULL;
+   for (i = 0; i < (argc == (restart ? 6 : 5) ? 4 : 1); i++)
+     spargv[i] = argv[i + 1];
+   spargv[i++] = (char *) "--direct";
+   spargv[i++] = (char *) "--restart";
+   spargv[i++] = fd1name;
+   spargv[i++] = fd2name;
+   spargv[i++] = fd3name;
+   spargv[i++] = fd4name;
+   spargv[i++] = name1;
+   spargv[i] = NULL;
 
    if (posix_spawn (&pid, argv[1], &actions, NULL, spargv, environ) != 0)
      error (EXIT_FAILURE, errno, "posix_spawn");