Skip to content

Commit

Permalink
Sem: inc cov
Browse files Browse the repository at this point in the history
  • Loading branch information
fchn289 committed Oct 27, 2023
1 parent 85ba950 commit b7c7f95
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ut/msg_self/MsgSelfTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
// ***********************************************************************************************
#include <chrono>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <memory> // for shared_ptr
Expand All @@ -12,6 +13,7 @@
#include "MsgSelf.hpp"
#include "MT_PingMainTH.hpp"

using namespace std::chrono;
using namespace testing;

namespace RLib
Expand Down Expand Up @@ -152,8 +154,10 @@ TEST_F(MsgSelfTest, destructMsgSelf_noCallback_noMemLeak_noCrash) // mem leak i
// ***********************************************************************************************
TEST_F(MsgSelfTest, wait_notify)
{
auto now = high_resolution_clock::now();
msgSelf_->newMsg(d1MsgHdlr_);
g_sem.mt_timedwait(); // REQ: 1 msg will wakeup mt_timedwait()
auto dur = duration_cast<std::chrono::milliseconds>(high_resolution_clock::now() - now);

msgSelf_->newMsg(d1MsgHdlr_);
msgSelf_->newMsg(d1MsgHdlr_); // req: dup
Expand Down
2 changes: 2 additions & 0 deletions ut/thread/MT_SemphoreTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ TEST_F(MT_SemaphoreTest, timeout)
DBG("end");
auto dur = duration_cast<std::chrono::milliseconds>(high_resolution_clock::now() - now);
EXPECT_GE(dur.count(), 100) << "REQ: default timeout=100ms";

g_sem.mt_timedwait(0, 1000'000'000); // REQ: invalid ns>=1000ms, no die
}

} // namespace

0 comments on commit b7c7f95

Please sign in to comment.