tevent: Add in some test code to allow the panic fallback path to be tested.
authorJeremy Allison <jra@samba.org>
Mon, 11 Feb 2013 18:52:30 +0000 (10:52 -0800)
committerJeremy Allison <jra@samba.org>
Thu, 14 Feb 2013 18:19:38 +0000 (10:19 -0800)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
lib/tevent/tevent_epoll.c

index 0ef1ffe9099dd343d35e829d59cb7bdd9faf5759..5a17331da6c180365d2bde48e2c755b7e28baabf 100644 (file)
@@ -43,6 +43,24 @@ struct epoll_event_context {
        bool (*panic_fallback)(struct tevent_context *ev, bool replay);
 };
 
+#ifdef TEST_PANIC_FALLBACK
+static int epoll_wait_panic_fallback(int epfd,
+                               struct epoll_event *events,
+                               int maxevents,
+                               int timeout)
+{
+       /* 50% of the time, fail... */
+       if ((random() % 2) == 0) {
+               errno = EINVAL;
+               return -1;
+       }
+
+       return epoll_wait(epfd, events, maxevents, timeout);
+}
+
+#define epoll_wait epoll_wait_panic_fallback
+#endif
+
 /*
   called to set the panic fallback function.
 */