Skip to content

Commit

Permalink
ThreadBack: testcase is scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
fchn289 committed Dec 19, 2023
1 parent de8b551 commit a1ff69e
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions ut/thread/ThreadBackTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,22 @@ TEST_F(ThreadBackTest, canHandle_someThreadDone_whileOtherRunning)
}
}

#define WAIT_NOTIFY
// ***********************************************************************************************
TEST_F(ThreadBackTest, GOLD_entryFn_notify_insteadof_timeout)
{
auto start = high_resolution_clock::now();
ThreadBack::newThread(
[] { return true; }, // entryFn
[](bool) {} // backFn
);
timedwait(0, 500'000'000); // long timer to ensure thread done beforehand
auto dur = duration_cast<std::chrono::milliseconds>(high_resolution_clock::now() - start);
EXPECT_LT(dur.count(), 500) << "REQ: entryFn end shall notify g_sem instead of timeout";

while (ThreadBack::hdlFinishedThreads() == 0); // clear all threads
}

#define ABNORMAL
// ***********************************************************************************************
TEST_F(ThreadBackTest, asyncFail_noException_toBackFnWithFalse)
Expand All @@ -167,20 +183,4 @@ TEST_F(ThreadBackTest, emptyThreadList_ok)
EXPECT_EQ(0u, nHandled);
}

#define WAIT_NOTIFY
// ***********************************************************************************************
TEST_F(ThreadBackTest, wait_notify)
{
auto start = high_resolution_clock::now();
ThreadBack::newThread(
[] { return true; }, // entryFn
[](bool) {} // backFn
);
timedwait(0, 500'000'000); // long timer to ensure thread done beforehand
auto dur = duration_cast<std::chrono::milliseconds>(high_resolution_clock::now() - start);
EXPECT_LT(dur.count(), 500) << "REQ: entryFn end shall notify g_sem instead of timeout";

while (ThreadBack::hdlFinishedThreads() == 0); // clear all threads
}

} // namespace

0 comments on commit a1ff69e

Please sign in to comment.