@@ -16,8 +16,6 @@ pub enum FingerprintDumpError {
16
16
ReadSysfsFile ( String , std:: io:: Error ) ,
17
17
/// Failed to get kernel version: {0}
18
18
GetKernelVersion ( std:: io:: Error ) ,
19
- /// `{0}` failed: {1}
20
- ShellCommand ( String , String ) ,
21
19
}
22
20
23
21
pub fn dump ( vmm : Arc < Mutex < Vmm > > ) -> Result < Fingerprint , FingerprintDumpError > {
@@ -61,26 +59,6 @@ fn read_sysfs_file(path: &str) -> Result<String, FingerprintDumpError> {
61
59
Ok ( s. trim_end_matches ( '\n' ) . to_string ( ) )
62
60
}
63
61
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: {:?}\n stdout: {}\n stderr: {}" ,
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
-
84
62
#[ cfg( test) ]
85
63
mod tests {
86
64
use super :: * ;
@@ -105,18 +83,4 @@ mod tests {
105
83
panic ! ( "Should fail with `No such file or directory`" ) ;
106
84
}
107
85
}
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
- }
122
86
}
0 commit comments