From 39ce86d2c3728b28292402a872eb82d86b5aa3aa Mon Sep 17 00:00:00 2001 From: Gregory Ballantine Date: Wed, 17 Aug 2022 18:48:07 -0400 Subject: [PATCH] Fixed the network ping and jitter tests to run on Windows --- src/benchmarks/network.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/benchmarks/network.rs b/src/benchmarks/network.rs index 4a7e17d..7080dc8 100644 --- a/src/benchmarks/network.rs +++ b/src/benchmarks/network.rs @@ -7,10 +7,16 @@ use crate::text; pub fn ping_host(address: &str, count: &u16) { println!("Pinging host {}, {} times.", address, count); + let mut count_arg = "-c"; + if cfg!(windows) { + count_arg = "-n"; + } + // run the ping command let output = process::Command::new("ping") .arg(address) - .arg(format!("-c {}", count)) + .arg(count_arg) + .arg(format!("{}", count)) .output() .expect("Failed to execute command"); @@ -29,10 +35,16 @@ pub fn ping_host(address: &str, count: &u16) { pub fn jitter_test(address: &str, count: &u16) { println!("Pinging host {}, {} times to determine network jitter.", address, count); + let mut count_arg = "-c"; + if cfg!(windows) { + count_arg = "-n"; + } + // run the ping command let output = process::Command::new("ping") .arg(address) - .arg(format!("-c {}", count)) + .arg(count_arg) + .arg(format!("{}", count)) .output() .expect("Failed to execute command");