From 205d5c2348a5ae4858c2fe07a8b3080b19c900be Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Fri, 30 May 2014 13:59:43 +0200 Subject: torture: Wait for the pidfile and then start the tests. Signed-off-by: Andreas Schneider Reviewed-by: Michael Adam --- tests/torture.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tests/torture.c') diff --git a/tests/torture.c b/tests/torture.c index 8c9e0db..9a1d1ce 100644 --- a/tests/torture.c +++ b/tests/torture.c @@ -147,6 +147,7 @@ static void torture_setup_echo_srv_ip(void **state, struct torture_state *s; char start_echo_srv[1024] = {0}; const char *t; + int count = 0; int rc; torture_setup_socket_dir(state); @@ -175,7 +176,18 @@ static void torture_setup_echo_srv_ip(void **state, rc = system(start_echo_srv); assert_int_equal(rc, 0); - sleep(1); + do { + struct stat sb; + + count++; + if (count > 100) { + break; + } + + rc = stat(s->srv_pidfile, &sb); + usleep(50); + } while (rc != 0); + assert_int_equal(rc, 0); /* set default iface for the client */ setenv("SOCKET_WRAPPER_DEFAULT_IFACE", "170", 1); -- cgit