From 15f63c95df73da3146d08331496f606e460d5821 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Wed, 11 Dec 2019 18:26:08 -0800 Subject: Add test case for bug 942. --- tests/pubsub.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/tests/pubsub.c b/tests/pubsub.c index d61867ce..68b7e3a4 100644 --- a/tests/pubsub.c +++ b/tests/pubsub.c @@ -136,16 +136,35 @@ TestMain("PUB/SUB pattern", { nng_msg_free(msg); }); - Convey("Subs without subsciptions don't receive", { + Convey("Subs using NNG_FLAG_NONBLOCK and no sub", { nng_msg *msg; - So(nng_setopt_ms(sub, NNG_OPT_RECVTIMEO, 90) == 0); So(nng_msg_alloc(&msg, 0) == 0); APPENDSTR(msg, "/some/don't/like/it"); So(nng_sendmsg(pub, msg, 0) == 0); - So(nng_recvmsg(sub, &msg, 0) == NNG_ETIMEDOUT); + So(nng_recvmsg(sub, &msg, NNG_FLAG_NONBLOCK) == NNG_EAGAIN); }); - }); + Convey("Subs using NNG_FLAG_NONBLOCK and empty sub", { + nng_msg *msg; + char *buf; + size_t size; + + So(nng_setopt(sub, NNG_OPT_SUB_SUBSCRIBE, "", 0) == 0); + So(nng_recvmsg(sub, &msg, NNG_FLAG_NONBLOCK) == NNG_EAGAIN); + So(nng_recv(sub, &buf, &size, NNG_FLAG_NONBLOCK | NNG_FLAG_ALLOC) == NNG_EAGAIN); + }); + + Convey("Subs without subscriptions don't receive", { + nng_msg *msg; + So(nng_setopt_ms(sub, NNG_OPT_RECVTIMEO, 90) == 0); + + So(nng_msg_alloc(&msg, 0) == 0); + APPENDSTR(msg, "/some/don't/like/it"); + So(nng_sendmsg(pub, msg, 0) == 0); + So(nng_recvmsg(sub, &msg, 0) == NNG_ETIMEDOUT); + }); + + }); Convey("Subs in raw receive", { nng_msg * msg; -- cgit v1.2.3-70-g09d2