Commit 8c456189d1f028c63980596f07863e1cfc38fbef

Authored by Jürgen Knödlseder
1 parent 26c398a7

Add kluge that may prevent test problems when running concurrent unit test of the VO module.

Showing 1 changed file with 31 additions and 2 deletions
test/test_GVO.cpp
... ... @@ -29,7 +29,7 @@
29 29 #include <config.h>
30 30 #endif
31 31 #include <cstdlib> // for system() function
32   -#include <unistd.h> // for sleep() function
  32 +#include <unistd.h> // for sleep() and usleep() function
33 33 #include "test_GVO.hpp"
34 34 #include "GTools.hpp"
35 35  
... ... @@ -68,6 +68,21 @@ TestGVO* TestGVO::clone(void) const
68 68 **************************************************************************/
69 69 void TestGVO::test_GVOHub(void)
70 70 {
  71 + // Kluge: wait until no Hub is online
  72 + GRan ran;
  73 + int no_hub = 0;
  74 + while (no_hub < 3) {
  75 + GVOClient client;
  76 + if (!client.ping_hub()) {
  77 + no_hub++;
  78 + usleep(ran.uniform()*1.0e6);
  79 + }
  80 + else {
  81 + no_hub = 0;
  82 + }
  83 + usleep(ran.uniform()*1.0e6);
  84 + }
  85 +
71 86 // Create child process
72 87 int pid = fork();
73 88  
... ... @@ -122,11 +137,25 @@ void TestGVO::test_GVOHub(void)
122 137 **************************************************************************/
123 138 void TestGVO::test_GVOClient(void)
124 139 {
  140 + // Kluge: wait until no Hub is online
  141 + GRan ran;
  142 + int no_hub = 0;
  143 + while (no_hub < 3) {
  144 + GVOClient client;
  145 + if (!client.ping_hub()) {
  146 + no_hub++;
  147 + usleep(ran.uniform()*1.0e6);
  148 + }
  149 + else {
  150 + no_hub = 0;
  151 + }
  152 + usleep(ran.uniform()*1.0e6);
  153 + }
  154 +
125 155 // Test constructor
126 156 test_try("GVOClient empty constructor");
127 157 try {
128 158 GVOClient client;
129   - //std::cout << client << std::endl;
130 159 test_try_success();
131 160 }
132 161 catch (std::exception &e) {
... ...