Update ping call code.
authorBrian Aker <brian@tangent.org>
Wed, 14 Mar 2012 16:54:14 +0000 (09:54 -0700)
committerBrian Aker <brian@tangent.org>
Wed, 14 Mar 2012 16:54:14 +0000 (09:54 -0700)
libtest/include.am
libtest/server.cc
libtest/unittest.cc
libtest/wait.h

index accd98ae78e8e5f07e56abe2e3486acc66ecc914..f4970642f93554698b3a47d076e2d194792bfba3 100644 (file)
@@ -228,7 +228,9 @@ libtest_skiptest_SOURCES= libtest/skiptest.cc
 check_PROGRAMS+= libtest/skiptest
 noinst_PROGRAMS+= libtest/skiptest
 
-libtest_wait_SOURCES= libtest/wait.cc
+libtest_wait_SOURCES=
+libtest_wait_SOURCES+= libtest/wait.cc
+libtest_wait_SOURCES+= libtest/dream.cc
 noinst_PROGRAMS+= libtest/wait
 
 libtest_abort_SOURCES= libtest/abort.cc
index b6564b3aab38bd11d0b9d7e25fc8169144965d6f..3e891bba2b6540d2b1815814447796fb515e5a78 100644 (file)
@@ -198,12 +198,27 @@ bool Server::start()
     }
   }
 
-  int counter= 0;
   bool pinged= false;
-  while ((pinged= ping()) == false and
-         counter < (is_helgrind() or is_valgrind() ? 20 : 5))
   {
-    dream(counter++, 50000);
+    uint32_t timeout= 20; // This number should be high enough for valgrind startup (which is slow)
+    uint32_t waited;
+    uint32_t this_wait;
+    uint32_t retry;
+
+    for (waited= 0, retry= 1; ; retry++, waited+= this_wait)
+    {
+      if ((pinged= ping()) == true)
+      {
+        break;
+      }
+      else if (waited >= timeout)
+      {
+        break;
+      }
+
+      this_wait= retry * retry / 3 + 1;
+      libtest::dream(this_wait, 0);
+    }
   }
 
   if (pinged == false)
index 0f82a560a701f31e177cedb1850c2e5d9d5a5489..a5860bdd35b4790a1ec1349f19d30cbd1bc80bd4 100644 (file)
@@ -236,8 +236,6 @@ static test_return_t gearmand_cycle_test(void *object)
 
   test_skip(true, has_gearmand_binary());
 
-  Error << " " << has_gearmand_binary();
-
   test_true(server_startup(*servers, "gearmand", get_free_port(), 0, NULL));
 
   return TEST_SUCCESS;
index 391afa4979fe9b897daa35d81ed8478012fff2fc..c6c3f966d84a79fcbddd9f167cc515d8e3992be1 100644 (file)
@@ -25,6 +25,8 @@
 #include <unistd.h>
 #include <string>
 
+#include <libtest/dream.h>
+
 namespace libtest {
 
 class Wait 
@@ -57,13 +59,7 @@ public:
       }
 
       this_wait= retry * retry / 3 + 1;
-      sleep(this_wait);
-#ifdef WIN32
-      sleep(this_wait);
-#else
-      struct timespec global_sleep_value= { this_wait, 0 };
-      nanosleep(&global_sleep_value, NULL);
-#endif
+      libtest::dream(this_wait, 0);
     }
   }