This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 1/3] Support run tst-exec and tst-spawn directly


Hi,

This patch supports run tst-exec and tst-spawn directly.  OK for
2.18?

Thanks.


H.J.
---
 ChangeLog.direct         | 10 ++++++++++
 posix/Makefile           |  4 ++++
 posix/tst-exec-static.c  |  1 +
 posix/tst-exec.c         | 20 +++++++++++--------
 posix/tst-spawn-static.c |  1 +
 posix/tst-spawn.c        | 51 +++++++++++++++++++++++++++++++-----------------
 6 files changed, 61 insertions(+), 26 deletions(-)
 create mode 100644 ChangeLog.direct
 create mode 100644 posix/tst-exec-static.c
 create mode 100644 posix/tst-spawn-static.c

diff --git a/ChangeLog.direct b/ChangeLog.direct
new file mode 100644
index 0000000..df9aa4d
--- /dev/null
+++ b/ChangeLog.direct
@@ -0,0 +1,10 @@
+2012-12-20  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.
diff --git a/posix/Makefile b/posix/Makefile
index 5e0e886..de200ee 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -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
index 0000000..bdd6369
--- /dev/null
+++ b/posix/tst-exec-static.c
@@ -0,0 +1 @@
+#include "tst-exec.c"
diff --git a/posix/tst-exec.c b/posix/tst-exec.c
index 8e88ab8..14d8365 100644
--- a/posix/tst-exec.c
+++ b/posix/tst-exec.c
@@ -1,5 +1,5 @@
 /* Tests for exec.
-   Copyright (C) 2000 Free Software Foundation, Inc.
+   Copyright (C) 2000-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
 
@@ -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 of 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
index 0000000..1b1d34f
--- /dev/null
+++ b/posix/tst-spawn-static.c
@@ -0,0 +1 @@
+#include "tst-spawn.c"
diff --git a/posix/tst-spawn.c b/posix/tst-spawn.c
index 162fd72..76daa56 100644
--- a/posix/tst-spawn.c
+++ b/posix/tst-spawn.c
@@ -1,5 +1,5 @@
 /* Tests for spawn.
-   Copyright (C) 2000 Free Software Foundation, Inc.
+   Copyright (C) 2000-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
 
@@ -171,10 +171,10 @@ do_test (int argc, char *argv[])
   char *spargv[12];
 
   /* We must have
-     - four parameters left of called initially
-       + path for ld.so
-       + "--library-path"
-       + the library path
+     - one or four parameters left of 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 +183,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 +235,33 @@ 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;
+   if (argc == (restart ? 6 : 5))
+     {
+       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;
+     }
+   else
+     {
+       spargv[0] = argv[1];
+       spargv[1] = (char *) "--direct";
+       spargv[2] = (char *) "--restart";
+       spargv[3] = fd1name;
+       spargv[4] = fd2name;
+       spargv[5] = fd3name;
+       spargv[6] = fd4name;
+       spargv[7] = name1;
+       spargv[8] = NULL;
+     }
 
    if (posix_spawn (&pid, argv[1], &actions, NULL, spargv, environ) != 0)
      error (EXIT_FAILURE, errno, "posix_spawn");
-- 
1.7.11.7


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]