summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>2025-10-07 19:38:06 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-10-09 10:58:07 +0100
commit8810c1deb029f1d8dba915c39f7aae92e9e9f2ad (patch)
treecc6d7be5b9a1c6aab40e723a7545a411cbb7ddc0
parentabd46facfa5a214d4895d368707681172e1624e6 (diff)
downloadpoky-8810c1deb029f1d8dba915c39f7aae92e9e9f2ad.tar.gz
oeqa: target: ssh: Fail on SSH error even when errors are ignored
Most tests running SSH commands ask for no error to be raised when the returned status is not 0. As run() will return this status, they may later use its value to do a similar check on their own, or completely ignore it. But most of the tests do not check if the non-zero status is caused by a fail of the command run on the target or by a fail of SSH itself. This can lead to confusion when the error does not come from the command executed on the target but from SSH itself: test might wrongfully be marked as PASSED or might fail with incoherent errors. As SSH errors are always reported with exit code 255, we can easily filter these. Modify OESSHTarget.run() behaviour so an AssertionError is raised on SSH failures, even when ignore_status parameter is True. Still allow to explicitly ignore this error for the rare cases where this can be needed. (From OE-Core rev: afe118d4f2de1f636b3a81dc692da35b35a3f2d7) Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/core/target/ssh.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/meta/lib/oeqa/core/target/ssh.py b/meta/lib/oeqa/core/target/ssh.py
index 8b5c450a05..0ac3ae4388 100644
--- a/meta/lib/oeqa/core/target/ssh.py
+++ b/meta/lib/oeqa/core/target/ssh.py
@@ -55,7 +55,7 @@ class OESSHTarget(OETarget):
55 def stop(self, **kwargs): 55 def stop(self, **kwargs):
56 pass 56 pass
57 57
58 def _run(self, command, timeout=None, ignore_status=True, raw=False): 58 def _run(self, command, timeout=None, ignore_status=True, raw=False, ignore_ssh_fails=False):
59 """ 59 """
60 Runs command in target using SSHProcess. 60 Runs command in target using SSHProcess.
61 """ 61 """
@@ -66,13 +66,17 @@ class OESSHTarget(OETarget):
66 self.logger.debug("[Command returned '%d' after %.2f seconds]" 66 self.logger.debug("[Command returned '%d' after %.2f seconds]"
67 "" % (status, time.time() - starttime)) 67 "" % (status, time.time() - starttime))
68 68
69 if status and not ignore_status: 69 if status == 255 and not ignore_ssh_fails:
70 raise AssertionError("ssh exited with status '255' for command "
71 "'%s': this is likely an SSH failure\n%s"
72 % (command, output))
73 elif status and not ignore_status:
70 raise AssertionError("Command '%s' returned non-zero exit " 74 raise AssertionError("Command '%s' returned non-zero exit "
71 "status %d:\n%s" % (command, status, output)) 75 "status %d:\n%s" % (command, status, output))
72 76
73 return (status, output) 77 return (status, output)
74 78
75 def run(self, command, timeout=None, ignore_status=True, raw=False): 79 def run(self, command, timeout=None, ignore_status=True, raw=False, ignore_ssh_fails=False):
76 """ 80 """
77 Runs command in target. 81 Runs command in target.
78 82
@@ -91,7 +95,7 @@ class OESSHTarget(OETarget):
91 else: 95 else:
92 processTimeout = self.timeout 96 processTimeout = self.timeout
93 97
94 status, output = self._run(sshCmd, processTimeout, ignore_status, raw) 98 status, output = self._run(sshCmd, processTimeout, ignore_status, raw, ignore_ssh_fails)
95 if len(output) > (64 * 1024): 99 if len(output) > (64 * 1024):
96 self.logger.debug('Command: %s\nStatus: %d Output length: %s\n' % (command, status, len(output))) 100 self.logger.debug('Command: %s\nStatus: %d Output length: %s\n' % (command, status, len(output)))
97 else: 101 else: