From: Davin McCall Date: Tue, 16 Jan 2018 21:01:03 +0000 (+0000) Subject: Minor fixes to tests. X-Git-Tag: v0.08~25 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=deb9e08dfbd2884942b22f06f660d3f454216ca1;p=oweals%2Fdinit.git Minor fixes to tests. Make sure to initialise all service properties in tests. --- diff --git a/src/includes/proc-service.h b/src/includes/proc-service.h index 0952fff..6a5831c 100644 --- a/src/includes/proc-service.h +++ b/src/includes/proc-service.h @@ -110,6 +110,8 @@ class base_process_service : public service_record void kill_pg(int signo) noexcept; public: + // Constructor for a base_process_service. Note that the various parameters not specified here must in + // general be set separately (using the appropriate set_xxx function for each). base_process_service(service_set *sset, string name, service_type_t record_type_p, string &&command, std::list> &command_offsets, const std::list &deplist_p); diff --git a/src/tests/proctests.cc b/src/tests/proctests.cc index 25d4736..d1eae39 100644 --- a/src/tests/proctests.cc +++ b/src/tests/proctests.cc @@ -35,6 +35,15 @@ namespace bp_sys { extern pid_t last_forked_pid; } +static void init_service_defaults(process_service &ps) +{ + ps.set_restart_interval(time_val(10,0), 3); + ps.set_restart_delay(time_val(0, 200000000)); // 200 milliseconds + ps.set_stop_timeout(time_val(10,0)); + ps.set_start_timeout(time_val(10,0)); + ps.set_start_interruptible(false); +} + // Regular service start void test_proc_service_start() { @@ -48,6 +57,8 @@ void test_proc_service_start() std::list depends; process_service p = process_service(&sset, "testproc", std::move(command), command_offsets, depends); + init_service_defaults(p); + p.start(true); sset.process_queues(); @@ -99,6 +110,8 @@ void test_term_via_stop() std::list depends; process_service p = process_service(&sset, "testproc", std::move(command), command_offsets, depends); + init_service_defaults(p); + p.start(true); sset.process_queues(); @@ -131,6 +144,8 @@ void test_proc_start_timeout() std::list depends; process_service p = process_service(&sset, "testproc", std::move(command), command_offsets, depends); + init_service_defaults(p); + p.start(true); sset.process_queues(); @@ -160,6 +175,8 @@ void test_proc_stop_timeout() std::list depends; process_service p = process_service(&sset, "testproc", std::move(command), command_offsets, depends); + init_service_defaults(p); + p.start(true); sset.process_queues(); @@ -202,6 +219,7 @@ void test_proc_smooth_recovery1() std::list depends; process_service p = process_service(&sset, "testproc", std::move(command), command_offsets, depends); + init_service_defaults(p); p.set_smooth_recovery(true); p.start(true); @@ -229,6 +247,7 @@ void test_proc_smooth_recovery1() assert(p.get_state() == service_state_t::STARTED); } +// Smooth recovery without restart delay void test_proc_smooth_recovery2() { using namespace std; @@ -241,6 +260,7 @@ void test_proc_smooth_recovery2() std::list depends; process_service p = process_service(&sset, "testproc", std::move(command), command_offsets, depends); + init_service_defaults(p); p.set_smooth_recovery(true); p.set_restart_delay(time_val(0, 0));