From: Davin McCall Date: Sat, 13 Jan 2018 12:32:33 +0000 (+0000) Subject: Stub out Dasynq functionality for tests. X-Git-Tag: v0.08~45 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=75821e671d683784f256600382966a9645b7958a;p=oweals%2Fdinit.git Stub out Dasynq functionality for tests. Later some of this may be turned into proper mock functionality. --- diff --git a/src/tests/test-dinit.cc b/src/tests/test-dinit.cc index 9b6ca7a..ab22ab6 100644 --- a/src/tests/test-dinit.cc +++ b/src/tests/test-dinit.cc @@ -1,11 +1,15 @@ #include "dasynq.h" +#include "dinit.h" -using eventloop_t = dasynq::event_loop; +// using eventloop_t = dasynq::event_loop; eventloop_t event_loop; int active_control_conns = 0; +/* +These are provided in header instead: + void open_control_socket(bool report_ro_failure) noexcept { } @@ -13,3 +17,4 @@ void open_control_socket(bool report_ro_failure) noexcept void setup_external_log() noexcept { } +*/ diff --git a/src/tests/test-includes/dinit.h b/src/tests/test-includes/dinit.h new file mode 100644 index 0000000..8582bed --- /dev/null +++ b/src/tests/test-includes/dinit.h @@ -0,0 +1,115 @@ +#ifndef DINIT_H_INCLUDED +#define DINIT_H_INCLUDED 1 + +// dummy dinit.h + +#include "dasynq.h" + +using clock_type = dasynq::clock_type; +using rearm = dasynq::rearm; +using time_val = dasynq::time_val; + +class eventloop_t +{ + public: + void get_time(time_val &tv, dasynq::clock_type clock) noexcept + { + tv = {0, 0}; + } + + class child_proc_watcher + { + public: + pid_t fork(eventloop_t &loop, bool reserved_child_watcher, int priority = dasynq::DEFAULT_PRIORITY) + { + return -1; + } + + void add_reserved(eventloop_t &eloop, pid_t child, int prio = dasynq::DEFAULT_PRIORITY) noexcept + { + + } + + void stop_watch(eventloop_t &eloop) noexcept + { + + } + + void deregister(eventloop_t &loop, pid_t pid) noexcept + { + + } + }; + + template class child_proc_watcher_impl : public child_proc_watcher + { + + }; + + class fd_watcher + { + int watched_fd; + + public: + void add_watch(eventloop_t &loop, int fd, int events, bool enable = true) + { + watched_fd = fd; + } + + int get_watched_fd() noexcept + { + return watched_fd; + } + + void set_enabled(eventloop_t &loop, bool enable) noexcept + { + + } + + void deregister(eventloop_t &loop) noexcept + { + + } + }; + + template class fd_watcher_impl : public fd_watcher + { + + }; + + class timer + { + public: + void add_timer(eventloop_t &loop) + { + + } + + void arm_timer_rel(eventloop_t &loop, time_val timeout) noexcept + { + + } + + void stop_timer(eventloop_t &loop) noexcept + { + + } + }; + + template class timer_impl : public timer + { + + }; +}; + +inline void open_control_socket(bool report_ro_failure = true) noexcept +{ +} + +inline void setup_external_log() noexcept +{ +} + +extern eventloop_t event_loop; + +#endif