Skip to content

Commit af2248d

Browse files
authored
Merge branch 'main' into dependabot/cargo/firecracker-142e97e9c3
2 parents 3e48dda + 4b79156 commit af2248d

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

tests/framework/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ def run_cmd(cmd, check=False, shell=True, cwd=None, timeout=None) -> CommandRetu
381381
382382
:param cmd: command to execute
383383
:param check: whether a non-zero return code should result in a `ChildProcessError` or not.
384-
:param no_shell: don't run the command in a sub-shell
384+
:param shell: run the command in a sub-shell
385385
:param cwd: sets the current directory before the child is executed
386386
:param timeout: Time before command execution should be aborted with a `TimeoutExpired` exception
387387
:return: return code, stdout, stderr

tests/host_tools/network.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,24 +90,33 @@ def _init_connection(self):
9090
We'll keep trying to execute a remote command that can't fail
9191
(`/bin/true`), until we get a successful (0) exit code.
9292
"""
93-
self.check_output("true", timeout=10)
93+
self.check_output("true", timeout=10, debug=True)
94+
95+
def run(self, cmd_string, timeout=None, *, check=False, debug=False):
96+
"""
97+
Execute the command passed as a string in the ssh context.
98+
99+
If `debug` is set, pass `-vvv` to `ssh`. Note that this will clobber stderr.
100+
"""
101+
command = [
102+
"ssh",
103+
*self.options,
104+
f"{self.user}@{self.host}",
105+
cmd_string,
106+
]
107+
108+
if debug:
109+
command.insert(1, "-vvv")
94110

95-
def run(self, cmd_string, timeout=None, *, check=False):
96-
"""Execute the command passed as a string in the ssh context."""
97111
return self._exec(
98-
[
99-
"ssh",
100-
*self.options,
101-
f"{self.user}@{self.host}",
102-
cmd_string,
103-
],
112+
command,
104113
timeout,
105114
check=check,
106115
)
107116

108-
def check_output(self, cmd_string, timeout=None):
117+
def check_output(self, cmd_string, timeout=None, *, debug=False):
109118
"""Same as `run`, but raises an exception on non-zero return code of remote command"""
110-
return self.run(cmd_string, timeout, check=True)
119+
return self.run(cmd_string, timeout, check=True, debug=debug)
111120

112121
def _exec(self, cmd, timeout=None, check=False):
113122
"""Private function that handles the ssh client invocation."""

0 commit comments

Comments
 (0)