3 Commits

Author SHA1 Message Date
8a7d8c1860 Version bump to v0.3.2
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2022-08-17 18:49:12 -04:00
39ce86d2c3 Fixed the network ping and jitter tests to run on Windows
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-08-17 18:48:07 -04:00
88be1ad2ba Added the scaffolding for the jitter test. Now just need to perform the proper calculations.
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-08-17 18:39:53 -04:00
3 changed files with 59 additions and 10 deletions

View File

@ -1,7 +1,7 @@
[package]
name = "hardware-tests"
description = "Bit Goblin PC hardware test suite."
version = "0.3.1"
version = "0.3.2"
edition = "2021"
readme = "README.md"
license = "BSD 2-Clause"

View File

@ -7,10 +7,44 @@ 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");
// check that the command succeeded
assert!(output.status.success());
// grab the ping results from stdout
let results_raw = &String::from_utf8_lossy(&output.stdout);
let results = text::format::trim_output(results_raw, 4);
for line in results {
println!("{}", line);
}
}
// network jitter test
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(count_arg)
.arg(format!("{}", count))
.output()
.expect("Failed to execute command");

View File

@ -11,8 +11,8 @@ struct Cli {
#[clap(subcommand)]
command: Commands,
#[clap(short = 'l', long, default_value_t = 1, help = "Number of times to run test. Default = 1", global = true)]
loopcount: u8,
#[clap(short = 'i', long, default_value_t = 1, help = "Number of times to run test. Default = 1", global = true)]
iterations: u8,
}
#[derive(Subcommand)]
@ -108,6 +108,15 @@ enum NetCommands {
count: u16,
},
// jitter subcommand
#[clap(name = "jitter", about = "Ping a host to determine network jitter.")]
Jitter {
#[clap(short = 'a', long, default_value_t = String::from("8.8.8.8"))]
address: String,
#[clap(short = 'c', long, default_value_t = 30)]
count: u16,
},
// bandwidth test subcommand
#[clap(name = "bandwidth", about = "Downloads a remote file to determine network bandwidth.")]
Bandwidth {
@ -129,25 +138,25 @@ fn main() {
Commands::Disk(args) => match &args.disk_commands {
DiskCommands::ReadSeqTest { tempfile, size } => {
for i in 0..cli.loopcount {
for i in 0..cli.iterations {
println!("Test run number {}.", i + 1);
benchmarks::disk::disk_read_seq_test(tempfile, size);
}
},
DiskCommands::ReadRandTest { tempfile, size } => {
for i in 0..cli.loopcount {
for i in 0..cli.iterations {
println!("Test run number {}.", i + 1);
benchmarks::disk::disk_read_rand_test(tempfile, size);
}
},
DiskCommands::WriteSeqTest { tempfile, size } => {
for i in 0..cli.loopcount {
for i in 0..cli.iterations {
println!("Test run number {}.", i + 1);
benchmarks::disk::disk_write_seq_test(tempfile, size);
}
},
DiskCommands::WriteRandTest { tempfile, size } => {
for i in 0..cli.loopcount {
for i in 0..cli.iterations {
println!("Test run number {}.", i + 1);
benchmarks::disk::disk_write_rand_test(tempfile, size);
}
@ -156,13 +165,19 @@ fn main() {
Commands::Net(args) => match &args.net_commands {
NetCommands::Ping { address, count } => {
for i in 0..cli.loopcount {
for i in 0..cli.iterations {
println!("Test run number {}.", i + 1);
benchmarks::network::ping_host(address, count);
}
},
NetCommands::Jitter { address, count } => {
for i in 0..cli.iterations {
println!("Test run number {}.", i + 1);
benchmarks::network::jitter_test(address, count);
}
},
NetCommands::Bandwidth { download, output } => {
for i in 0..cli.loopcount {
for i in 0..cli.iterations {
println!("Test run number {}.", i + 1);
benchmarks::network::bandwidth_test(download, output);
}