@@ -104,6 +104,7 @@ TEST_F(AsyncFunctionHandlerTest, check_initialization)
104
104
105
105
// Once initialized, it should not be possible to initialize again
106
106
async_class.get_handler ().start_thread ();
107
+ std::this_thread::sleep_for (std::chrono::milliseconds (10 ));
107
108
auto trigger_status = async_class.trigger ();
108
109
ASSERT_TRUE (trigger_status.first );
109
110
ASSERT_EQ (realtime_tools::return_type::OK, trigger_status.second );
@@ -130,6 +131,7 @@ TEST_F(AsyncFunctionHandlerTest, check_triggering)
130
131
// It shouldn't be possible to trigger without starting the thread
131
132
ASSERT_THROW (async_class.trigger (), std::runtime_error);
132
133
async_class.get_handler ().start_thread ();
134
+ std::this_thread::sleep_for (std::chrono::milliseconds (10 ));
133
135
134
136
ASSERT_TRUE (async_class.get_handler ().get_thread ().joinable ());
135
137
ASSERT_TRUE (
@@ -174,6 +176,7 @@ TEST_F(AsyncFunctionHandlerTest, trigger_for_several_cycles)
174
176
ASSERT_FALSE (async_class.get_handler ().is_running ());
175
177
ASSERT_FALSE (async_class.get_handler ().is_stopped ());
176
178
async_class.get_handler ().start_thread ();
179
+ std::this_thread::sleep_for (std::chrono::milliseconds (10 ));
177
180
178
181
EXPECT_EQ (async_class.get_state ().id (), lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE);
179
182
@@ -193,8 +196,8 @@ TEST_F(AsyncFunctionHandlerTest, trigger_for_several_cycles)
193
196
missed_triggers++;
194
197
}
195
198
}
196
- // Make sure that the failed triggers are less than 0.1 %
197
- ASSERT_LT (missed_triggers, static_cast <int >(0.001 * total_cycles))
199
+ // Make sure that the failed triggers are less than 0.5 %
200
+ ASSERT_LT (missed_triggers, static_cast <int >(0.005 * total_cycles))
198
201
<< " The missed triggers cannot be more than 0.1%!" ;
199
202
async_class.get_handler ().stop_thread ();
200
203
@@ -216,6 +219,7 @@ TEST_F(AsyncFunctionHandlerTest, test_with_deactivate_and_activate_cycles)
216
219
ASSERT_FALSE (async_class.get_handler ().is_running ());
217
220
ASSERT_FALSE (async_class.get_handler ().is_stopped ());
218
221
async_class.get_handler ().start_thread ();
222
+ std::this_thread::sleep_for (std::chrono::milliseconds (10 ));
219
223
ASSERT_TRUE (async_class.get_handler ().is_running ());
220
224
ASSERT_FALSE (async_class.get_handler ().is_stopped ());
221
225
EXPECT_EQ (async_class.get_state ().id (), lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE);
@@ -285,6 +289,7 @@ TEST_F(AsyncFunctionHandlerTest, check_triggering_with_different_return_state_an
285
289
ASSERT_FALSE (
286
290
realtime_tools::set_thread_affinity (async_class.get_handler ().get_thread (), 0 ).first );
287
291
async_class.get_handler ().start_thread ();
292
+ std::this_thread::sleep_for (std::chrono::milliseconds (10 ));
288
293
289
294
ASSERT_TRUE (async_class.get_handler ().get_thread ().joinable ());
290
295
ASSERT_TRUE (realtime_tools::set_thread_affinity (async_class.get_handler ().get_thread (), 0 ).first );
@@ -356,6 +361,7 @@ TEST_F(AsyncFunctionHandlerTest, check_exception_handling)
356
361
realtime_tools::TestAsyncFunctionHandler async_class;
357
362
async_class.initialize ();
358
363
async_class.get_handler ().start_thread ();
364
+ std::this_thread::sleep_for (std::chrono::milliseconds (10 ));
359
365
360
366
EXPECT_EQ (async_class.get_state ().id (), lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE);
361
367
auto trigger_status = async_class.trigger ();
@@ -401,6 +407,7 @@ TEST_F(AsyncFunctionHandlerTest, check_exception_handling)
401
407
402
408
async_class.reset_counter (0 );
403
409
async_class.get_handler ().start_thread ();
410
+ std::this_thread::sleep_for (std::chrono::milliseconds (10 ));
404
411
trigger_status = async_class.trigger ();
405
412
ASSERT_TRUE (trigger_status.first );
406
413
ASSERT_EQ (realtime_tools::return_type::OK, trigger_status.second );
0 commit comments