Skip to content

Commit

Permalink
Fix refresh permission test by checking more regularly (#1779)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdelapla authored Aug 18, 2023
1 parent 7c5a03b commit ce72886
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions tst/TurnConnectionFunctionalityTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,21 +149,30 @@ TEST_F(TurnConnectionFunctionalityTest, turnConnectionRefreshPermissionTest)
MUTEX_UNLOCK(pTurnConnection->lock);
}

DLOGI("Checking if TURN_STATE_READY is set");
EXPECT_TRUE(turnReady == TRUE);

// modify permission expiration time to trigger refresh permission
MUTEX_LOCK(pTurnConnection->lock);
pTurnConnection->turnPeerList[0].permissionExpirationTime = GETTIME();
MUTEX_UNLOCK(pTurnConnection->lock);

// turn Connection timer run happens every second when at ready state.
THREAD_SLEEP(1500 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND);

// verify we are no longer in ready state.
MUTEX_LOCK(pTurnConnection->lock);
EXPECT_TRUE(pTurnConnection->state != TURN_STATE_READY);
MUTEX_UNLOCK(pTurnConnection->lock);
turnReady = FALSE;
turnReadyTimeout = GETTIME() + 10 * HUNDREDS_OF_NANOS_IN_A_SECOND;
while (!turnReady && GETTIME() < turnReadyTimeout) {
THREAD_SLEEP(5 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND);
MUTEX_LOCK(pTurnConnection->lock);
if (pTurnConnection->state != TURN_STATE_READY) {
turnReady = TRUE;
}
MUTEX_UNLOCK(pTurnConnection->lock);
}

//here "TRUE" actually means not in the ready state
EXPECT_TRUE(turnReady == TRUE);

//and now let's make sure we get back to ready
turnReady = FALSE;
turnReadyTimeout = GETTIME() + 10 * HUNDREDS_OF_NANOS_IN_A_SECOND;

Expand Down

0 comments on commit ce72886

Please sign in to comment.