diff --git a/src/cpu-template-helper/src/fingerprint/dump.rs b/src/cpu-template-helper/src/fingerprint/dump.rs index c5e6055a145..e362e88e98a 100644 --- a/src/cpu-template-helper/src/fingerprint/dump.rs +++ b/src/cpu-template-helper/src/fingerprint/dump.rs @@ -16,8 +16,6 @@ pub enum FingerprintDumpError { ReadSysfsFile(String, std::io::Error), /// Failed to get kernel version: {0} GetKernelVersion(std::io::Error), - /// `{0}` failed: {1} - ShellCommand(String, String), } pub fn dump(vmm: Arc>) -> Result { @@ -61,26 +59,6 @@ fn read_sysfs_file(path: &str) -> Result { Ok(s.trim_end_matches('\n').to_string()) } -fn run_shell_command(cmd: &str) -> Result { - let output = std::process::Command::new("bash") - .args(["-c", cmd]) - .output() - .map_err(|err| FingerprintDumpError::ShellCommand(cmd.to_string(), err.to_string()))?; - - if !output.status.success() { - return Err(FingerprintDumpError::ShellCommand( - cmd.to_string(), - format!( - "code: {:?}\nstdout: {}\nstderr: {}", - output.status.code(), - std::str::from_utf8(&output.stdout).unwrap(), - std::str::from_utf8(&output.stderr).unwrap(), - ), - )); - } - Ok(std::str::from_utf8(&output.stdout).unwrap().to_string()) -} - #[cfg(test)] mod tests { use super::*; @@ -105,18 +83,4 @@ mod tests { panic!("Should fail with `No such file or directory`"); } } - - #[test] - fn test_run_valid_shell_command() { - let valid_cmd = "ls"; - run_shell_command(valid_cmd).unwrap(); - } - - #[test] - fn test_run_invalid_shell_command() { - let invalid_cmd = "unknown_command"; - if run_shell_command(invalid_cmd).is_ok() { - panic!("Should fail with `unknown_command: not found`"); - } - } }