diff options
| -rw-r--r-- | src/sp/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | src/sp/multistress_test.c (renamed from tests/multistress.c) | 64 | ||||
| -rw-r--r-- | tests/CMakeLists.txt | 1 |
3 files changed, 35 insertions, 33 deletions
diff --git a/src/sp/CMakeLists.txt b/src/sp/CMakeLists.txt index 16123d82..128aac15 100644 --- a/src/sp/CMakeLists.txt +++ b/src/sp/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2021 Staysail Systems, Inc. <info@staystail.tech> +# Copyright 2024 Staysail Systems, Inc. <info@staystail.tech> # # This software is supplied under the terms of the MIT License, a # copy of which should be located in the distribution where this @@ -19,3 +19,4 @@ nng_sources( ) nng_test(pipe_test) +nng_test(multistress_test) diff --git a/tests/multistress.c b/src/sp/multistress_test.c index b9e48014..1e336205 100644 --- a/tests/multistress.c +++ b/src/sp/multistress_test.c @@ -25,8 +25,7 @@ #include <nng/protocol/survey0/respond.h> #include <nng/protocol/survey0/survey.h> -#include "convey.h" -#include "stubs.h" +#include <nuts.h> #ifdef NDEBUG #define dprintf(...) @@ -761,7 +760,9 @@ pipeline0_test(int ntests) nng_sleep_aio(1, srv->woke); } -Main({ +void +test_multi_stress(void) +{ int i; char *str; int tmo; @@ -769,13 +770,13 @@ Main({ // Each run should truly be random. srand((int) time(NULL)); - 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 have limited resources. - if (((str = ConveyGetEnv("STRESSPRESSURE")) == NULL) || + if (((str = getenv("STRESSPRESSURE")) == NULL) || ((ncases = atoi(str)) < 1)) { ncases = 32; } @@ -822,31 +823,32 @@ Main({ nng_aio_stop(cases[i].woke); } - Test("MultiProtocol/Transport Stress", { - Convey("All tests worked", { - for (i = 0; i < ncases; i++) { - test_case *c = &cases[i]; - if (c->name == NULL) { - break; - } - nng_aio_stop(c->sent); - nng_aio_stop(c->recd); - nng_aio_stop(c->woke); - nng_aio_free(c->sent); - nng_aio_free(c->recd); - nng_aio_free(c->woke); - - dprintf("RESULT socket %u (%s) sent %d " - "recd %d fail %d\n", - c->sock.id, c->name, c->nsend, c->nrecv, - c->nfail); - So(c->nfail == 0); - So((c->sent == NULL) || (c->nsend > 0)); - So((c->recd == NULL) || (c->nrecv > 0)); - } - }); - }); + for (i = 0; i < ncases; i++) { + test_case *c = &cases[i]; + if (c->name == NULL) { + break; + } + nng_aio_stop(c->sent); + nng_aio_stop(c->recd); + nng_aio_stop(c->woke); + nng_aio_free(c->sent); + nng_aio_free(c->recd); + nng_aio_free(c->woke); + + dprintf("RESULT socket %u (%s) sent %d " + "recd %d fail %d\n", + c->sock.id, c->name, c->nsend, c->nrecv, c->nfail); + NUTS_TRUE(c->nfail == 0); + NUTS_TRUE((c->sent == NULL) || (c->nsend > 0)); + NUTS_TRUE((c->recd == NULL) || (c->nrecv > 0)); + + NUTS_CLOSE(c->sock); + } free(cases); - nng_fini(); -}) +} + +NUTS_TESTS = { + { "multi stress", test_multi_stress }, + { NULL, NULL }, +}; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a3569e6c..86a76069 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -130,7 +130,6 @@ add_nng_test1(httpclient 60 NNG_SUPP_HTTP) add_nng_test1(httpserver 30 NNG_SUPP_HTTP) add_nng_test(inproc 5) add_nng_test(ipcsupp 10) -add_nng_test(multistress 60) add_nng_test(nonblock 60) add_nng_test(scalability 20 ON) add_nng_test(synch 5) |
