Stub out Dasynq functionality for tests.
authorDavin McCall <davmac@davmac.org>
Sat, 13 Jan 2018 12:32:33 +0000 (12:32 +0000)
committerDavin McCall <davmac@davmac.org>
Sat, 13 Jan 2018 12:32:33 +0000 (12:32 +0000)
Later some of this may be turned into proper mock functionality.

src/tests/test-dinit.cc
src/tests/test-includes/dinit.h [new file with mode: 0644]

index 9b6ca7a0d52c57f669377954eb3de6583bd47f58..ab22ab6686c26e51be26a1a86a5c2923399744f8 100644 (file)
@@ -1,11 +1,15 @@
 #include "dasynq.h"
+#include "dinit.h"
 
-using eventloop_t = dasynq::event_loop<dasynq::null_mutex>;
+// using eventloop_t = dasynq::event_loop<dasynq::null_mutex>;
 
 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 (file)
index 0000000..8582bed
--- /dev/null
@@ -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 <typename Derived> 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 <typename Derived> 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 <typename Derived> 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