Fixed the network ping and jitter tests to run on Windows
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Gregory Ballantine 2022-08-17 18:48:07 -04:00
parent 88be1ad2ba
commit 39ce86d2c3

View File

@ -7,10 +7,16 @@ use crate::text;
pub fn ping_host(address: &str, count: &u16) { pub fn ping_host(address: &str, count: &u16) {
println!("Pinging host {}, {} times.", address, count); println!("Pinging host {}, {} times.", address, count);
let mut count_arg = "-c";
if cfg!(windows) {
count_arg = "-n";
}
// run the ping command // run the ping command
let output = process::Command::new("ping") let output = process::Command::new("ping")
.arg(address) .arg(address)
.arg(format!("-c {}", count)) .arg(count_arg)
.arg(format!("{}", count))
.output() .output()
.expect("Failed to execute command"); .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) { pub fn jitter_test(address: &str, count: &u16) {
println!("Pinging host {}, {} times to determine network jitter.", address, count); 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 // run the ping command
let output = process::Command::new("ping") let output = process::Command::new("ping")
.arg(address) .arg(address)
.arg(format!("-c {}", count)) .arg(count_arg)
.arg(format!("{}", count))
.output() .output()
.expect("Failed to execute command"); .expect("Failed to execute command");