diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-11-30 22:46:27 -0500 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-11-30 22:46:27 -0500 |
| commit | 8f036f1e0b231f5ec7c146ba31a6f73d3595d47a (patch) | |
| tree | 50cbe164c8013a43db25aabef0b9dbac912a2cb6 | |
| parent | 0a2a8d4c14543b9b8b1228e6012b05190915bda4 (diff) | |
| download | nng-8f036f1e0b231f5ec7c146ba31a6f73d3595d47a.tar.gz nng-8f036f1e0b231f5ec7c146ba31a6f73d3595d47a.tar.bz2 nng-8f036f1e0b231f5ec7c146ba31a6f73d3595d47a.zip | |
tests: convert nonblock test to NUTS
| -rw-r--r-- | src/sp/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/sp/nonblock_test.c (renamed from tests/nonblock.c) | 56 | ||||
| -rw-r--r-- | tests/CMakeLists.txt | 1 |
3 files changed, 34 insertions, 24 deletions
diff --git a/src/sp/CMakeLists.txt b/src/sp/CMakeLists.txt index 7ccaf051..42ce2020 100644 --- a/src/sp/CMakeLists.txt +++ b/src/sp/CMakeLists.txt @@ -21,3 +21,4 @@ nng_sources( nng_test(pipe_test) nng_test(device_test) nng_test(multistress_test) +nng_test(nonblock_test) diff --git a/tests/nonblock.c b/src/sp/nonblock_test.c index 624c9233..0f9be034 100644 --- a/tests/nonblock.c +++ b/src/sp/nonblock_test.c @@ -14,14 +14,19 @@ #ifndef _WIN32 #include <sys/select.h> #include <sys/time.h> +#define PLATFD int +#else +#include <winsock2.h> +// order counts +#include <mswsock.h> +#define PLATFD SOCKET #endif #include <nng/nng.h> #include <nng/protocol/reqrep0/rep.h> #include <nng/protocol/reqrep0/req.h> -#include "convey.h" -#include "stubs.h" +#include <nuts.h> const char *addr = "inproc://bug346"; @@ -92,27 +97,32 @@ reqthr(void *arg) nng_socket reqs[NCLIENTS]; nng_socket rep; -TestMain("Nonblocking Works", { - Convey("Running for 15 sec", { - nng_thread *server; - nng_thread *clients[NCLIENTS]; +static void +test_nonblocking(void) +{ + nng_thread *server; + nng_thread *clients[NCLIENTS]; - So(nng_rep0_open(&rep) == 0); - for (int i = 0; i < NCLIENTS; i++) { - So(nng_req0_open(&reqs[i]) == 0); - } + NUTS_PASS(nng_rep0_open(&rep)); + for (int i = 0; i < NCLIENTS; i++) { + NUTS_PASS(nng_req0_open(&reqs[i])); + } - nng_thread_create(&server, repthr, &rep); - for (int i = 0; i < NCLIENTS; i++) { - nng_thread_create(&clients[i], reqthr, &reqs[i]); - } + NUTS_PASS(nng_thread_create(&server, repthr, &rep)); + for (int i = 0; i < NCLIENTS; i++) { + NUTS_PASS(nng_thread_create(&clients[i], reqthr, &reqs[i])); + } - nng_msleep(15000); - nng_close(rep); - nng_thread_destroy(server); - for (int i = 0; i < NCLIENTS; i++) { - nng_close(reqs[i]); - nng_thread_destroy(clients[i]); - } - }); -}) + nng_msleep(15000); + nng_close(rep); + nng_thread_destroy(server); + for (int i = 0; i < NCLIENTS; i++) { + nng_close(reqs[i]); + nng_thread_destroy(clients[i]); + } +} + +NUTS_TESTS = { + { "nonblocking", test_nonblocking }, + { NULL, NULL }, +}; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1e8ea918..51938146 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -128,7 +128,6 @@ add_nng_test(files 5) add_nng_test1(httpclient 60 NNG_SUPP_HTTP) add_nng_test1(httpserver 30 NNG_SUPP_HTTP) add_nng_test(ipcsupp 10) -add_nng_test(nonblock 60) add_nng_test(scalability 20 ON) add_nng_test(tcpsupp 10) add_nng_test(wss 30) |
