In execve05, the first child must keep a file open at least until the second
child tries to execve() this file. However the test achieves this with a sleep
of 10s, which may fail on loaded systems.
This patch replaces this (arbitrary) sleep with a pipe-based synchronization,
where the parent notifies the first child once the second child has terminated.
Signed-off-by: Louis Rilling <[EMAIL PROTECTED]>
---
testcases/kernel/syscalls/execve/execve05.c | 30 ++++++++++++++++++++--------
1 file changed, 22 insertions(+), 8 deletions(-)
Index: b/testcases/kernel/syscalls/execve/execve05.c
===================================================================
--- a/testcases/kernel/syscalls/execve/execve05.c 2008-06-02
16:12:51.000000000 +0200
+++ b/testcases/kernel/syscalls/execve/execve05.c 2008-06-02
16:37:53.000000000 +0200
@@ -70,7 +70,8 @@ void do_child_1(void);
void do_child_2(void);
int exp_enos[] = {ETXTBSY, 0};
-int sync_pipes[2];
+int start_sync_pipes[2];
+int end_sync_pipes[2];
int Fflag = 0;
char *test_name;
@@ -116,7 +117,9 @@ main(int ac, char **av)
/* reset Tst_count in case we are looping */
Tst_count = 0;
- if (sync_pipe_create(sync_pipes) == -1)
+ if (sync_pipe_create(start_sync_pipes) == -1)
+ tst_brkm(TBROK, cleanup, "sync_pipe_create failed");
+ if (sync_pipe_create(end_sync_pipes) == -1)
tst_brkm(TBROK, cleanup, "sync_pipe_create failed");
/*
@@ -138,10 +141,10 @@ main(int ac, char **av)
#endif
}
- if (sync_pipe_wait(sync_pipes) == -1)
+ if (sync_pipe_wait(start_sync_pipes) == -1)
tst_brkm(TBROK, cleanup, "sync_pipe_wait failed");
- if (sync_pipe_close(sync_pipes) == -1)
+ if (sync_pipe_close(start_sync_pipes) == -1)
tst_brkm(TBROK, cleanup, "sync_pipe_close failed");
if ((pid1 = FORK_OR_VFORK()) == -1)
@@ -151,6 +154,10 @@ main(int ac, char **av)
argv[0] = 0;
env[0] = 0;
+ /* do not interfere with end synchronization of first
+ * child */
+ sync_pipe_close(end_sync_pipes);
+
TEST(execve(test_name, argv, env));
TEST_ERROR_LOG(TEST_ERRNO);
@@ -170,7 +177,6 @@ main(int ac, char **av)
exit(retval);
} else { /* parent */
/* wait for the child to finish */
- waitpid(pid,NULL,0);
waitpid(pid1,&status,0);
/* make sure the child returned a good exit status */
e_code = status >> 8;
@@ -181,6 +187,10 @@ main(int ac, char **av)
if ((e_code != 3) || (retval != 3)) {
tst_resm(TFAIL, "Failures reported above");
}
+
+ /* terminate first child */
+ sync_pipe_notify(end_sync_pipes);
+ waitpid(pid,NULL,0);
cleanup();
}
}
@@ -243,12 +253,16 @@ do_child_1()
exit(1);
}
- if (sync_pipe_notify(sync_pipes) == -1)
+ if (sync_pipe_notify(start_sync_pipes) == -1)
tst_brkm(TBROK, cleanup, "sync_pipe_notify failed");
- if (sync_pipe_close(sync_pipes) == -1)
+ if (sync_pipe_close(start_sync_pipes) == -1)
tst_brkm(TBROK, cleanup, "sync_pipe_close failed");
- sleep(10); /* let other child execve same file */
+ /* let other child execve same file */
+ if (sync_pipe_wait(end_sync_pipes) == -1) {
+ tst_brkm(TBROK, NULL, "sync_pipe_wait failed");
+ exit(1);
+ }
exit(0);
}
--
Dr Louis Rilling Kerlabs
Skype: louis.rilling Batiment Germanium
Phone: (+33|0) 6 80 89 08 23 80 avenue des Buttes de Coesmes
http://www.kerlabs.com/ 35700 Rennes
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list