]> git.proxmox.com Git - mirror_kronosnet.git/commitdiff
[tests] add common function to sleep based on how the test suite is running
authorFabio M. Di Nitto <fdinitto@redhat.com>
Thu, 26 Sep 2019 05:18:46 +0000 (07:18 +0200)
committerFabio M. Di Nitto <fdinitto@redhat.com>
Thu, 26 Sep 2019 05:18:46 +0000 (07:18 +0200)
Address issue while waiting for host to be up and PMTUd first run.

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
libknet/tests/api_knet_handle_pmtud_set.c
libknet/tests/api_knet_link_set_enable.c
libknet/tests/test-common.c
libknet/tests/test-common.h

index 4404368849afa24571804e937dd441b6d5c974e0..15b1dddee51275d2502c025a8088b32da39c32ec 100644 (file)
@@ -167,7 +167,7 @@ static void test(void)
        /*
         * wait for PMTUd to pick up the change
         */
-       sleep(1);
+       test_sleep(knet_h, 1);
        flush_logs(logfds[0], stdout);
 
        if (knet_h->data_mtu != data_mtu - 64) {
@@ -196,11 +196,11 @@ static void test(void)
        /*
         * wait for PMTUd to pick up the change
         */
-       sleep(2);
+       test_sleep(knet_h, 1);
        flush_logs(logfds[0], stdout);
 
        if (knet_h->data_mtu != data_mtu) {
-               printf("knet_handle_pmtud_set failed to redetect MTU\n");
+               printf("knet_handle_pmtud_set failed to redetect MTU: detected mtu: %u data_mtu: %u \n", knet_h->data_mtu, data_mtu);
                knet_link_set_enable(knet_h, 1, 0, 0);
                knet_link_clear_config(knet_h, 1, 0);
                knet_host_remove(knet_h, 1);
index 17e6e031c46bf7f16a238094eb25b5bc09233559..fc233ea37d933cf84fc8eeb9597a807ddee98a39 100644 (file)
@@ -293,7 +293,7 @@ static void test_sctp(void)
        }
 
        printf("Wait 2 seconds for sockets to connect\n");
-       sleep(2);
+       test_sleep(knet_h, 2);
 
        printf("Test knet_link_set_enable with correct values (0)\n");
 
index 58216083a3b9a6979da5df1daf19e019ac1da435..8ebb29c4aacad8d3cea43a1604e2c7cf86223672 100644 (file)
@@ -478,6 +478,15 @@ int make_local_sockaddr6(struct sockaddr_storage *lo, uint16_t offset)
        return _make_local_sockaddr(lo, offset, AF_INET6);
 }
 
+void test_sleep(knet_handle_t knet_h, int seconds)
+{
+       if (is_memcheck() || is_helgrind()) {
+               printf("Test suite is running under valgrind, adjusting sleep timers\n");
+               seconds = seconds * 16;
+       }
+       sleep(seconds);
+}
+
 int wait_for_host(knet_handle_t knet_h, uint16_t host_id, int seconds, int logfd, FILE *std)
 {
        int i = 0;
@@ -490,6 +499,8 @@ int wait_for_host(knet_handle_t knet_h, uint16_t host_id, int seconds, int logfd
        while (i < seconds) {
                flush_logs(logfd, std);
                if (knet_h->host_index[host_id]->status.reachable == 1) {
+                       printf("Waiting for host to settle\n");
+                       test_sleep(knet_h, 1);
                        return 0;
                }
                printf("waiting host %u to be reachable for %d more seconds\n", host_id, seconds - i);
index f1375ab8cf502c256ac6f317907e68b980939e3f..963c438268ab76f6f9411eba2aa9f328dbb3b302 100644 (file)
@@ -71,5 +71,6 @@ int make_local_sockaddr(struct sockaddr_storage *lo, uint16_t offset);
 int make_local_sockaddr6(struct sockaddr_storage *lo, uint16_t offset);
 int wait_for_host(knet_handle_t knet_h, uint16_t host_id, int seconds, int logfd, FILE *std);
 int wait_for_packet(knet_handle_t knet_h, int seconds, int datafd, int logfd, FILE *std);
+void test_sleep(knet_handle_t knet_h, int seconds);
 
 #endif