Fix time-out-during-start test.
authorDavin McCall <davmac@davmac.org>
Sun, 26 May 2019 04:09:43 +0000 (14:09 +1000)
committerDavin McCall <davmac@davmac.org>
Sun, 26 May 2019 04:09:43 +0000 (14:09 +1000)
src/tests/proctests.cc
src/tests/test-includes/dinit.h

index 026ca8f9a924a45094ff4add193cea65a0cdc73d..263c2a87a81a24444b412c7004d410ff1aa748d7 100644 (file)
@@ -321,8 +321,9 @@ void test_proc_start_timeout()
     command_offsets.emplace_back(0, command.length());
     std::list<prelim_dep> 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);
index 3b99881a2e0bc184eaccdb182df65078c18fc0d4..e3cef621d72395f9c325db9c3d582ea47df5c1e8 100644 (file)
@@ -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;