Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix refresh permission test by checking more regularly #1779

Merged
merged 1 commit into from
Aug 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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