Skip to content

Commit a1ff69e

Browse files
committed
ThreadBack: testcase is scenario
1 parent de8b551 commit a1ff69e

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

ut/thread/ThreadBackTest.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,22 @@ TEST_F(ThreadBackTest, canHandle_someThreadDone_whileOtherRunning)
149149
}
150150
}
151151

152+
#define WAIT_NOTIFY
153+
// ***********************************************************************************************
154+
TEST_F(ThreadBackTest, GOLD_entryFn_notify_insteadof_timeout)
155+
{
156+
auto start = high_resolution_clock::now();
157+
ThreadBack::newThread(
158+
[] { return true; }, // entryFn
159+
[](bool) {} // backFn
160+
);
161+
timedwait(0, 500'000'000); // long timer to ensure thread done beforehand
162+
auto dur = duration_cast<std::chrono::milliseconds>(high_resolution_clock::now() - start);
163+
EXPECT_LT(dur.count(), 500) << "REQ: entryFn end shall notify g_sem instead of timeout";
164+
165+
while (ThreadBack::hdlFinishedThreads() == 0); // clear all threads
166+
}
167+
152168
#define ABNORMAL
153169
// ***********************************************************************************************
154170
TEST_F(ThreadBackTest, asyncFail_noException_toBackFnWithFalse)
@@ -167,20 +183,4 @@ TEST_F(ThreadBackTest, emptyThreadList_ok)
167183
EXPECT_EQ(0u, nHandled);
168184
}
169185

170-
#define WAIT_NOTIFY
171-
// ***********************************************************************************************
172-
TEST_F(ThreadBackTest, wait_notify)
173-
{
174-
auto start = high_resolution_clock::now();
175-
ThreadBack::newThread(
176-
[] { return true; }, // entryFn
177-
[](bool) {} // backFn
178-
);
179-
timedwait(0, 500'000'000); // long timer to ensure thread done beforehand
180-
auto dur = duration_cast<std::chrono::milliseconds>(high_resolution_clock::now() - start);
181-
EXPECT_LT(dur.count(), 500) << "REQ: entryFn end shall notify g_sem instead of timeout";
182-
183-
while (ThreadBack::hdlFinishedThreads() == 0); // clear all threads
184-
}
185-
186186
} // namespace

0 commit comments

Comments
 (0)