feat add timeout
Some checks failed
ci/pr/linux-aarch64-gcc/1 Pipeline failed
ci/push/linux-aarch64-gcc/1 Pipeline was successful
ci/push/linux-x64-gcc/2 Pipeline failed
ci/push/linux-aarch64-gcc/2 Pipeline failed
ci/pr/linux-x64-gcc/1 Pipeline was successful
ci/pr/linux-aarch64-gcc/2 Pipeline failed
ci/push/linux-x64-gcc/1 Pipeline was successful
ci/pr/linux-x64-gcc/2 Pipeline failed
Some checks failed
ci/pr/linux-aarch64-gcc/1 Pipeline failed
ci/push/linux-aarch64-gcc/1 Pipeline was successful
ci/push/linux-x64-gcc/2 Pipeline failed
ci/push/linux-aarch64-gcc/2 Pipeline failed
ci/pr/linux-x64-gcc/1 Pipeline was successful
ci/pr/linux-aarch64-gcc/2 Pipeline failed
ci/push/linux-x64-gcc/1 Pipeline was successful
ci/pr/linux-x64-gcc/2 Pipeline failed
This commit is contained in:
parent
ef009a4ae9
commit
7b13e5584a
@ -36,8 +36,8 @@ class CondVarTest : public ::testing::Test {
|
||||
protected:
|
||||
Mutex *m;
|
||||
CondVar *cv;
|
||||
volatile bool is_set;
|
||||
volatile bool is_timeout;
|
||||
bool is_set;
|
||||
bool is_timeout;
|
||||
std::thread *worker;
|
||||
};
|
||||
|
||||
@ -69,6 +69,7 @@ TEST_F(CondVarTest, NotifyOne_Wait) {
|
||||
TEST_F(CondVarTest, NotifyOne_WaitFor) {
|
||||
// Wait
|
||||
// constexpr auto kWaitTimeoutMs = 100;
|
||||
auto start = ReadSteadyClock();
|
||||
constexpr auto kWaitTimeout = std::chrono::milliseconds(50);
|
||||
auto WaitFor = [&] {
|
||||
UniqueLock<Mutex> inner_locker(*m);
|
||||
@ -91,9 +92,16 @@ TEST_F(CondVarTest, NotifyOne_WaitFor) {
|
||||
cv->NotifyOne();
|
||||
}
|
||||
|
||||
auto now = ReadSteadyClock();
|
||||
t1.join();
|
||||
ASSERT_TRUE(is_set);
|
||||
ASSERT_FALSE(is_timeout);
|
||||
if (now - start > kWaitTimeout) {
|
||||
// timeout
|
||||
ASSERT_TRUE(is_timeout);
|
||||
ASSERT_FALSE(is_set);
|
||||
} else {
|
||||
ASSERT_FALSE(is_timeout);
|
||||
ASSERT_TRUE(is_set);
|
||||
}
|
||||
}
|
||||
|
||||
// timeout
|
||||
|
Loading…
Reference in New Issue
Block a user