diff options
| -rw-r--r-- | src/sp/protocol/reqrep0/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/sp/protocol/reqrep0/reqstress_test.c (renamed from tests/reqstress.c) | 58 | ||||
| -rw-r--r-- | tests/CMakeLists.txt | 2 |
3 files changed, 30 insertions, 31 deletions
diff --git a/src/sp/protocol/reqrep0/CMakeLists.txt b/src/sp/protocol/reqrep0/CMakeLists.txt index a3cecfd0..b5d44759 100644 --- a/src/sp/protocol/reqrep0/CMakeLists.txt +++ b/src/sp/protocol/reqrep0/CMakeLists.txt @@ -23,3 +23,4 @@ nng_test(req_test) nng_test(rep_test) nng_test(xrep_test) nng_test(xreq_test) +nng_test(reqstress_test) diff --git a/tests/reqstress.c b/src/sp/protocol/reqrep0/reqstress_test.c index de31e987..cd0004a0 100644 --- a/tests/reqstress.c +++ b/src/sp/protocol/reqrep0/reqstress_test.c @@ -17,8 +17,7 @@ #include <nng/protocol/reqrep0/rep.h> #include <nng/protocol/reqrep0/req.h> -#include "convey.h" -#include "stubs.h" +#include <nuts.h> #ifdef NDEBUG #define dprintf(...) @@ -261,19 +260,21 @@ reqrep_test(int ntests) } } -Main({ +static void +test_req_stress(void) +{ int i; int tmo; char *str; - if (((str = ConveyGetEnv("STRESSTIME")) == NULL) || + if (((str = getenv("STRESSTIME")) == NULL) || ((tmo = atoi(str)) < 1)) { tmo = 30; } // We have to keep this relatively low by default because some // platforms don't support large numbers of sockets. (On macOS // laptop I can run this with 500 though.) - if (((str = ConveyGetEnv("STRESSPRESSURE")) == NULL) || + if (((str = getenv("STRESSPRESSURE")) == NULL) || ((ncases = atoi(str)) < 1)) { ncases = 32; } @@ -307,30 +308,29 @@ Main({ } nng_msleep(100); - Test("Req/Rep Stress", { - Convey("All tests worked", { - for (i = 0; i < ncases; i++) { - nng_aio_stop(cases[i].recv_aio); - nng_aio_stop(cases[i].send_aio); - nng_aio_stop(cases[i].time_aio); - nng_aio_free(cases[i].recv_aio); - nng_aio_free(cases[i].send_aio); - nng_aio_free(cases[i].time_aio); - if (cases[i].name != NULL) { - dprintf( - "RESULT socket %u (%s) sent %d " - "recd %d fail %d\n", - cases[i].socket.id, cases[i].name, - cases[i].nsend, cases[i].nrecv, - cases[i].nfail); - So(cases[i].nfail == 0); - So(cases[i].nsend > 0 || - cases[i].nrecv > 0); - } - } - }); - }); + for (i = 0; i < ncases; i++) { + nng_aio_stop(cases[i].recv_aio); + nng_aio_stop(cases[i].send_aio); + nng_aio_stop(cases[i].time_aio); + nng_aio_free(cases[i].recv_aio); + nng_aio_free(cases[i].send_aio); + nng_aio_free(cases[i].time_aio); + if (cases[i].name != NULL) { + dprintf("RESULT socket %u (%s) sent %d " + "recd %d fail %d\n", + cases[i].socket.id, cases[i].name, cases[i].nsend, + cases[i].nrecv, cases[i].nfail); + NUTS_TRUE(cases[i].nfail == 0); + NUTS_TRUE(cases[i].nsend > 0 || cases[i].nrecv > 0); + NUTS_CLOSE(cases[i].socket); + } + } free(cases); nng_fini(); -}) +} + +NUTS_TESTS = { + { "req stress", test_req_stress }, + { NULL, NULL }, +}; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 86a76069..f41379e0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -140,7 +140,5 @@ add_nng_test(ws 30) add_nng_test(wss 30) add_nng_test1(zt 60 NNG_TRANSPORT_ZEROTIER) -add_nng_test(reqstress 60) - # c++ tests add_nng_cpp_test(cplusplus_pair 5) |
