Clean up fuzz test source
[oweals/dinit.git] / src / tests / test_service.h
1 #include "service.h"
2
3 // A test service.
4 //
5 // This service can be induced to successfully start or fail (once it is STARTING) by calling either the
6 // started() or failed_to_start() functions.
7 //
8 class test_service : public service_record
9 {
10     public:
11     test_service(service_set *set, std::string name, service_type_t type_p,
12             const std::list<prelim_dep> &deplist_p)
13             : service_record(set, name, type_p, deplist_p)
14     {
15
16     }
17
18     // Do any post-dependency startup; return false on failure
19     virtual bool bring_up() noexcept override
20     {
21         // return service_record::bring_up();
22         return true;
23     }
24
25     // All dependents have stopped.
26     virtual void bring_down() noexcept override
27     {
28         return service_record::bring_down();
29     }
30
31     // Whether a STARTING service can immediately transition to STOPPED (as opposed to
32     // having to wait for it reach STARTED and then go through STOPPING).
33     virtual bool can_interrupt_start() noexcept override
34     {
35         return waiting_for_deps;
36     }
37
38     virtual bool interrupt_start() noexcept override
39     {
40         return true;
41     }
42
43     void started() noexcept
44     {
45         service_record::started();
46     }
47
48     void failed_to_start() noexcept
49     {
50         service_record::failed_to_start();
51     }
52 };