]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
fix posix/tst-spawn test
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Tue, 26 Sep 2017 16:40:09 +0000 (17:40 +0100)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Thu, 12 Oct 2017 14:07:34 +0000 (15:07 +0100)
The test spawns two children but only waited for one.
The fix avoids printing to stderr.

* posix/tst-spawn.c (do_test): Wait for both children.

ChangeLog
posix/tst-spawn.c

index 7d1fbc66bed126137d1e2f772442ce2c10a2a350..58b28159d440b0ab69770232e7fb75475ee94f64 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2017-10-12  Szabolcs Nagy  <szabolcs.nagy@arm.com>
+
+       * posix/tst-spawn.c (do_test): Wait for both children.
+
 2017-10-12  H.J. Lu  <hongjiu.lu@intel.com>
 
        [BZ #22284]
index 08d92bd7a7afdaf1a1abf2f996b00bb107c1d631..4e5e76351cd4e43204b6a4703cb37b165441eaaa 100644 (file)
 #include <spawn.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 #include <wait.h>
 #include <sys/param.h>
+#include <support/check.h>
+#include <support/xunistd.h>
 
 
 /* Nonzero if the program gets called via `exec'.  */
@@ -249,13 +250,16 @@ do_test (int argc, char *argv[])
      error (EXIT_FAILURE, errno, "posix_spawn_file_actions_destroy");
    free (name3_copy);
 
-  /* Wait for the child.  */
-  if (waitpid (pid, &status, 0) != pid)
-    error (EXIT_FAILURE, errno, "wrong child");
+  /* Wait for the children.  */
+  TEST_VERIFY (xwaitpid (pid, &status, 0) == pid);
+  TEST_VERIFY (WIFEXITED (status));
+  TEST_VERIFY (!WIFSIGNALED (status));
+  TEST_VERIFY (WEXITSTATUS (status) == 0);
 
-  if (WTERMSIG (status) != 0)
-    error (EXIT_FAILURE, 0, "Child terminated incorrectly");
-  status = WEXITSTATUS (status);
+  xwaitpid (-1, &status, 0);
+  TEST_VERIFY (WIFEXITED (status));
+  TEST_VERIFY (!WIFSIGNALED (status));
+  TEST_VERIFY (WEXITSTATUS (status) == 0);
 
-  return status;
+  return 0;
 }