From f9591be4916fb2467ce5a45ad74a12242946083c Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 13 Oct 2024 13:02:56 -0700 Subject: [PATCH] UDP: More test tuning for lossy environments. --- src/sp/transport/udp/udp_tran_test.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/sp/transport/udp/udp_tran_test.c b/src/sp/transport/udp/udp_tran_test.c index d68f60f9f..fe567e7bf 100644 --- a/src/sp/transport/udp/udp_tran_test.c +++ b/src/sp/transport/udp/udp_tran_test.c @@ -268,15 +268,20 @@ test_udp_multi_small_burst(void) NUTS_PASS(nng_dialer_start(d, 0)); nng_msleep(100); - float actual = 0; - float expect = 0; - int burst = 4; - int count = 20; - -#ifdef NNG_PLATFORM_WINDOWS + float actual = 0; + float expect = 0; + float require = 0.50; + int burst = 4; + int count = 20; + +#if defined(NNG_SANITIZER) || defined(NNG_COVERAGE) + // sanitizers may drop a lot, so can coverage + require = 0.0; +#elif defined(NNG_PLATFORM_WINDOWS) // Windows seems to drop a lot - maybe because of virtualization - burst = 2; - count = 10; + burst = 2; + count = 10; + require = 0.10; #endif // Experimentally at least on Darwin, we see some packet losses @@ -297,13 +302,9 @@ test_udp_multi_small_burst(void) NUTS_TRUE(sz == 95); } NUTS_TRUE(actual <= expect); -#if !defined(NNG_SANITIZER) && !defined(NNG_COVERAGE) - // Under sanitizer runs we lose a lot, maybe even majority, of packets - NUTS_TRUE( - actual / expect > 0.50); // maximum reasonable packet loss of 20% + NUTS_TRUE(actual / expect > require); NUTS_MSG("Packet loss: %.02f (got %.f of %.f)", 1.0 - actual / expect, actual, expect); -#endif NUTS_CLOSE(s0); NUTS_CLOSE(s1); }