From 2f1e799d1225b18e960d426d35b6a83fa80db86f Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 12 Mar 2018 15:13:47 -0700 Subject: fixes #281 desire nng_sleep_aio() --- tests/aio.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests') diff --git a/tests/aio.c b/tests/aio.c index 8af5dbc7..b57c5a69 100644 --- a/tests/aio.c +++ b/tests/aio.c @@ -12,6 +12,7 @@ #include "nng.h" #include "protocol/pair1/pair.h" +#include "supplemental/util/platform.h" #include "stubs.h" @@ -28,11 +29,33 @@ cbdone(void *p) (*(int *) p)++; } +void +sleepdone(void *arg) +{ + *(nng_time *) arg = nng_clock(); +} + Main({ Test("AIO operations", { const char *addr = "inproc://aio"; + Convey("Sleep works", { + nng_time start = 0; + nng_time end = 0; + nng_aio *saio; + So(nng_aio_alloc(&saio, sleepdone, &end) == 0); + start = nng_clock(); + nng_sleep_aio(200, saio); + nng_aio_wait(saio); + So(nng_aio_result(saio) == 0); + So(end != 0); + So((end - start) >= 200); + So((end - start) <= 1000); + So((nng_clock() - start) >= 200); + So((nng_clock() - start) <= 1000); + nng_aio_free(saio); + }); Convey("Given a connected pair of sockets", { nng_socket s1; nng_socket s2; -- cgit v1.2.3-70-g09d2