hardware-tests/src/tests/disk.rs
2022-08-06 01:27:15 -04:00

110 lines
3.2 KiB
Rust

use std::process::Command;
// test disk sequential read speeds w/ fio
pub fn disk_read_seq_test(tempfile: &str, size: &u8) {
// run the fio command
let output = Command::new("fio")
.arg("--name=TEST")
.arg(format!("--filename={}", tempfile))
.arg("--rw=read")
.arg("--size=2g")
.arg(format!("--io_size={}g", size))
.arg("--blocksize=1024k")
.arg("--ioengine=libaio")
.arg("--fsync=10000")
.arg("--iodepth=32")
.arg("--direct=1")
.arg("--numjobs=1")
.arg("--runtime=60")
.arg("--group_reporting")
.output()
.expect("Failed to execute command");
// check that the command succeeded
assert!(output.status.success());
// print the test's output
println!("{}", String::from_utf8_lossy(&output.stdout));
}
// test disk 4K random read speeds w/ fio
pub fn disk_read_rand_test(tempfile: &str, size: &u8) {
// run the fio command
let output = Command::new("fio")
.arg("--name=TEST")
.arg(format!("--filename={}", tempfile))
.arg("--rw=randread")
.arg("--size=2g")
.arg(format!("--io_size={}g", size))
.arg("--blocksize=4k")
.arg("--ioengine=libaio")
.arg("--fsync=1")
.arg("--iodepth=1")
.arg("--direct=1")
.arg("--numjobs=32")
.arg("--runtime=60")
.arg("--group_reporting")
.output()
.expect("Failed to execute command");
// check that the command succeeded
assert!(output.status.success());
// print the test's output
println!("{}", String::from_utf8_lossy(&output.stdout));
}
// test sequential disk write speeds w/ fio
pub fn disk_write_seq_test(tempfile: &str, size: &u8) {
// run the fio command
let output = Command::new("fio")
.arg("--name=TEST")
.arg(format!("--filename={}", tempfile))
.arg("--rw=write")
.arg("--size=2g")
.arg(format!("--io_size={}g", size))
.arg("--blocksize=1024k")
.arg("--ioengine=libaio")
.arg("--fsync=10000")
.arg("--iodepth=32")
.arg("--direct=1")
.arg("--numjobs=1")
.arg("--runtime=60")
.arg("--group_reporting")
.output()
.expect("Failed to execute command");
// check that the command succeeded
assert!(output.status.success());
// print the test's output
println!("{}", String::from_utf8_lossy(&output.stdout));
}
// test random 4K disk write speeds w/ fio
pub fn disk_write_rand_test(tempfile: &str, size: &u8) {
// run the fio command
let output = Command::new("fio")
.arg("--name=TEST")
.arg(format!("--filename={}", tempfile))
.arg("--rw=randrw")
.arg("--size=2g")
.arg(format!("--io_size={}g", size))
.arg("--blocksize=4k")
.arg("--ioengine=libaio")
.arg("--fsync=1")
.arg("--iodepth=1")
.arg("--direct=1")
.arg("--numjobs=32")
.arg("--runtime=60")
.arg("--group_reporting")
.output()
.expect("Failed to execute command");
// check that the command succeeded
assert!(output.status.success());
// print the test's output
println!("{}", String::from_utf8_lossy(&output.stdout));
}