Added a simple program that tests a disk's write speed
This commit is contained in:
parent
002fb2fc88
commit
04ebc2290f
5
.gitignore
vendored
5
.gitignore
vendored
@ -14,3 +14,8 @@ Cargo.lock
|
||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||
*.pdb
|
||||
|
||||
|
||||
|
||||
# Added by cargo
|
||||
|
||||
/target
|
||||
|
12
Cargo.toml
Normal file
12
Cargo.toml
Normal file
@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "hardware-tests"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[[bin]]
|
||||
name = "hdtest"
|
||||
path = "src/hdtest.rs"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
25
src/hdtest.rs
Normal file
25
src/hdtest.rs
Normal file
@ -0,0 +1,25 @@
|
||||
use std::fs;
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
// run the dd command with a block size of 1 MB, 10K times (10GB file)
|
||||
let output = Command::new("dd")
|
||||
.arg("bs=1M")
|
||||
.arg("count=10240")
|
||||
.arg("if=/dev/zero")
|
||||
.arg("of=./speed-test")
|
||||
.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("./speed-test") {
|
||||
Ok(()) => println!("Cleaning up..."),
|
||||
Err(e) => println!("There was a problem during cleanup - {}", e),
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user