Fix bug with activation count for auto-restart services
[oweals/dinit.git] / src / tests / proctests.cc
index 395ec3e05e0365f04a132d3657a4d29d87f4b43c..b75eea344e5fae6ccba9e2b851acef9ddaf70a87 100644 (file)
@@ -251,6 +251,7 @@ void test_proc_term_restart2()
     assert(p.get_state() == service_state_t::STARTED);
     assert(event_loop.active_timers.size() == 0);
 
+    // simulate process terminating, should then be restarted:
     base_process_service_test::handle_exit(&p, 0);
     sset.process_queues();
 
@@ -268,11 +269,32 @@ void test_proc_term_restart2()
     assert(p.get_state() == service_state_t::STARTED);
     assert(event_loop.active_timers.size() == 0);
 
+    assert(sset.count_active_services() == 2);
+
+    // Request stop, this time it should not restart:
+    p.stop(true);
+    sset.process_queues();
+    base_process_service_test::handle_exit(&p, 0);
+    sset.process_queues();
+
+    assert(p.get_state() == service_state_t::STOPPED);
+    assert(event_loop.active_timers.size() == 0);
+    assert(sset.count_active_services() == 1);
+
+    // simulate terminate dinit
+    sset.stop_all_services();
+
+    //base_process_service_test::handle_exit(&p, 0);
+    sset.process_queues();
+
+    assert(p.get_state() == service_state_t::STOPPED);
+    assert(event_loop.active_timers.size() == 0);
+    assert(sset.count_active_services() == 0);
+
     sset.remove_service(&p);
     sset.remove_service(&b);
 }
 
-
 // Termination via stop request
 void test_term_via_stop()
 {