Skip to content

Commit f91b800

Browse files
committed
refactor: Drop run_shell_command()
run_shell_command() is no longer used and related error variant and tests can be dropped. Signed-off-by: Takahiro Itazuri <[email protected]>
1 parent 643349a commit f91b800

File tree

1 file changed

+0
-36
lines changed
  • src/cpu-template-helper/src/fingerprint

1 file changed

+0
-36
lines changed

src/cpu-template-helper/src/fingerprint/dump.rs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ pub enum FingerprintDumpError {
1616
ReadSysfsFile(String, std::io::Error),
1717
/// Failed to get kernel version: {0}
1818
GetKernelVersion(std::io::Error),
19-
/// `{0}` failed: {1}
20-
ShellCommand(String, String),
2119
}
2220

2321
pub fn dump(vmm: Arc<Mutex<Vmm>>) -> Result<Fingerprint, FingerprintDumpError> {
@@ -61,26 +59,6 @@ fn read_sysfs_file(path: &str) -> Result<String, FingerprintDumpError> {
6159
Ok(s.trim_end_matches('\n').to_string())
6260
}
6361

64-
fn run_shell_command(cmd: &str) -> Result<String, FingerprintDumpError> {
65-
let output = std::process::Command::new("bash")
66-
.args(["-c", cmd])
67-
.output()
68-
.map_err(|err| FingerprintDumpError::ShellCommand(cmd.to_string(), err.to_string()))?;
69-
70-
if !output.status.success() {
71-
return Err(FingerprintDumpError::ShellCommand(
72-
cmd.to_string(),
73-
format!(
74-
"code: {:?}\nstdout: {}\nstderr: {}",
75-
output.status.code(),
76-
std::str::from_utf8(&output.stdout).unwrap(),
77-
std::str::from_utf8(&output.stderr).unwrap(),
78-
),
79-
));
80-
}
81-
Ok(std::str::from_utf8(&output.stdout).unwrap().to_string())
82-
}
83-
8462
#[cfg(test)]
8563
mod tests {
8664
use super::*;
@@ -105,18 +83,4 @@ mod tests {
10583
panic!("Should fail with `No such file or directory`");
10684
}
10785
}
108-
109-
#[test]
110-
fn test_run_valid_shell_command() {
111-
let valid_cmd = "ls";
112-
run_shell_command(valid_cmd).unwrap();
113-
}
114-
115-
#[test]
116-
fn test_run_invalid_shell_command() {
117-
let invalid_cmd = "unknown_command";
118-
if run_shell_command(invalid_cmd).is_ok() {
119-
panic!("Should fail with `unknown_command: not found`");
120-
}
121-
}
12286
}

0 commit comments

Comments
 (0)