Skip to content

Commit

Permalink
UDP: More test tuning for lossy environments.
Browse files Browse the repository at this point in the history
  • Loading branch information
gdamore committed Oct 13, 2024
1 parent b61285d commit f9591be
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/sp/transport/udp/udp_tran_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
Expand Down

0 comments on commit f9591be

Please sign in to comment.