@@ -37,7 +37,7 @@ const int kAcceptableError = 1;
37
37
38
38
TEST (TimerFd, Oneshot)
39
39
{
40
- auto sp_loop = Loop::New (" epoll " );
40
+ auto sp_loop = Loop::New ();
41
41
auto timer_event = new TimerFd (sp_loop, " 10" );
42
42
SetScopeExitAction ([=] { delete timer_event; delete sp_loop; });
43
43
@@ -58,7 +58,7 @@ TEST(TimerFd, Oneshot)
58
58
59
59
TEST (TimerFd, Persist)
60
60
{
61
- auto sp_loop = Loop::New (" epoll " );
61
+ auto sp_loop = Loop::New ();
62
62
auto timer_event = new TimerFd (sp_loop, " 10" );
63
63
SetScopeExitAction ([=] { delete timer_event; delete sp_loop; });
64
64
@@ -68,7 +68,7 @@ TEST(TimerFd, Persist)
68
68
int run_time = 0 ;
69
69
timer_event->setCallback ([&run_time]() { ++run_time; });
70
70
71
- sp_loop->exitLoop (std::chrono::milliseconds (100 ));
71
+ sp_loop->exitLoop (std::chrono::milliseconds (101 )); // ! 多等1ms
72
72
sp_loop->runLoop ();
73
73
74
74
EXPECT_EQ (run_time, 10 );
@@ -77,7 +77,7 @@ TEST(TimerFd, Persist)
77
77
78
78
TEST (TimerFd, DisableSelfInCallback)
79
79
{
80
- auto sp_loop = Loop::New (" epoll " );
80
+ auto sp_loop = Loop::New ();
81
81
auto timer_event = new TimerFd (sp_loop, " 10" );
82
82
SetScopeExitAction ([=] { delete timer_event; delete sp_loop; });
83
83
@@ -100,7 +100,7 @@ TEST(TimerFd, DisableSelfInCallback)
100
100
101
101
TEST (TimerFd, Precision)
102
102
{
103
- auto sp_loop = Loop::New (" epoll " );
103
+ auto sp_loop = Loop::New ();
104
104
auto timer_event = new TimerFd (sp_loop, " 100" );
105
105
SetScopeExitAction ([=] { delete timer_event; delete sp_loop; });
106
106
@@ -137,7 +137,7 @@ TEST(TimerFd, NanoSeconds)
137
137
auto min_interval_ns = ns - prev_ns;
138
138
printf (" Elapsed nanoseconds since last second: %ld\n " , min_interval_ns);
139
139
140
- auto sp_loop = Loop::New (" epoll " );
140
+ auto sp_loop = Loop::New ();
141
141
auto timer_event = new TimerFd (sp_loop, std::to_string (min_interval_ns));
142
142
SetScopeExitAction ([=] { delete timer_event; delete sp_loop; });
143
143
@@ -166,7 +166,7 @@ TEST(TimerFd, NanoSeconds)
166
166
// ! 检查单次触发后,状态是否自动变成disable
167
167
TEST (TimerFd, OneshotCheckIsEnabled)
168
168
{
169
- auto sp_loop = Loop::New (" epoll " );
169
+ auto sp_loop = Loop::New ();
170
170
auto timer_event = new TimerFd (sp_loop, " 101" );
171
171
auto check_before_timer = sp_loop->newTimerEvent ();
172
172
auto check_after_timer = sp_loop->newTimerEvent ();
0 commit comments