From 3bed9dca3a3ae5b226e3bf6aee3352d7665dbcc2 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sat, 24 Dec 2016 15:22:36 -0800 Subject: Expose nng_sendmsg. --- tests/sock.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests') diff --git a/tests/sock.c b/tests/sock.c index 931e114a..65ed5565 100644 --- a/tests/sock.c +++ b/tests/sock.c @@ -54,6 +54,27 @@ TestMain("Socket Operations", { So(msg == NULL); }) + Convey("Send with no pipes times out correctly", { + nng_msg *msg = NULL; + int64_t when = 500000; + uint64_t now; + + // We cheat to get access to the core's clock. + So(nng_msg_alloc(&msg, 0) == 0); + So(msg != NULL); + extern uint64_t nni_clock(void); + now = nni_clock(); + + rv = nng_setopt(sock, NNG_OPT_SNDTIMEO, &when, + sizeof (when)); + So(rv == 0); + rv = nng_sendmsg(sock, msg, 0); + So(rv == NNG_ETIMEDOUT); + So(nni_clock() > (now + 500000)); + So(nni_clock() < (now + 1000000)); + nng_msg_free(msg); + }) + Convey("We can set and get options", { int64_t when = 1234; int64_t check = 0; -- cgit v1.2.3-70-g09d2