Browse Source

More tolerant wait time for tests

Paul-Louis Ageneau 5 years ago
parent
commit
c39a4ee6c5
2 changed files with 8 additions and 2 deletions
  1. 5 1
      test/capi.cpp
  2. 3 1
      test/connectivity.cpp

+ 5 - 1
test/capi.cpp

@@ -131,6 +131,8 @@ static void deletePeer(Peer *peer) {
 }
 
 int test_capi_main() {
+	int attempts;
+
 	rtcInitLogger(RTC_LOG_DEBUG);
 
 	rtcConfiguration config;
@@ -155,7 +157,9 @@ int test_capi_main() {
 	rtcSetClosedCallback(peer1->dc, closedCallback);
 	rtcSetMessageCallback(peer1->dc, messageCallback);
 
-	sleep(3);
+	attempts = 10;
+	while (!peer2->connected && attempts--)
+		sleep(1);
 
 	if (peer1->state != RTC_CONNECTED || peer2->state != RTC_CONNECTED) {
 		fprintf(stderr, "PeerConnection is not connected\n");

+ 3 - 1
test/connectivity.cpp

@@ -106,7 +106,9 @@ void test_connectivity() {
 		}
 	});
 
-	this_thread::sleep_for(3s);
+	int attempts = 10;
+	while ((!dc2 || !dc2->isOpen()) && attempts--)
+		this_thread::sleep_for(1s);
 
 	if (pc1->state() != PeerConnection::State::Connected &&
 	    pc2->state() != PeerConnection::State::Connected)