Skip to content

Commit

Permalink
Fix UT
Browse files Browse the repository at this point in the history
Signed-off-by: Longxiang Lyu <lolv@microsoft.com>
  • Loading branch information
lolyu committed Jul 3, 2024
1 parent 7c21338 commit b16de0f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
9 changes: 4 additions & 5 deletions test/LinkManagerStateMachineActiveActiveTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,8 @@ void LinkManagerStateMachineActiveActiveTest::handleMuxState(std::string state,

void LinkManagerStateMachineActiveActiveTest::handlePeerMuxState(std::string state, uint32_t count)
{
for (uint8_t i = 0; i < mPositiveUpdateCount; i++) {
mFakeMuxPort.handlePeerMuxState(state);
runIoService(count);
}
mFakeMuxPort.handlePeerMuxState(state);
runIoService(count);
}

void LinkManagerStateMachineActiveActiveTest::handleProbeMuxState(std::string state, uint32_t count)
Expand Down Expand Up @@ -405,6 +403,7 @@ TEST_F(LinkManagerStateMachineActiveActiveTest, MuxActiveLinkProberPeerUnknown)
VALIDATE_PEER_STATE(PeerWait, Wait);

postPeerLinkProberEvent(link_prober::LinkProberState::PeerActive, 1);
runIoService(1);
handlePeerMuxState("active", 1);
VALIDATE_PEER_STATE(PeerActive, Active);

Expand All @@ -413,7 +412,7 @@ TEST_F(LinkManagerStateMachineActiveActiveTest, MuxActiveLinkProberPeerUnknown)
EXPECT_EQ(mDbInterfacePtr->mSetPeerMuxStateInvokeCount, 1);
EXPECT_EQ(mDbInterfacePtr->mLastSetPeerMuxState, mux_state::MuxState::Label::Standby);

handlePeerMuxState("standby", 1);
handlePeerMuxState("standby", 2);
VALIDATE_PEER_STATE(PeerUnknown, Standby);
EXPECT_EQ(mFakeMuxPort.mFakeLinkProber->mSendPeerProbeCommand, 1);
}
Expand Down
5 changes: 1 addition & 4 deletions test/MuxPortTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ void MuxPortTest::stopIoServiceThreaded()
{
mWork.reset();
mIoService.stop();
mThreadGroup.join_all();
}

void MuxPortTest::SetUp()
Expand Down Expand Up @@ -215,7 +216,6 @@ TEST_F(MuxPortTest, TestPeerLinkStateNotificationHandler)
mFakeMuxPort.handlePeerLinkState("down");
called += 2;

uint32_t check = 0;
while (fakeLinkManagerStateMachinePtr->mPeerLinkStateNotificationHandlerCalled < called)
{
usleep(1000);
Expand All @@ -236,7 +236,6 @@ TEST_F(MuxPortTest, TestPeerMuxStateNotificationHandler)
mFakeMuxPort.handlePeerMuxState("standby");
called += 2;

uint32_t check = 0;
while (fakeLinkManagerStateMachinePtr->mPeerMuxStateNotificationHandlerCalled < called)
{
usleep(1000);
Expand All @@ -257,7 +256,6 @@ TEST_F(MuxPortTest, TestMuxConfigNotificationHandler)
mFakeMuxPort.handleMuxConfig("standby");
called += 2;

uint32_t check = 0;
while (fakeLinkManagerStateMachinePtr->mMuxConfigNotificationHandlerCalled < called)
{
usleep(1000);
Expand All @@ -279,7 +277,6 @@ TEST_F(MuxPortTest, TestDefaultRouteStateNotificationHandler)
mFakeMuxPort.handleDefaultRouteState("ok");
called += 2;

uint32_t check = 0;
while (fakeLinkManagerStateMachinePtr->mDefaultRouteStateNotificationHandlerCalled < called)
{
usleep(1000);
Expand Down

0 comments on commit b16de0f

Please sign in to comment.