diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | tests/compat_options.c | 57 |
2 files changed, 61 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 46236423..d6283dbc 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -187,5 +187,9 @@ add_nng_compat_test(compat_survey 5) add_nng_compat_test(compat_reqttl 5) add_nng_compat_test(compat_shutdown 5) +# These are special tests for compat mode, not inherited from the +# legacy libnanomsg suite. +add_nng_test(compat_options 5 NNG_PROTO_REP0) + # c++ tests add_nng_cpp_test(cplusplus_pair 5) diff --git a/tests/compat_options.c b/tests/compat_options.c new file mode 100644 index 00000000..1cf147f5 --- /dev/null +++ b/tests/compat_options.c @@ -0,0 +1,57 @@ +// +// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2018 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 +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +#include "convey.h" + +#include "compat/nanomsg/nn.h" + +#include "compat_testutil.h" + +#include <string.h> + +#define SECONDS(x) ((x) *1000) + +TestMain("Compatible Options", { + + atexit(nn_term); + + Convey("Given a compat NN_REP socket", { + int repsock; + + So((repsock = nn_socket(AF_SP, NN_REP)) != -1); + Reset({ nn_close(repsock); }); + + Convey("NN_DOMAIN works", { + int dom = 4321; + size_t sz; + sz = sizeof(dom); + So(nn_getsockopt(repsock, NN_SOL_SOCKET, NN_DOMAIN, + &dom, &sz) == 0); + So(sz == sizeof(dom)); + So(dom == AF_SP); + + So(nn_setsockopt(repsock, NN_SOL_SOCKET, NN_DOMAIN, + &dom, sz) == -1); + So(nn_errno() == ENOPROTOOPT); + }); + Convey("NN_LINGER has no effect", { + int l = 4321; + size_t sz; + sz = sizeof(l); + So(nn_setsockopt(repsock, NN_SOL_SOCKET, NN_LINGER, &l, + sz) == 0); + + So(nn_getsockopt(repsock, NN_SOL_SOCKET, NN_LINGER, &l, + &sz) == 0); + So(sz == sizeof(l)); + So(l == 0); + }); + }); +}) |
