diff --git a/test/test-time.c b/test/test-time.c index 8d4bf7a467..a8b3846263 100644 --- a/test/test-time.c +++ b/test/test-time.c @@ -81,8 +81,10 @@ time_cb(evutil_socket_t fd, short event, void *arg) int main(int argc, char **argv) { + struct event_base *base; struct timeval tv; int i; + #ifdef _WIN32 WORD wVersionRequested; WSADATA wsaData; @@ -98,23 +100,24 @@ main(int argc, char **argv) event_enable_debug_logging(EVENT_DBG_ALL); } - /* Initialize the event library */ - event_init(); + base = event_base_new(); for (i = 0; i < NEVENT; i++) { - ev[i] = malloc(sizeof(struct event)); - - /* Initialize one event */ - evtimer_set(ev[i], time_cb, ev[i]); + ev[i] = evtimer_new(base, time_cb, event_self_cbarg()); tv.tv_sec = 0; tv.tv_usec = rand_int(50000); evtimer_add(ev[i], &tv); } - event_dispatch(); + i = event_base_dispatch(base); + printf("event_base_dispatch=%d, called=%d, EVENT=%d\n", + i, called, NEVENT); - printf("%d, %d\n", called, NEVENT); - return (called < NEVENT); + if (i == 1 && called >= NEVENT) { + return EXIT_SUCCESS; + } else { + return EXIT_FAILURE; + } }