diff options
| -rw-r--r-- | src/core/init.c | 9 | ||||
| -rw-r--r-- | tests/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | tests/bus.c | 4 | ||||
| -rw-r--r-- | tests/compat_testutil.c (renamed from tests/nuts_compat.c) | 0 | ||||
| -rw-r--r-- | tests/device.c | 4 | ||||
| -rw-r--r-- | tests/httpclient.c | 4 | ||||
| -rw-r--r-- | tests/httpserver.c | 9 | ||||
| -rw-r--r-- | tests/inproc.c | 3 | ||||
| -rw-r--r-- | tests/ipc.c | 3 | ||||
| -rw-r--r-- | tests/ipcsupp.c | 3 | ||||
| -rw-r--r-- | tests/ipcwinsec.c | 5 | ||||
| -rw-r--r-- | tests/multistress.c | 4 | ||||
| -rw-r--r-- | tests/nonblock.c | 4 | ||||
| -rw-r--r-- | tests/pipe.c | 3 | ||||
| -rw-r--r-- | tests/reqctx.c | 8 | ||||
| -rw-r--r-- | tests/reqstress.c | 4 | ||||
| -rw-r--r-- | tests/scalability.c | 15 | ||||
| -rw-r--r-- | tests/stats.c | 3 | ||||
| -rw-r--r-- | tests/tcp.c | 4 | ||||
| -rw-r--r-- | tests/tcp6.c | 4 | ||||
| -rw-r--r-- | tests/tcpsupp.c | 3 | ||||
| -rw-r--r-- | tests/tls.c | 3 | ||||
| -rw-r--r-- | tests/udp.c | 3 | ||||
| -rw-r--r-- | tests/ws.c | 4 | ||||
| -rw-r--r-- | tests/wss.c | 4 | ||||
| -rw-r--r-- | tests/zt.c | 3 |
26 files changed, 37 insertions, 78 deletions
diff --git a/src/core/init.c b/src/core/init.c index 7be879f5..5454385d 100644 --- a/src/core/init.c +++ b/src/core/init.c @@ -1,5 +1,5 @@ // -// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 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 @@ -29,6 +29,13 @@ nni_init_helper(void) nni_mtx_init(&nni_init_mtx); NNI_LIST_INIT(&nni_init_list, nni_initializer, i_node); nni_inited = true; +#ifdef NNG_TEST_LIB + static bool cleanup = false; + if (!cleanup) { + atexit(nng_fini); + cleanup = true; + } +#endif if (((rv = nni_stat_sys_init()) != 0) || ((rv = nni_taskq_sys_init()) != 0) || diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9ff9adfa..5fcd4323 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -64,7 +64,7 @@ if (NNG_TESTS) # are present. It's not worth trying to figure out which of these # should work and which shouldn't. macro(add_nng_compat_test NAME TIMEOUT) - add_executable(${NAME} ${NAME}.c nuts_compat.c) + add_executable(${NAME} ${NAME}.c compat_testutil.c) target_link_libraries(${NAME} nng_testing) target_include_directories(${NAME} PRIVATE ${PROJECT_SOURCE_DIR}/src/compat diff --git a/tests/bus.c b/tests/bus.c index 96e7ede3..ccd48167 100644 --- a/tests/bus.c +++ b/tests/bus.c @@ -1,5 +1,5 @@ // -// Copyright 2018 Garrett D'Amore <garrett@damore.org> +// Copyright 2021 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 @@ -24,8 +24,6 @@ TestMain("BUS pattern", { const char *addr = "inproc://test"; - Reset({ nng_fini(); }); - Convey("We can create a BUS socket", { nng_socket bus; diff --git a/tests/nuts_compat.c b/tests/compat_testutil.c index 7db03bf0..7db03bf0 100644 --- a/tests/nuts_compat.c +++ b/tests/compat_testutil.c diff --git a/tests/device.c b/tests/device.c index 0ff784cc..7d10cbf1 100644 --- a/tests/device.c +++ b/tests/device.c @@ -1,5 +1,5 @@ // -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 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 @@ -106,6 +106,4 @@ Main({ }); }); }); - - nng_fini(); }) diff --git a/tests/httpclient.c b/tests/httpclient.c index 29239ddb..e153a987 100644 --- a/tests/httpclient.c +++ b/tests/httpclient.c @@ -1,5 +1,5 @@ // -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 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 @@ -35,8 +35,6 @@ const uint8_t chunked_sum[20] = { 0x9b, 0x06, 0xfb, 0xee, 0x51, 0xc6, 0x42, 0x68 }; TestMain("HTTP Client", { - atexit(nng_fini); - Convey("Given a TCP connection to example.com", { nng_aio * aio; nng_http_client *cli; diff --git a/tests/httpserver.c b/tests/httpserver.c index a509638e..445aad0e 100644 --- a/tests/httpserver.c +++ b/tests/httpserver.c @@ -1,5 +1,5 @@ // -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // Copyright 2020 Dirac Research <robert.bielik@dirac.com> // @@ -30,12 +30,6 @@ const char *doc2 = "This is a text file."; const char *doc3 = "<html><body>This is doc number 3.</body></html>"; const char *doc4 = "<html><body>Whoops, Errored!</body></html>"; -void -cleanup(void) -{ - nng_fini(); -} - static int httpdo(nng_url *url, nng_http_req *req, nng_http_res *res, void **datap, size_t *sizep) @@ -190,7 +184,6 @@ TestMain("HTTP Server", { nng_http_handler *h; nni_init(); - atexit(cleanup); Convey("We can start an HTTP server", { nng_aio *aio; diff --git a/tests/inproc.c b/tests/inproc.c index 3a3a2b60..11a6f118 100644 --- a/tests/inproc.c +++ b/tests/inproc.c @@ -1,5 +1,5 @@ // -// Copyright 2017 Garrett D'Amore <garrett@damore.org> +// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2017 Capitar IT Group BV <info@capitar.com> // // This software is supplied under the terms of the MIT License, a @@ -17,5 +17,4 @@ TestMain("Inproc Transport", { trantest_test_all("inproc://TEST_%u"); - nng_fini(); }) diff --git a/tests/ipc.c b/tests/ipc.c index 590b10df..d910e0af 100644 --- a/tests/ipc.c +++ b/tests/ipc.c @@ -1,5 +1,5 @@ // -// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // Copyright 2018 Devolutions <info@devolutions.net> // @@ -85,5 +85,4 @@ check_props(nng_msg *msg) TestMain("IPC Transport", { trantest_test_extended("ipc:///tmp/nng_ipc_test_%u", check_props); - nng_fini(); }) diff --git a/tests/ipcsupp.c b/tests/ipcsupp.c index d5128098..bd751885 100644 --- a/tests/ipcsupp.c +++ b/tests/ipcsupp.c @@ -1,5 +1,5 @@ // -// Copyright 2019 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // Copyright 2018 Devolutions <info@devolutions.net> // @@ -19,7 +19,6 @@ static int num = 0; TestMain("Supplemental IPC", { - atexit(nng_fini); Convey("We can create a dialer and listener", { nng_stream_dialer * d; nng_stream_listener *l; diff --git a/tests/ipcwinsec.c b/tests/ipcwinsec.c index d6b28c1b..533dfe37 100644 --- a/tests/ipcwinsec.c +++ b/tests/ipcwinsec.c @@ -1,5 +1,5 @@ // -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 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 @@ -23,7 +23,6 @@ #ifndef _WIN32 TestMain("IPC Security Descriptor", { - atexit(nng_fini); Convey("Given a socket and an IPC listener", { nng_socket s; nng_listener l; @@ -80,8 +79,6 @@ sdescAuthUsers(PSID sid, PACL *aclp) } TestMain("IPC Security Descriptor", { - atexit(nng_fini); - Convey("Given a socket and an IPC listener", { nng_socket s; nng_listener l; diff --git a/tests/multistress.c b/tests/multistress.c index 9264e6bc..fee40503 100644 --- a/tests/multistress.c +++ b/tests/multistress.c @@ -1,5 +1,5 @@ // -// Copyright 2019 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 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 @@ -770,8 +770,6 @@ Main({ char *str; int tmo; - atexit(nng_fini); - // Each run should truly be random. srand((int) time(NULL)); diff --git a/tests/nonblock.c b/tests/nonblock.c index c8cce901..3ad22889 100644 --- a/tests/nonblock.c +++ b/tests/nonblock.c @@ -1,5 +1,5 @@ // -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 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 @@ -94,8 +94,6 @@ nng_socket reqs[NCLIENTS]; nng_socket rep; TestMain("Nonblocking Works", { - atexit(nng_fini); - Convey("Running for 15 sec", { nng_thread *server; nng_thread *clients[NCLIENTS]; diff --git a/tests/pipe.c b/tests/pipe.c index 71e9be67..617337b0 100644 --- a/tests/pipe.c +++ b/tests/pipe.c @@ -1,5 +1,5 @@ // -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 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 @@ -114,7 +114,6 @@ char addr[64]; static int cnt; TestMain("Pipe notify works", { - atexit(nng_fini); Convey("We can create a pipeline", { struct testcase push; diff --git a/tests/reqctx.c b/tests/reqctx.c index e937b995..c727b91c 100644 --- a/tests/reqctx.c +++ b/tests/reqctx.c @@ -1,5 +1,5 @@ // -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 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 @@ -28,10 +28,10 @@ static struct { } rep_state; void -rep_cb(void *notused) +rep_cb(void *unused) { int rv; - (void) notused; + (void) unused; nng_mtx_lock(rep_state.mtx); if (rep_state.state == START) { @@ -96,8 +96,6 @@ TestMain("REQ concurrent contexts", { memset(recv_order, 0, NCTX * sizeof(int)); - atexit(nng_fini); - Convey("We can use REQ contexts concurrently", { nng_socket req; diff --git a/tests/reqstress.c b/tests/reqstress.c index 481e4e92..18eac37a 100644 --- a/tests/reqstress.c +++ b/tests/reqstress.c @@ -1,5 +1,5 @@ // -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 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 @@ -270,8 +270,6 @@ Main({ int tmo; char *str; - atexit(nng_fini); - if (((str = ConveyGetEnv("STRESSTIME")) == NULL) || ((tmo = atoi(str)) < 1)) { tmo = 30; diff --git a/tests/scalability.c b/tests/scalability.c index 1cbbd961..0cff2243 100644 --- a/tests/scalability.c +++ b/tests/scalability.c @@ -1,5 +1,5 @@ // -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 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 @@ -43,14 +43,6 @@ serve(void *arg) nng_close(rep); } -void -stop(void) -{ - nng_closeall(); - nng_thread_destroy(server); - nng_fini(); -} - int openclients(nng_socket *clients, int num) { @@ -97,8 +89,6 @@ Main({ nng_socket *clients; int * results; - atexit(stop); - clients = calloc(nclients, sizeof(nng_socket)); results = calloc(nclients, sizeof(int)); @@ -122,6 +112,9 @@ Main({ }); }); + nng_close(rep); + nng_thread_destroy(server); + free(clients); free(results); }) diff --git a/tests/stats.c b/tests/stats.c index 68a5ab62..fb731275 100644 --- a/tests/stats.c +++ b/tests/stats.c @@ -1,5 +1,5 @@ // -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 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 @@ -22,7 +22,6 @@ #define SECONDS(x) ((x) *1000) TestMain("Stats Test", { - atexit(nng_fini); Convey("We are able to open a PAIR socket", { nng_socket s1; diff --git a/tests/tcp.c b/tests/tcp.c index eecc148a..afc92f19 100644 --- a/tests/tcp.c +++ b/tests/tcp.c @@ -1,5 +1,5 @@ // -// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // Copyright 2018 Devolutions <info@devolutions.net> // @@ -62,6 +62,4 @@ check_props_v4(nng_msg *msg) TestMain("TCP Transport", { trantest_test_extended("tcp://127.0.0.1:%u", check_props_v4); - - nng_fini(); }) diff --git a/tests/tcp6.c b/tests/tcp6.c index 9b3b0d4b..ecc55a46 100644 --- a/tests/tcp6.c +++ b/tests/tcp6.c @@ -1,5 +1,5 @@ // -// Copyright 2018 Staysail Systems, Inc. <info@staystail.tech> +// Copyright 2021 Staysail Systems, Inc. <info@staystail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // // This software is supplied under the terms of the MIT License, a @@ -92,6 +92,4 @@ TestMain("TCP (IPv6) Transport", { So(nng_dial(s1, "tcp://::1:5055", NULL, 0) == NNG_EADDRINVAL); So(nng_dial(s1, "tcp://[::1]", NULL, 0) == NNG_EADDRINVAL); }); - - nng_fini(); }) diff --git a/tests/tcpsupp.c b/tests/tcpsupp.c index 39558f58..9117c15b 100644 --- a/tests/tcpsupp.c +++ b/tests/tcpsupp.c @@ -1,5 +1,5 @@ // -// Copyright 2019 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 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 @@ -16,7 +16,6 @@ #include "stubs.h" TestMain("Supplemental TCP", { - atexit(nng_fini); Convey("We can create a dialer and listener", { nng_stream_dialer * d = NULL; nng_stream_listener *l = NULL; diff --git a/tests/tls.c b/tests/tls.c index 59525089..c6d5da6e 100644 --- a/tests/tls.c +++ b/tests/tls.c @@ -1,6 +1,6 @@ // // Copyright 2018 Capitar IT Group BV <info@capitar.com> -// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech> // // This software is supplied under the terms of the MIT License, a // copy of which should be located in the distribution where this @@ -266,7 +266,6 @@ TestMain("TLS Transport", { tt.listener_init = init_listener_tls; tt.tmpl = "tls+tcp://127.0.0.1:%u"; tt.proptest = check_props_v4; - atexit(nng_fini); trantest_test(&tt); diff --git a/tests/udp.c b/tests/udp.c index af7b2807..c2772048 100644 --- a/tests/udp.c +++ b/tests/udp.c @@ -1,5 +1,5 @@ // -// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 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 @@ -20,7 +20,6 @@ TestMain("UDP support", { nni_init(); - atexit(nng_fini); trantest_port = trantest_port ? trantest_port : 5555; @@ -1,5 +1,5 @@ // -// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 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 @@ -83,6 +83,4 @@ check_props_v4(nng_msg *msg) TestMain("WebSocket Transport", { trantest_test_extended("ws://127.0.0.1:%u/test", check_props_v4); - - nng_fini(); }) diff --git a/tests/wss.c b/tests/wss.c index ca33a542..0f570b81 100644 --- a/tests/wss.c +++ b/tests/wss.c @@ -1,5 +1,5 @@ // -// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 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 @@ -245,6 +245,4 @@ TestMain("WebSocket Secure (TLS) Transport", { tt.proptest = check_props; trantest_test(&tt); - - nng_fini(); }) @@ -1,5 +1,5 @@ // -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 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 @@ -130,7 +130,6 @@ TestMain("ZeroTier Transport", { unsigned port; port = 5555; - atexit(nng_fini); Convey("We can register the zero tier transport", { So(nng_zt_register() == 0); }); |
