aboutsummaryrefslogtreecommitdiff
path: root/tests/stubs.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/stubs.h')
-rw-r--r--tests/stubs.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/stubs.h b/tests/stubs.h
index da3a6d5f..c34bed7a 100644
--- a/tests/stubs.h
+++ b/tests/stubs.h
@@ -12,11 +12,23 @@
#define STUBS_H
#ifdef _WIN32
+
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+
#include <windows.h>
+#include <winsock2.h>
+// order counts
+#include <mswsock.h>
+#define PLATFD SOCKET
+#define poll WSAPoll
#else
+#include <poll.h>
#include <stdint.h>
#include <sys/time.h>
#include <time.h>
+#define PLATFD int
#endif
// Stub handlers for some common things.
@@ -46,6 +58,25 @@ getms(void)
#endif
}
+bool
+fdready(int fd)
+{
+ struct pollfd pfd;
+ pfd.fd = (PLATFD) fd;
+ pfd.events = POLLRDNORM;
+ pfd.revents = 0;
+
+ switch (poll(&pfd, 1, 0)) {
+ case 0:
+ return (false);
+ case 1:
+ return (true);
+ default:
+ ConveyError("BAD POLL RETURN!");
+ return (false);
+ }
+}
+
int
nosocket(nng_socket *s)
{