summaryrefslogtreecommitdiff
path: root/posix
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2017-09-26 17:40:09 +0100
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2017-10-12 15:07:34 +0100
commit5ba41de9ed2cf6cf39a9cd7a7541bc71fc447d52 (patch)
tree3813a26c397cbba61b4c4aeaac1aa8d0626ee8ec /posix
parent7bacdcfc42b01a4c565abfc3d789577850481d05 (diff)
fix posix/tst-spawn test
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.
Diffstat (limited to 'posix')
-rw-r--r--posix/tst-spawn.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/posix/tst-spawn.c b/posix/tst-spawn.c
index 08d92bd7a7..4e5e76351c 100644
--- a/posix/tst-spawn.c
+++ b/posix/tst-spawn.c
@@ -23,9 +23,10 @@
#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;
}