aboutsummaryrefslogtreecommitdiff
path: root/contrib/ntp/sntp/libevent/test/test-time.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ntp/sntp/libevent/test/test-time.c')
-rw-r--r--contrib/ntp/sntp/libevent/test/test-time.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/contrib/ntp/sntp/libevent/test/test-time.c b/contrib/ntp/sntp/libevent/test/test-time.c
index dcd6639a56fb..bcc7086df7ed 100644
--- a/contrib/ntp/sntp/libevent/test/test-time.c
+++ b/contrib/ntp/sntp/libevent/test/test-time.c
@@ -41,6 +41,7 @@
#include "event2/event.h"
#include "event2/event_compat.h"
#include "event2/event_struct.h"
+#include "util-internal.h"
int called = 0;
@@ -48,14 +49,12 @@ int called = 0;
struct event *ev[NEVENT];
+struct evutil_weakrand_state weakrand_state;
+
static int
rand_int(int n)
{
-#ifdef _WIN32
- return (int)(rand() % n);
-#else
- return (int)(random() % n);
-#endif
+ return evutil_weakrand_(&weakrand_state) % n;
}
static void
@@ -71,7 +70,7 @@ time_cb(evutil_socket_t fd, short event, void *arg)
j = rand_int(NEVENT);
tv.tv_sec = 0;
tv.tv_usec = rand_int(50000);
- if (tv.tv_usec % 2)
+ if (tv.tv_usec % 2 || called < NEVENT)
evtimer_add(ev[j], &tv);
else
evtimer_del(ev[j]);
@@ -93,6 +92,8 @@ main(int argc, char **argv)
(void) WSAStartup(wVersionRequested, &wsaData);
#endif
+ evutil_weakrand_seed_(&weakrand_state, 0);
+
/* Initalize the event library */
event_init();
@@ -108,6 +109,8 @@ main(int argc, char **argv)
event_dispatch();
+
+ printf("%d, %d\n", called, NEVENT);
return (called < NEVENT);
}