From 2b6408065feceb586b6a9b2eb0c6d218290e17fa Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Sun, 26 May 2019 14:09:43 +1000 Subject: [PATCH] Fix time-out-during-start test. --- src/tests/proctests.cc | 8 +++++--- src/tests/test-includes/dinit.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/tests/proctests.cc b/src/tests/proctests.cc index 026ca8f..263c2a8 100644 --- a/src/tests/proctests.cc +++ b/src/tests/proctests.cc @@ -321,8 +321,9 @@ void test_proc_start_timeout() command_offsets.emplace_back(0, command.length()); std::list depends; - process_service p {&sset, "testproc", std::move(command), command_offsets, depends}; + scripted_service p {&sset, "testproc", std::move(command), command_offsets, depends}; init_service_defaults(p); + p.set_start_timeout(time_val(10,0)); sset.add_service(&p); p.start(true); @@ -330,14 +331,15 @@ void test_proc_start_timeout() assert(p.get_state() == service_state_t::STARTING); - p.timer_expired(); + event_loop.advance_time(time_val(10,0)); sset.process_queues(); assert(p.get_state() == service_state_t::STOPPING); - base_process_service_test::handle_exit(&p, 0); + base_process_service_test::handle_signal_exit(&p, SIGTERM); sset.process_queues(); + // We set no stop script, so state should now be STOPPED with no timer set assert(p.get_state() == service_state_t::STOPPED); assert(p.get_stop_reason() == stopped_reason_t::TIMEDOUT); assert(event_loop.active_timers.size() == 0); diff --git a/src/tests/test-includes/dinit.h b/src/tests/test-includes/dinit.h index 3b99881..e3cef62 100644 --- a/src/tests/test-includes/dinit.h +++ b/src/tests/test-includes/dinit.h @@ -28,6 +28,7 @@ class eventloop_t tv = current_time; } + // Advance the simulated current time by the given amount, and call timer callbacks. void advance_time(time_val amount) { current_time += amount; -- 2.25.1