};
// Regular service start
-void test1()
+void test_proc_service_start()
{
using namespace std;
}
// Unexpected termination
-void test2()
+void test_proc_unexpected_term()
{
using namespace std;
}
// Termination via stop request
-void test3()
+void test_term_via_stop()
{
using namespace std;
}
// Time-out during start
-void test4()
+void test_proc_start_timeout()
{
using namespace std;
assert(p.get_state() == service_state_t::STOPPED);
}
+// Smooth recovery
+void test_proc_smooth_recovery()
+{
+ using namespace std;
+
+ service_set sset;
+
+ string command = "test-command";
+ list<pair<unsigned,unsigned>> command_offsets;
+ command_offsets.emplace_back(0, command.length());
+ std::list<prelim_dep> depends;
+
+ process_service p = process_service(&sset, "testproc", std::move(command), command_offsets, depends);
+ p.set_smooth_recovery(true);
+
+ 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::STARTED);
+}
+
-#define RUN_TEST(name) \
- std::cout << #name "... "; \
+#define RUN_TEST(name, spacing) \
+ std::cout << #name "..." spacing; \
name(); \
std::cout << "PASSED" << std::endl;
int main(int argc, char **argv)
{
- RUN_TEST(test1);
- RUN_TEST(test2);
- RUN_TEST(test3);
- RUN_TEST(test4);
+ RUN_TEST(test_proc_service_start, " ");
+ RUN_TEST(test_proc_unexpected_term, " ");
+ RUN_TEST(test_term_via_stop, " ");
+ RUN_TEST(test_proc_start_timeout, " ");
+ RUN_TEST(test_proc_smooth_recovery, " ");
}