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), } }