torture: Wait for the pidfile and then start the tests.
authorAndreas Schneider <asn@samba.org>
Fri, 30 May 2014 11:59:43 +0000 (13:59 +0200)
committerMichael Adam <obnox@samba.org>
Sat, 31 May 2014 01:42:30 +0000 (03:42 +0200)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
tests/torture.c

index 8c9e0db77a3c5efab55df93359ca9e5a12d84bde..9a1d1ce36ebeef5cdaeebafeeceb5aa137d07cc2 100644 (file)
@@ -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);