Consolidated the test programs into one 'bgbench' program
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
29
src/tests/disk.rs
Normal file
29
src/tests/disk.rs
Normal file
@ -0,0 +1,29 @@
|
||||
use std::fs;
|
||||
use std::process::Command;
|
||||
|
||||
// test disk write speeds by continually writing zeroes to it
|
||||
pub fn disk_write_test(tempfile: &str, size: &u8) {
|
||||
// convert size in Gigabytes down to Megabytes
|
||||
let size_gigs: u32 = (*size as u32 * 1024).into();
|
||||
|
||||
// run the dd command with a block size of 1 MB
|
||||
let output = Command::new("dd")
|
||||
.arg("bs=1M")
|
||||
.arg(format!("count={}", size_gigs))
|
||||
.arg("if=/dev/zero")
|
||||
.arg(format!("of={}", tempfile))
|
||||
.output()
|
||||
.expect("Failed to execute command");
|
||||
|
||||
// check that the command succeeded
|
||||
assert!(output.status.success());
|
||||
|
||||
// for whatever reason, `dd` output ends up in stderr
|
||||
println!("{}", String::from_utf8_lossy(&output.stderr));
|
||||
|
||||
// remove the test file
|
||||
match fs::remove_file(tempfile) {
|
||||
Ok(()) => println!("Cleaning up..."),
|
||||
Err(e) => println!("There was a problem during cleanup - {}", e),
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user