From 58337cfc78c86fe36a7f6f17c29ad9d24504a52a Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Wed, 7 Jul 2021 22:37:58 -0700 Subject: Test fixes. --- src/core/aio_test.c | 21 +++++++++++++++------ src/core/message_test.c | 2 -- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/core/aio_test.c b/src/core/aio_test.c index 75305dc8..a94978bc 100644 --- a/src/core/aio_test.c +++ b/src/core/aio_test.c @@ -277,6 +277,17 @@ aio_sleep_loop(void *arg) nng_sleep_aio(sl->interval, sl->aio); } +static bool +is_github_macos(void) +{ + char *env; + if (((env = getenv("RUNNER_OS")) != NULL) && + (strcmp(env, "macOS") == 0)) { + return (true); + } + return (true); +} + void test_sleep_loop(void) { @@ -302,13 +313,12 @@ test_sleep_loop(void) nng_mtx_unlock(sl.mx); dur = (nng_duration) (nng_clock() - start); NUTS_ASSERT(dur >= 150); - if ((getenv("GITHUB_ACTIONS") == "") || - (getenv("RUNNER_OS") != "macOS")) { + if (!is_github_macos()) { NUTS_ASSERT(dur <= 500); // allow for sloppy clocks + NUTS_ASSERT(sl.count == 3); } NUTS_ASSERT(sl.done); NUTS_PASS(sl.result); - NUTS_ASSERT(sl.count == 3); nng_aio_free(sl.aio); nng_cv_free(sl.cv); @@ -342,13 +352,12 @@ test_sleep_cancel(void) nng_mtx_unlock(sl.mx); dur = (nng_duration) (nng_clock() - start); NUTS_ASSERT(dur >= 100); - if ((getenv("GITHUB_ACTIONS") == "") || - (getenv("RUNNER_OS") != "macOS")) { + if (!is_github_macos()) { NUTS_ASSERT(dur <= 500); // allow for sloppy clocks + NUTS_ASSERT(sl.count == 1); } NUTS_ASSERT(sl.done); NUTS_FAIL(sl.result, NNG_ECANCELED); - NUTS_ASSERT(sl.count == 1); nng_aio_free(sl.aio); nng_cv_free(sl.cv); diff --git a/src/core/message_test.c b/src/core/message_test.c index cbd217af..0f920499 100644 --- a/src/core/message_test.c +++ b/src/core/message_test.c @@ -14,8 +14,6 @@ #include "nuts.h" -static uint8_t dat123[] = { 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3 }; - void test_msg_option(void) { -- cgit v1.2.3-70-g09d2