Skip to content

Commit 11ee715

Browse files
committed
fix(eventx):解决在禁了epoll之后TimerFd单元测试不过问题
1 parent 7a9022c commit 11ee715

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

modules/base/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ LIB_VERSION_X = 1
2626
LIB_VERSION_Y = 0
2727
LIB_VERSION_Z = 1
2828

29-
HAVE_EXECINFO_H ?= yes # 默认支持execinfo.h
29+
HAVE_EXECINFO_H ?= yes
3030

3131
HEAD_FILES = \
3232
version.h \

modules/event/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ LIB_VERSION_X = 1
2424
LIB_VERSION_Y = 2
2525
LIB_VERSION_Z = 0
2626

27-
HAVE_EPOLL ?= yes # 默认支持epoll
27+
HAVE_EPOLL ?= yes
2828

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

modules/eventx/timer_fd_test.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const int kAcceptableError = 1;
3737

3838
TEST(TimerFd, Oneshot)
3939
{
40-
auto sp_loop = Loop::New("epoll");
40+
auto sp_loop = Loop::New();
4141
auto timer_event = new TimerFd(sp_loop, "10");
4242
SetScopeExitAction([=] { delete timer_event; delete sp_loop; });
4343

@@ -58,7 +58,7 @@ TEST(TimerFd, Oneshot)
5858

5959
TEST(TimerFd, Persist)
6060
{
61-
auto sp_loop = Loop::New("epoll");
61+
auto sp_loop = Loop::New();
6262
auto timer_event = new TimerFd(sp_loop, "10");
6363
SetScopeExitAction([=] { delete timer_event; delete sp_loop; });
6464

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

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

7474
EXPECT_EQ(run_time, 10);
@@ -77,7 +77,7 @@ TEST(TimerFd, Persist)
7777

7878
TEST(TimerFd, DisableSelfInCallback)
7979
{
80-
auto sp_loop = Loop::New("epoll");
80+
auto sp_loop = Loop::New();
8181
auto timer_event = new TimerFd(sp_loop, "10");
8282
SetScopeExitAction([=] { delete timer_event; delete sp_loop; });
8383

@@ -100,7 +100,7 @@ TEST(TimerFd, DisableSelfInCallback)
100100

101101
TEST(TimerFd, Precision)
102102
{
103-
auto sp_loop = Loop::New("epoll");
103+
auto sp_loop = Loop::New();
104104
auto timer_event = new TimerFd(sp_loop, "100");
105105
SetScopeExitAction([=] { delete timer_event; delete sp_loop; });
106106

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

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

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

0 commit comments

Comments
 (0)