diff --git a/src/supplemental/util/CMakeLists.txt b/src/supplemental/util/CMakeLists.txt index 6a820b21f..edae518e1 100644 --- a/src/supplemental/util/CMakeLists.txt +++ b/src/supplemental/util/CMakeLists.txt @@ -13,3 +13,4 @@ nng_headers( nng/supplemental/util/options.h nng/supplemental/util/platform.h) nng_test(idhash_test) +nng_test(options_test) diff --git a/src/supplemental/util/options_test.c b/src/supplemental/util/options_test.c new file mode 100644 index 000000000..e365f97e0 --- /dev/null +++ b/src/supplemental/util/options_test.c @@ -0,0 +1,320 @@ +// +// Copyright 2024 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// 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 "nng/nng.h" +#include + +#include + +static nng_optspec case1[] = { + // clang-format off + { "flag", 'f', 1, false }, + { "longflag", 0, 2, false }, + { "value", 'v', 3, true }, + { NULL, 'b', 4, false }, + { NULL, 0, 0, false }, + // clang-format on +}; + +void +test_simple_options(void) +{ + int opti = 1; + char *av[6]; + int ac = 5; + int v; + char *a = NULL; + + av[0] = "program"; + av[1] = "-f"; + av[2] = "-v"; + av[3] = "123"; + av[4] = "456"; + NUTS_PASS(nng_opts_parse(ac, av, case1, &v, &a, &opti)); + NUTS_TRUE(v == 1); + NUTS_NULL(a); + NUTS_TRUE(opti == 2); + NUTS_PASS(nng_opts_parse(ac, av, case1, &v, &a, &opti)); + NUTS_TRUE(opti == 4); + NUTS_TRUE(v == 3); + NUTS_MATCH(a, "123"); + NUTS_TRUE(nng_opts_parse(ac, av, case1, &v, &a, &opti) == -1); + NUTS_TRUE(opti == 4); + NUTS_MATCH(av[opti], "456"); +} + +void +test_long_options(void) +{ + int opti = 1; + char *av[6]; + int ac = 5; + int v; + char *a = NULL; + + av[0] = "program"; + av[1] = "--flag"; + av[2] = "--value"; + av[3] = "123"; + av[4] = "456"; + NUTS_PASS(nng_opts_parse(ac, av, case1, &v, &a, &opti)); + NUTS_TRUE(v == 1); + NUTS_NULL(a); + NUTS_TRUE(opti == 2); + NUTS_PASS(nng_opts_parse(ac, av, case1, &v, &a, &opti)); + NUTS_TRUE(opti == 4); + NUTS_TRUE(v == 3); + NUTS_MATCH(a, "123"); + NUTS_TRUE(nng_opts_parse(ac, av, case1, &v, &a, &opti) == -1); + NUTS_TRUE(opti == 4); + NUTS_MATCH(av[opti], "456"); +} + +void +test_attached_short(void) +{ + int opti = 1; + char *av[3]; + int ac = 3; + int v; + char *a = NULL; + + av[0] = "program"; + av[1] = "-v123"; + av[2] = "456"; + NUTS_PASS(nng_opts_parse(ac, av, case1, &v, &a, &opti)); + NUTS_TRUE(opti == 2); + NUTS_TRUE(v == 3); + NUTS_MATCH(a, "123"); + NUTS_TRUE(nng_opts_parse(ac, av, case1, &v, &a, &opti) == -1); + NUTS_TRUE(opti == 2); + NUTS_MATCH(av[opti], "456"); +} + +void +test_attached_long_equals(void) +{ + int opti = 1; + char *av[3]; + int ac = 3; + int v; + char *a = NULL; + + av[0] = "program"; + av[1] = "--value=123"; + av[2] = "456"; + NUTS_PASS(nng_opts_parse(ac, av, case1, &v, &a, &opti)); + NUTS_TRUE(opti == 2); + NUTS_TRUE(v == 3); + NUTS_MATCH(a, "123"); + NUTS_TRUE(nng_opts_parse(ac, av, case1, &v, &a, &opti) == -1); + NUTS_TRUE(opti == 2); + NUTS_MATCH(av[opti], "456"); +} + +void +test_attached_long_colon(void) +{ + int opti = 1; + char *av[3]; + int ac = 3; + int v; + char *a = NULL; + + av[0] = "program"; + av[1] = "--value:123"; + av[2] = "456"; + NUTS_PASS(nng_opts_parse(ac, av, case1, &v, &a, &opti)); + NUTS_TRUE(opti == 2); + NUTS_TRUE(v == 3); + NUTS_MATCH(a, "123"); + NUTS_TRUE(nng_opts_parse(ac, av, case1, &v, &a, &opti) == -1); + NUTS_TRUE(opti == 2); + NUTS_MATCH(av[opti], "456"); +} + +void +test_negative_bad_short(void) +{ + int opti = 1; + char *av[3]; + int ac = 3; + int v; + char *a = NULL; + + av[0] = "program"; + av[1] = "-Z"; + av[2] = "456"; + NUTS_FAIL(nng_opts_parse(ac, av, case1, &v, &a, &opti), NNG_EINVAL); + NUTS_TRUE(opti == 1); +} + +void +test_negative_bad_long(void) +{ + int opti = 1; + char *av[3]; + int ac = 3; + int v; + char *a = NULL; + + av[0] = "program"; + av[1] = "--something"; + av[2] = "456"; + NUTS_FAIL(nng_opts_parse(ac, av, case1, &v, &a, &opti), NNG_EINVAL); + NUTS_TRUE(opti == 1); +} + +void +test_option_separator_flag(void) +{ + int opti = 1; + char *av[5]; + int ac = 5; + int v; + char *a = NULL; + + av[0] = "program"; + av[1] = "-f"; + av[2] = "-"; + av[3] = "-v"; + av[4] = "456"; + NUTS_PASS(nng_opts_parse(ac, av, case1, &v, &a, &opti)); + NUTS_TRUE(v == 1); + NUTS_TRUE(opti == 2); + NUTS_TRUE(nng_opts_parse(ac, av, case1, &v, &a, &opti) == -1); + NUTS_TRUE(opti == 3); +} + +void +test_no_options(void) +{ + int opti = 1; + char *av[1]; + int ac = 1; + int v; + char *a = NULL; + + av[0] = "program"; + NUTS_TRUE(nng_opts_parse(ac, av, case1, &v, &a, &opti) == -1); +} + +void +test_arg_only(void) +{ + int opti = 1; + char *av[2]; + int ac = 2; + int v; + char *a = NULL; + + av[0] = "program"; + av[1] = "123"; + NUTS_TRUE(nng_opts_parse(ac, av, case1, &v, &a, &opti) == -1); + NUTS_TRUE(opti == 1); +} + +void +test_mixed_long_short(void) +{ + int opti = 1; + char *av[7]; + int ac = 7; + int v; + char *a = NULL; + + av[0] = "program"; + av[1] = "--value=123"; + av[2] = "-f"; + av[3] = "--longflag"; + av[4] = "-b"; + av[5] = "-vxyz"; + av[6] = "456"; + NUTS_PASS(nng_opts_parse(ac, av, case1, &v, &a, &opti)); + NUTS_TRUE(opti == 2); + NUTS_TRUE(v == 3); + NUTS_MATCH(a, "123"); + NUTS_PASS(nng_opts_parse(ac, av, case1, &v, &a, &opti)); + NUTS_TRUE(opti == 3); + NUTS_TRUE(v == 1); + NUTS_PASS(nng_opts_parse(ac, av, case1, &v, &a, &opti)); + NUTS_TRUE(opti == 4); + NUTS_TRUE(v == 2); + NUTS_PASS(nng_opts_parse(ac, av, case1, &v, &a, &opti)); + NUTS_TRUE(opti == 5); + NUTS_TRUE(v == 4); + NUTS_PASS(nng_opts_parse(ac, av, case1, &v, &a, &opti)); + NUTS_TRUE(opti == 6); + NUTS_TRUE(v == 3); + NUTS_MATCH(a, "xyz"); + NUTS_MATCH(av[opti], "456"); + NUTS_TRUE(nng_opts_parse(ac, av, case1, &v, &a, &opti) == -1); + NUTS_TRUE(opti == 6); +} + +void +test_ambiguous(void) +{ + int opti = 1; + char *av[2]; + int ac = 2; + int v; + char *a = NULL; + + nng_optspec spec[] = { + { "flag", 'f', 1, false }, + { "fluid", 0, 2, false }, + { NULL, 0, 0, false }, + }; + + av[0] = "program"; + av[1] = "--fl"; + NUTS_FAIL(nng_opts_parse(ac, av, spec, &v, &a, &opti), NNG_EAMBIGUOUS); +} + +void +test_missing_arg(void) +{ + int opti = 1; + char *av[2]; + int ac = 2; + int v; + char *a = NULL; + + nng_optspec spec[] = { + { "flag", 'f', 1, true }, + { NULL, 0, 0, false }, + }; + + av[0] = "program"; + av[1] = "--fl"; + NUTS_FAIL(nng_opts_parse(ac, av, spec, &v, &a, &opti), NNG_ENOARG); + av[0] = "program"; + av[1] = "-f"; + opti = 1; + NUTS_FAIL(nng_opts_parse(ac, av, spec, &v, &a, &opti), NNG_ENOARG); +} + +NUTS_TESTS = { + { "simple options", test_simple_options }, + { "long options", test_long_options }, + { "separator flag", test_option_separator_flag }, + { "no options", test_no_options }, + { "attached short", test_attached_long_equals }, + { "attached long equals", test_attached_long_equals }, + { "attached long colon", test_attached_long_colon }, + { "bad short", test_negative_bad_short }, + { "bad long", test_negative_bad_long }, + { "arg only", test_arg_only }, + { "options mixed long short", test_mixed_long_short }, + { "ambiguous options", test_ambiguous }, + { "missing argument", test_missing_arg }, + { NULL, NULL }, +}; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3868a9552..d4e008bd3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -132,7 +132,6 @@ add_nng_test(inproc 5) add_nng_test(ipcsupp 10) add_nng_test(multistress 60) add_nng_test(nonblock 60) -add_nng_test(options 5) add_nng_test(pipe 5) add_nng_test(scalability 20 ON) add_nng_test(synch 5) @@ -143,7 +142,6 @@ add_nng_test(ws 30) add_nng_test(wss 30) add_nng_test1(zt 60 NNG_TRANSPORT_ZEROTIER) -add_nng_test(reqctx 5) add_nng_test(reqstress 60) # c++ tests diff --git a/tests/options.c b/tests/options.c deleted file mode 100644 index 191340051..000000000 --- a/tests/options.c +++ /dev/null @@ -1,241 +0,0 @@ -// -// Copyright 2018 Staysail Systems, Inc. -// Copyright 2018 Capitar IT Group BV -// -// 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 - -#include -#include - -#include "convey.h" - -static nng_optspec case1[] = { - // clang-format off - { "flag", 'f', 1, false }, - { "longflag", 0, 2, false }, - { "value", 'v', 3, true }, - { NULL, 'b', 4, false }, - { NULL, 0, 0, false }, - // clang-format on -}; - -TestMain("Option Parsing", { - Convey("Simple works", { - int opti = 1; - char *av[6]; - int ac = 5; - int v; - char *a = NULL; - - av[0] = "program"; - av[1] = "-f"; - av[2] = "-v"; - av[3] = "123"; - av[4] = "456"; - So(nng_opts_parse(ac, av, case1, &v, &a, &opti) == 0); - So(v == 1); - So(a == NULL); - So(opti == 2); - So(nng_opts_parse(ac, av, case1, &v, &a, &opti) == 0); - So(opti == 4); - So(v == 3); - So(strcmp(a, "123") == 0); - So(nng_opts_parse(ac, av, case1, &v, &a, &opti) == -1); - So(opti == 4); - So(strcmp(av[opti], "456") == 0); - }); - - Convey("Long works", { - int opti = 1; - char *av[6]; - int ac = 5; - int v; - char *a = NULL; - - av[0] = "program"; - av[1] = "--flag"; - av[2] = "--value"; - av[3] = "123"; - av[4] = "456"; - So(nng_opts_parse(ac, av, case1, &v, &a, &opti) == 0); - So(v == 1); - So(a == NULL); - So(opti == 2); - So(nng_opts_parse(ac, av, case1, &v, &a, &opti) == 0); - So(opti == 4); - So(v == 3); - So(strcmp(a, "123") == 0); - So(nng_opts_parse(ac, av, case1, &v, &a, &opti) == -1); - So(opti == 4); - So(strcmp(av[opti], "456") == 0); - }); - - Convey("Attached short works", { - int opti = 1; - char *av[3]; - int ac = 3; - int v; - char *a = NULL; - - av[0] = "program"; - av[1] = "-v123"; - av[2] = "456"; - So(nng_opts_parse(ac, av, case1, &v, &a, &opti) == 0); - So(opti == 2); - So(v == 3); - So(strcmp(a, "123") == 0); - So(nng_opts_parse(ac, av, case1, &v, &a, &opti) == -1); - So(opti == 2); - So(strcmp(av[opti], "456") == 0); - }); - - Convey("Attached long (=) works", { - int opti = 1; - char *av[3]; - int ac = 3; - int v; - char *a = NULL; - - av[0] = "program"; - av[1] = "--value=123"; - av[2] = "456"; - So(nng_opts_parse(ac, av, case1, &v, &a, &opti) == 0); - So(opti == 2); - So(v == 3); - So(strcmp(a, "123") == 0); - So(nng_opts_parse(ac, av, case1, &v, &a, &opti) == -1); - So(opti == 2); - So(strcmp(av[opti], "456") == 0); - }); - - Convey("Attached long (:) works", { - int opti = 1; - char *av[3]; - int ac = 3; - int v; - char *a = NULL; - - av[0] = "program"; - av[1] = "--value:123"; - av[2] = "456"; - So(nng_opts_parse(ac, av, case1, &v, &a, &opti) == 0); - So(opti == 2); - So(v == 3); - So(strcmp(a, "123") == 0); - So(nng_opts_parse(ac, av, case1, &v, &a, &opti) == -1); - So(opti == 2); - So(strcmp(av[opti], "456") == 0); - }); - - Convey("Negative bad short works", { - int opti = 1; - char *av[3]; - int ac = 3; - int v; - char *a = NULL; - - av[0] = "program"; - av[1] = "-Z"; - av[2] = "456"; - So(nng_opts_parse(ac, av, case1, &v, &a, &opti) == NNG_EINVAL); - So(opti == 1); - }); - - Convey("Negative bad long works", { - int opti = 1; - char *av[3]; - int ac = 3; - int v; - char *a = NULL; - - av[0] = "program"; - av[1] = "--something"; - av[2] = "456"; - So(nng_opts_parse(ac, av, case1, &v, &a, &opti) == NNG_EINVAL); - So(opti == 1); - }); - - Convey("Separator flag works", { - int opti = 1; - char *av[5]; - int ac = 5; - int v; - char *a = NULL; - - av[0] = "program"; - av[1] = "-f"; - av[2] = "-"; - av[3] = "-v"; - av[4] = "456"; - So(nng_opts_parse(ac, av, case1, &v, &a, &opti) == 0); - So(v == 1); - So(opti == 2); - So(nng_opts_parse(ac, av, case1, &v, &a, &opti) == -1); - So(opti == 3); - }); - - Convey("No options works", { - int opti = 1; - char *av[1]; - int ac = 1; - int v; - char *a = NULL; - - av[0] = "program"; - So(nng_opts_parse(ac, av, case1, &v, &a, &opti) == -1); - }); - - Convey("No options (but arguments) works", { - int opti = 1; - char *av[2]; - int ac = 2; - int v; - char *a = NULL; - - av[0] = "program"; - av[1] = "123"; - So(nng_opts_parse(ac, av, case1, &v, &a, &opti) == -1); - So(opti == 1); - }); - Convey("Mixed long and short works", { - int opti = 1; - char *av[7]; - int ac = 7; - int v; - char *a = NULL; - - av[0] = "program"; - av[1] = "--value=123"; - av[2] = "-f"; - av[3] = "--longflag"; - av[4] = "-b"; - av[5] = "-vxyz"; - av[6] = "456"; - So(nng_opts_parse(ac, av, case1, &v, &a, &opti) == 0); - So(opti == 2); - So(v == 3); - So(strcmp(a, "123") == 0); - So(nng_opts_parse(ac, av, case1, &v, &a, &opti) == 0); - So(opti == 3); - So(v == 1); - So(nng_opts_parse(ac, av, case1, &v, &a, &opti) == 0); - So(opti == 4); - So(v == 2); - So(nng_opts_parse(ac, av, case1, &v, &a, &opti) == 0); - So(opti == 5); - So(v == 4); - So(nng_opts_parse(ac, av, case1, &v, &a, &opti) == 0); - So(opti == 6); - So(v == 3); - So(strcmp(a, "xyz") == 0); - So(strcmp(av[opti], "456") == 0); - So(nng_opts_parse(ac, av, case1, &v, &a, &opti) == -1); - So(opti == 6); - }); -}) diff --git a/tests/reqctx.c b/tests/reqctx.c deleted file mode 100644 index 47222c00d..000000000 --- a/tests/reqctx.c +++ /dev/null @@ -1,265 +0,0 @@ -// -// Copyright 2024 Staysail Systems, Inc. -// Copyright 2018 Capitar IT Group BV -// -// 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 - -#include -#include -#include - -#include "convey.h" -#include "stubs.h" - -static struct { - nng_aio *aio; - enum { START, SEND, RECV } state; - nng_socket s; - nng_msg *msg; - int cnt; - nng_mtx *mtx; -} rep_state; - -void -rep_cb(void *unused) -{ - int rv; - (void) unused; - - nng_mtx_lock(rep_state.mtx); - if (rep_state.state == START) { - rep_state.state = RECV; - nng_recv_aio(rep_state.s, rep_state.aio); - nng_mtx_unlock(rep_state.mtx); - return; - } - if ((rv = nng_aio_result(rep_state.aio)) != 0) { - if (rep_state.msg != NULL) { - nng_msg_free(rep_state.msg); - rep_state.msg = NULL; - } - nng_mtx_unlock(rep_state.mtx); - return; - } - switch (rep_state.state) { - case START: - break; - case RECV: - rep_state.msg = nng_aio_get_msg(rep_state.aio); - rep_state.state = SEND; - nng_aio_set_msg(rep_state.aio, rep_state.msg); - nng_send_aio(rep_state.s, rep_state.aio); - break; - case SEND: - rep_state.msg = NULL; - rep_state.state = RECV; - nng_aio_set_msg(rep_state.aio, NULL); - nng_recv_aio(rep_state.s, rep_state.aio); - rep_state.cnt++; - break; - } - nng_mtx_unlock(rep_state.mtx); -} - -#define NCTX 1000 - -void -markr(void *arg) -{ - *(bool *) arg = true; -} - -static void -marks(void *arg) -{ - *(bool *) arg = true; -} - -nng_ctx ctxs[NCTX]; -uint32_t recv_order[NCTX]; -nng_aio *saios[NCTX]; -nng_aio *raios[NCTX]; -bool recd[NCTX]; -bool sent[NCTX]; - -TestMain("REQ concurrent contexts", { - int rv; - const char *addr = "inproc://test"; - int i; - - memset(recv_order, 0, NCTX * sizeof(int)); - - Convey("We can use REQ contexts concurrently", { - nng_socket req; - - So(nng_mtx_alloc(&rep_state.mtx) == 0); - So(nng_aio_alloc(&rep_state.aio, rep_cb, NULL) == 0); - So(nng_rep_open(&rep_state.s) == 0); - So(nng_req_open(&req) == 0); - - for (i = 0; i < NCTX; i++) { - sent[i] = recd[i] = false; - recv_order[i] = (uint32_t) i; - if (nng_aio_alloc(&raios[i], markr, &(recd[i])) != 0) { - break; - } - nng_aio_set_timeout(raios[i], 5000); - if (nng_aio_alloc(&saios[i], marks, &(sent[i])) != 0) { - break; - } - nng_aio_set_timeout(saios[i], 5000); - } - - So(nng_socket_set_int(rep_state.s, NNG_OPT_SENDBUF, NCTX) == - 0); - So(i == NCTX); - for (i = 0; i < NCTX; i++) { - uint32_t tmp; - int ni = rand() % NCTX; // recv index - - tmp = recv_order[i]; - recv_order[i] = recv_order[ni]; - recv_order[ni] = tmp; - } - Reset({ - for (i = 0; i < NCTX; i++) { - nng_aio_free(saios[i]); - nng_aio_free(raios[i]); - } - nng_close(req); - nng_close(rep_state.s); - nng_aio_free(rep_state.aio); - nng_mtx_free(rep_state.mtx); - }); - - So(nng_listen(rep_state.s, addr, NULL, 0) == 0); - So(nng_dial(req, addr, NULL, 0) == 0); - - nng_msleep(100); // let things establish. - - // Start the rep state machine going. - rep_cb(NULL); - - for (i = 0; i < NCTX; i++) { - if ((rv = nng_ctx_open(&ctxs[i], req)) != 0) { - break; - } - } - So(rv == 0); - So(i == NCTX); - - // Send messages - for (i = 0; i < NCTX; i++) { - nng_msg *m; - if ((rv = nng_msg_alloc(&m, sizeof(uint32_t))) != 0) { - Fail("msg alloc failed: %s", nng_strerror(rv)); - } - if ((rv = nng_msg_append_u32(m, i)) != 0) { - Fail("append failed: %s", nng_strerror(rv)); - } - nng_aio_set_msg(saios[i], m); - nng_ctx_send(ctxs[i], saios[i]); - } - So(rv == 0); - So(i == NCTX); - - for (i = 0; i < NCTX; i++) { - nng_aio_wait(saios[i]); - if ((rv = nng_aio_result(saios[i])) != 0) { - Fail("send failed: %s", nng_strerror(rv)); - So(false); - break; - } - } - for (i = 0; i < NCTX; i++) { - if (!sent[i]) { - Fail("Index %d (%d) not sent", i, i); - } - } - - So(rv == 0); - So(i == NCTX); - // Receive answers - for (i = 0; i < NCTX; i++) { - int ri = recv_order[i]; - nng_ctx_recv(ctxs[ri], raios[ri]); - } - - for (i = 0; i < NCTX; i++) { - nng_msg *msg; - uint32_t x; - - nng_aio_wait(raios[i]); - if ((rv = nng_aio_result(raios[i])) != 0) { - Fail("recv %d (%d) %d failed: %s", i, - recv_order[i], rep_state.cnt, - nng_strerror(rv)); - continue; - } - msg = nng_aio_get_msg(raios[i]); - if ((rv = nng_msg_chop_u32(msg, &x)) != 0) { - Fail("recv msg trim: %s", nng_strerror(rv)); - break; - } - if (x != (uint32_t) i) { - Fail("message body mismatch: %x %x\n", x, - (uint32_t) i); - break; - } - - nng_msg_free(msg); - } - for (i = 0; i < NCTX; i++) { - if (!recd[i]) { - Fail("Index %d (%d) not received", i, - recv_order[i]); - break; - } - } - - So(rv == 0); - So(i == NCTX); - }); - - Convey("Given a socket and a context", { - nng_socket req; - nng_ctx ctx; - nng_aio *aio; - - So(nng_req0_open(&req) == 0); - So(nng_ctx_open(&ctx, req) == 0); - So(nng_aio_alloc(&aio, NULL, NULL) == 0); - nng_aio_set_timeout(aio, 1000); - - Reset({ nng_aio_free(aio); }); - - Convey("Closing the socket aborts a context send", { - nng_msg *msg; - So(nng_msg_alloc(&msg, 0) == 0); - nng_aio_set_msg(aio, msg); - nng_ctx_send(ctx, aio); - nng_close(req); - nng_aio_wait(aio); - So(nng_aio_result(aio) == NNG_ECLOSED); - nng_msg_free(msg); - }); - - Convey("Closing the context aborts a context send", { - nng_msg *msg; - So(nng_msg_alloc(&msg, 0) == 0); - nng_aio_set_msg(aio, msg); - nng_ctx_send(ctx, aio); - nng_ctx_close(ctx); - nng_aio_wait(aio); - So(nng_aio_result(aio) == NNG_ECLOSED); - nng_msg_free(msg); - nng_close(req); - }); - }); -})