From 376c1335532efa1b58cffd5a62405c40c7afe57b Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Mon, 15 Jan 2018 18:36:38 +0000 Subject: [PATCH] proctests: complete existing tests and add a 4th (currently fails). --- src/tests/proctests.cc | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/tests/proctests.cc b/src/tests/proctests.cc index eb45389..bbeb578 100644 --- a/src/tests/proctests.cc +++ b/src/tests/proctests.cc @@ -65,12 +65,15 @@ void test2() process_service p = process_service(&sset, "testproc", std::move(command), command_offsets, depends); p.start(true); + sset.process_queues(); base_process_service_test::exec_succeeded(&p); + sset.process_queues(); assert(p.get_state() == service_state_t::STARTED); base_process_service_test::handle_exit(&p, 0); + sset.process_queues(); assert(p.get_state() == service_state_t::STOPPED); } @@ -89,16 +92,49 @@ void test3() process_service p = process_service(&sset, "testproc", std::move(command), command_offsets, depends); p.start(true); + sset.process_queues(); base_process_service_test::exec_succeeded(&p); + sset.process_queues(); assert(p.get_state() == service_state_t::STARTED); p.stop(true); + sset.process_queues(); assert(p.get_state() == service_state_t::STOPPING); base_process_service_test::handle_exit(&p, 0); + sset.process_queues(); + + assert(p.get_state() == service_state_t::STOPPED); +} + +// Time-out during start +void test4() +{ + using namespace std; + + service_set sset; + + string command = "test-command"; + list> command_offsets; + command_offsets.emplace_back(0, command.length()); + std::list depends; + + process_service p = process_service(&sset, "testproc", std::move(command), command_offsets, depends); + p.start(true); + sset.process_queues(); + + assert(p.get_state() == service_state_t::STARTING); + + p.timer_expired(); + sset.process_queues(); + + assert(p.get_state() == service_state_t::STOPPING); + + base_process_service_test::handle_exit(&p, 0); + sset.process_queues(); assert(p.get_state() == service_state_t::STOPPED); } @@ -114,4 +150,5 @@ int main(int argc, char **argv) RUN_TEST(test1); RUN_TEST(test2); RUN_TEST(test3); + RUN_TEST(test4); } -- 2.25.1