diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-08-24 14:15:48 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-08-24 14:20:34 -0700 |
| commit | c9a68bfe6bea2acc708bf49045f6cb65017a3306 (patch) | |
| tree | e2b93b81b2962bdfb7953cb30fcfae08f0bd4093 /tests/reqrep.c | |
| parent | 68ff9c823d3cead2b11a003c40c8f5affc11dc71 (diff) | |
| download | nng-c9a68bfe6bea2acc708bf49045f6cb65017a3306.tar.gz nng-c9a68bfe6bea2acc708bf49045f6cb65017a3306.tar.bz2 nng-c9a68bfe6bea2acc708bf49045f6cb65017a3306.zip | |
Eliminate legacy option settings, provide easier option IDs.
This eliminates all the old #define's or enum values, making all
option IDs now totally dynamic, and providing well-known string
values for well-behaved applications.
We have added tests of some of these options, including lookups, and
so forth. We have also fixed a few problems; including at least
one crasher bug when the timeouts on reconnect were zero.
Protocol specific options are now handled in the protocol. We will
be moving the initialization for a few of those well known entities
to the protocol startup code, following the PAIRv1 pattern, later.
Applications must therefore not depend on the value of the integer IDs,
at least until the application has opened a socket of the appropriate
type.
Diffstat (limited to 'tests/reqrep.c')
| -rw-r--r-- | tests/reqrep.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/tests/reqrep.c b/tests/reqrep.c index e36232b6..537d45c8 100644 --- a/tests/reqrep.c +++ b/tests/reqrep.c @@ -1,5 +1,6 @@ // // Copyright 2017 Garrett D'Amore <garrett@damore.org> +// Copyright 2017 Capitar IT Group BV <info@capitar.com> // // This software is supplied under the terms of the MIT License, a // copy of which should be located in the distribution where this @@ -12,6 +13,9 @@ #include <string.h> +extern const char *nng_opt_req_resendtime; +extern int nng_optid_req_resendtime; + TestMain("REQ/REP pattern", { int rv; const char *addr = "inproc://test"; @@ -27,6 +31,22 @@ TestMain("REQ/REP pattern", { So(nng_peer(req) == NNG_PROTO_REP); }); + Convey("Resend time option id works", { + int opt; + const char *name; + opt = nng_option_lookup(nng_opt_req_resendtime); + So(opt >= 0); + So(opt == nng_optid_req_resendtime); + name = nng_option_name(opt); + So(name != NULL); + So(strcmp(name, nng_opt_req_resendtime) == 0); + + // Set timeout. + So(nng_setopt_usec(req, opt, 10000) == 0); + // Check invalid size + So(nng_setopt(req, opt, name, 1) == NNG_EINVAL); + }); + Convey("Recv with no send fails", { nng_msg *msg; rv = nng_recvmsg(req, &msg, 0); @@ -53,6 +73,11 @@ TestMain("REQ/REP pattern", { So(rv == NNG_ESTATE); nng_msg_free(msg); }); + + Convey("Cannot set resend time", { + So(nng_setopt_usec(rep, nng_optid_req_resendtime, + 100) == NNG_ENOTSUP); + }); }); Convey("We can create a linked REQ/REP pair", { @@ -115,8 +140,8 @@ TestMain("REQ/REP pattern", { nng_close(req); }); - So(nng_setopt_usec(req, NNG_OPT_RESENDTIME, retry) == 0); - So(nng_setopt_int(req, NNG_OPT_SNDBUF, 16) == 0); + So(nng_setopt_usec(req, nng_optid_req_resendtime, retry) == 0); + So(nng_setopt_int(req, nng_optid_sendbuf, 16) == 0); So(nng_msg_alloc(&abc, 0) == 0); So(nng_msg_append(abc, "abc", 4) == 0); |
