mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-22 19:32:20 +00:00
test_infra: Return an error if SSH executed command exits with non-zero
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
3dc15a9259
commit
e7cf513064
@ -503,6 +503,8 @@ pub enum SshCommandError {
|
|||||||
Authentication(ssh2::Error),
|
Authentication(ssh2::Error),
|
||||||
ChannelSession(ssh2::Error),
|
ChannelSession(ssh2::Error),
|
||||||
Command(ssh2::Error),
|
Command(ssh2::Error),
|
||||||
|
ExitStatus(ssh2::Error),
|
||||||
|
NonZeroExitStatus(i32),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ssh_command_ip_with_auth(
|
pub fn ssh_command_ip_with_auth(
|
||||||
@ -537,7 +539,14 @@ pub fn ssh_command_ip_with_auth(
|
|||||||
let _ = channel.read_to_string(&mut s);
|
let _ = channel.read_to_string(&mut s);
|
||||||
let _ = channel.close();
|
let _ = channel.close();
|
||||||
let _ = channel.wait_close();
|
let _ = channel.wait_close();
|
||||||
Ok(())
|
|
||||||
|
let status = channel.exit_status().map_err(SshCommandError::ExitStatus)?;
|
||||||
|
|
||||||
|
if status != 0 {
|
||||||
|
Err(SshCommandError::NonZeroExitStatus(status))
|
||||||
|
} else {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
})() {
|
})() {
|
||||||
Ok(_) => break,
|
Ok(_) => break,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user