Give some tolerance to recv_mmsg test (#25299)

This commit is contained in:
sakridge 2022-05-19 10:54:39 -06:00 committed by GitHub
parent 2266dfc696
commit 8c39648ec6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -18,6 +18,7 @@ pub fn test_recv_mmsg_batch_size() {
let sent = TEST_BATCH_SIZE; let sent = TEST_BATCH_SIZE;
let mut elapsed_in_max_batch = 0; let mut elapsed_in_max_batch = 0;
let mut num_max_batches = 0;
(0..1000).for_each(|_| { (0..1000).for_each(|_| {
for _ in 0..sent { for _ in 0..sent {
let data = [0; PACKET_DATA_SIZE]; let data = [0; PACKET_DATA_SIZE];
@ -27,8 +28,11 @@ pub fn test_recv_mmsg_batch_size() {
let now = Instant::now(); let now = Instant::now();
let recv = recv_mmsg(&reader, &mut packets[..]).unwrap(); let recv = recv_mmsg(&reader, &mut packets[..]).unwrap();
elapsed_in_max_batch += now.elapsed().as_nanos(); elapsed_in_max_batch += now.elapsed().as_nanos();
assert_eq!(TEST_BATCH_SIZE, recv); if recv == TEST_BATCH_SIZE {
num_max_batches += 1;
}
}); });
assert!(num_max_batches > 990);
let mut elapsed_in_small_batch = 0; let mut elapsed_in_small_batch = 0;
(0..1000).for_each(|_| { (0..1000).for_each(|_| {