diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-11-30 22:54:06 -0500 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-11-30 22:54:06 -0500 |
| commit | b52f072bbd0184dae11229f8f50de4151d7423b5 (patch) | |
| tree | 5ec53fcaafda4fca196ebc997fcff594801f02f5 | |
| parent | 8f036f1e0b231f5ec7c146ba31a6f73d3595d47a (diff) | |
| download | nng-b52f072bbd0184dae11229f8f50de4151d7423b5.tar.gz nng-b52f072bbd0184dae11229f8f50de4151d7423b5.tar.bz2 nng-b52f072bbd0184dae11229f8f50de4151d7423b5.zip | |
tests: convert scalability test to NUTS
| -rw-r--r-- | src/sp/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/sp/scalability_test.c (renamed from tests/scalability.c) | 57 | ||||
| -rw-r--r-- | tests/CMakeLists.txt | 1 |
3 files changed, 27 insertions, 32 deletions
diff --git a/src/sp/CMakeLists.txt b/src/sp/CMakeLists.txt index 42ce2020..ef79e674 100644 --- a/src/sp/CMakeLists.txt +++ b/src/sp/CMakeLists.txt @@ -22,3 +22,4 @@ nng_test(pipe_test) nng_test(device_test) nng_test(multistress_test) nng_test(nonblock_test) +nng_test(scalability_test) diff --git a/tests/scalability.c b/src/sp/scalability_test.c index 0b4b1799..6e9047a1 100644 --- a/tests/scalability.c +++ b/src/sp/scalability_test.c @@ -14,8 +14,7 @@ #include <nng/protocol/reqrep0/rep.h> #include <nng/protocol/reqrep0/req.h> -#include "convey.h" -#include "stubs.h" +#include <nuts.h> static int nclients = 200; @@ -45,18 +44,15 @@ serve(void *arg) int openclients(nng_socket *clients, int num) { - int rv; int i; nng_duration t; for (i = 0; i < num; i++) { t = 100; // 100ms nng_socket c; - if (((rv = nng_req_open(&c)) != 0) || - ((rv = nng_socket_set_ms(c, NNG_OPT_RECVTIMEO, t)) != 0) || - ((rv = nng_socket_set_ms(c, NNG_OPT_SENDTIMEO, t)) != 0) || - ((rv = nng_dial(c, addr, NULL, 0)) != 0)) { - return (rv); - } + NUTS_PASS(nng_req_open(&c)); + NUTS_PASS(nng_socket_set_ms(c, NNG_OPT_RECVTIMEO, t)); + NUTS_PASS(nng_socket_set_ms(c, NNG_OPT_SENDTIMEO, t)); + NUTS_PASS(nng_dial(c, addr, NULL, 0)); clients[i] = c; } return (0); @@ -84,36 +80,35 @@ transact(nng_socket *clients, int num) return (rv); } -Main({ +void +test_scalability(void) +{ nng_socket *clients; int *results; clients = calloc(nclients, sizeof(nng_socket)); results = calloc(nclients, sizeof(int)); - if ((nng_rep_open(&rep) != 0) || - (nng_socket_set_int(rep, NNG_OPT_RECVBUF, 256) != 0) || - (nng_socket_set_int(rep, NNG_OPT_SENDBUF, 256) != 0) || - (nng_listen(rep, addr, NULL, 0) != 0) || - (nng_thread_create(&server, serve, NULL) != 0)) { - fprintf(stderr, "Unable to set up server!\n"); - exit(1); + NUTS_PASS(nng_rep_open(&rep)); + NUTS_PASS(nng_socket_set_int(rep, NNG_OPT_RECVBUF, 256)); + NUTS_PASS(nng_socket_set_int(rep, NNG_OPT_SENDBUF, 256)); + NUTS_PASS(nng_listen(rep, addr, NULL, 0)); + NUTS_PASS(nng_thread_create(&server, serve, NULL)); + + int i; + NUTS_TRUE(openclients(clients, nclients) == 0); + NUTS_TRUE(transact(clients, nclients) == 0); + for (i = 0; i < nclients; i++) { + NUTS_CLOSE(clients[i]); } - - Test("Scalability", { - Convey("We can handle many many clients", { - int i; - So(openclients(clients, nclients) == 0); - So(transact(clients, nclients) == 0); - for (i = 0; i < nclients; i++) { - So(nng_close(clients[i]) == 0); - } - }); - }); - - nng_close(rep); + NUTS_CLOSE(rep); nng_thread_destroy(server); free(clients); free(results); -}) +} + +NUTS_TESTS = { + { "scalability", test_scalability }, + { NULL, NULL }, +}; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 51938146..966a93cc 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(scalability 20 ON) add_nng_test(tcpsupp 10) add_nng_test(wss 30) add_nng_test1(zt 60 NNG_TRANSPORT_ZEROTIER) |
