Skip to content

Commit

Permalink
fix(eventx):解决在禁了epoll之后TimerFd单元测试不过问题
Browse files Browse the repository at this point in the history
  • Loading branch information
hevake committed Nov 26, 2024
1 parent 7a9022c commit 11ee715
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion modules/base/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ LIB_VERSION_X = 1
LIB_VERSION_Y = 0
LIB_VERSION_Z = 1

HAVE_EXECINFO_H ?= yes # 默认支持execinfo.h
HAVE_EXECINFO_H ?= yes

HEAD_FILES = \
version.h \
Expand Down
2 changes: 1 addition & 1 deletion modules/event/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ LIB_VERSION_X = 1
LIB_VERSION_Y = 2
LIB_VERSION_Z = 0

HAVE_EPOLL ?= yes # 默认支持epoll
HAVE_EPOLL ?= yes

CXXFLAGS += -DMODULE_ID='"tbox.event"'

Expand Down
14 changes: 7 additions & 7 deletions modules/eventx/timer_fd_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const int kAcceptableError = 1;

TEST(TimerFd, Oneshot)
{
auto sp_loop = Loop::New("epoll");
auto sp_loop = Loop::New();
auto timer_event = new TimerFd(sp_loop, "10");
SetScopeExitAction([=] { delete timer_event; delete sp_loop; });

Expand All @@ -58,7 +58,7 @@ TEST(TimerFd, Oneshot)

TEST(TimerFd, Persist)
{
auto sp_loop = Loop::New("epoll");
auto sp_loop = Loop::New();
auto timer_event = new TimerFd(sp_loop, "10");
SetScopeExitAction([=] { delete timer_event; delete sp_loop; });

Expand All @@ -68,7 +68,7 @@ TEST(TimerFd, Persist)
int run_time = 0;
timer_event->setCallback([&run_time]() { ++run_time; });

sp_loop->exitLoop(std::chrono::milliseconds(100));
sp_loop->exitLoop(std::chrono::milliseconds(101)); //! 多等1ms
sp_loop->runLoop();

EXPECT_EQ(run_time, 10);
Expand All @@ -77,7 +77,7 @@ TEST(TimerFd, Persist)

TEST(TimerFd, DisableSelfInCallback)
{
auto sp_loop = Loop::New("epoll");
auto sp_loop = Loop::New();
auto timer_event = new TimerFd(sp_loop, "10");
SetScopeExitAction([=] { delete timer_event; delete sp_loop; });

Expand All @@ -100,7 +100,7 @@ TEST(TimerFd, DisableSelfInCallback)

TEST(TimerFd, Precision)
{
auto sp_loop = Loop::New("epoll");
auto sp_loop = Loop::New();
auto timer_event = new TimerFd(sp_loop, "100");
SetScopeExitAction([=] { delete timer_event; delete sp_loop; });

Expand Down Expand Up @@ -137,7 +137,7 @@ TEST(TimerFd, NanoSeconds)
auto min_interval_ns = ns - prev_ns;
printf("Elapsed nanoseconds since last second: %ld\n", min_interval_ns);

auto sp_loop = Loop::New("epoll");
auto sp_loop = Loop::New();
auto timer_event = new TimerFd(sp_loop, std::to_string(min_interval_ns));
SetScopeExitAction([=] { delete timer_event; delete sp_loop; });

Expand Down Expand Up @@ -166,7 +166,7 @@ TEST(TimerFd, NanoSeconds)
//! 检查单次触发后,状态是否自动变成disable
TEST(TimerFd, OneshotCheckIsEnabled)
{
auto sp_loop = Loop::New("epoll");
auto sp_loop = Loop::New();
auto timer_event = new TimerFd(sp_loop, "101");
auto check_before_timer = sp_loop->newTimerEvent();
auto check_after_timer = sp_loop->newTimerEvent();
Expand Down

0 comments on commit 11ee715

Please sign in to comment.