aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Liebler <stli@linux.ibm.com>2019-02-01 11:03:35 +0100
committerStefan Liebler <stli@linux.ibm.com>2019-02-01 11:03:35 +0100
commit114f792eaea2505cd8aee02d330aad37238da6a5 (patch)
treed8c34511d57013157577f1adfe8d0f870c12e53e
parentd5627550ae99d10dfad216910ffa774f60460123 (diff)
downloadglibc-114f792eaea2505cd8aee02d330aad37238da6a5.zip
glibc-114f792eaea2505cd8aee02d330aad37238da6a5.tar.gz
glibc-114f792eaea2505cd8aee02d330aad37238da6a5.tar.bz2
posix/tst-spawn: Fix racy tests in spawned processes.
From time to time I get fails in tst-spawn like: tst-spawn.c:111: numeric comparison failure left: 0 (0x0); from: xlseek (fd2, 0, SEEK_CUR) right: 28 (0x1c); from: strlen (fd2string) error: 1 test failures tst-spawn.c:252: numeric comparison failure left: 1 (0x1); from: WEXITSTATUS (status) right: 0 (0x0); from: 0 error: 1 test failures It turned out, that a child process is testing it's open file descriptors with e.g. a sequence of testing the current position, setting the position to zero and reading a specific amount of bytes. Unfortunately starting with commit 2a69f853c03034c2e383e0f9c35b5402ce8b5473 the test is spawning a second child process which is sharing some of the file descriptors. If the test sequence as mentioned above is running in parallel it leads to test failures. As the second call of posix_spawn shall test a NULL pid argument, this patch is just moving the waitpid of the first child before the posix_spawn of the second child. ChangeLog: * posix/tst-spawn do_test(): Move waitpid before posix_spawn.
-rw-r--r--ChangeLog4
-rw-r--r--posix/tst-spawn.c11
2 files changed, 10 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 3865128..25a644f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2019-02-01 Stefan Liebler <stli@linux.ibm.com>
+
+ * posix/tst-spawn do_test(): Move waitpid before posix_spawn.
+
2019-01-31 Vineet Gupta <vgupta@synopsys.com>
* sysdeps/unix/make-syscalls.sh: Fix comment referencing
diff --git a/posix/tst-spawn.c b/posix/tst-spawn.c
index eea5add..9aa7e62 100644
--- a/posix/tst-spawn.c
+++ b/posix/tst-spawn.c
@@ -237,6 +237,12 @@ do_test (int argc, char *argv[])
TEST_COMPARE (posix_spawn (&pid, argv[1], &actions, NULL, spargv, environ),
0);
+ /* Wait for the children. */
+ TEST_COMPARE (xwaitpid (pid, &status, 0), pid);
+ TEST_VERIFY (WIFEXITED (status));
+ TEST_VERIFY (!WIFSIGNALED (status));
+ TEST_COMPARE (WEXITSTATUS (status), 0);
+
/* Same test but with a NULL pid argument. */
TEST_COMPARE (posix_spawn (NULL, argv[1], &actions, NULL, spargv, environ),
0);
@@ -246,11 +252,6 @@ do_test (int argc, char *argv[])
free (name3_copy);
/* Wait for the children. */
- TEST_COMPARE (xwaitpid (pid, &status, 0), pid);
- TEST_VERIFY (WIFEXITED (status));
- TEST_VERIFY (!WIFSIGNALED (status));
- TEST_COMPARE (WEXITSTATUS (status), 0);
-
xwaitpid (-1, &status, 0);
TEST_VERIFY (WIFEXITED (status));
TEST_VERIFY (!WIFSIGNALED (status));