From: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
To: openembedded-core@lists.openembedded.org
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Subject: [PATCH 1/4] oeqa: target: ssh: Fail on SSH error even when errors are ignored
Date: Tue, 07 Oct 2025 19:38:06 +0200 [thread overview]
Message-ID: <20251007-mathieu-ssh-fails-v1-1-a6affee3571b@bootlin.com> (raw)
In-Reply-To: <20251007-mathieu-ssh-fails-v1-0-a6affee3571b@bootlin.com>
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.
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
---
meta/lib/oeqa/core/target/ssh.py | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/meta/lib/oeqa/core/target/ssh.py b/meta/lib/oeqa/core/target/ssh.py
index 8b5c450a058fd172f36af6cbd9569983aa3d2d51..0ac3ae438895c97e89599b2dfb2797dabbf383dd 100644
--- a/meta/lib/oeqa/core/target/ssh.py
+++ b/meta/lib/oeqa/core/target/ssh.py
@@ -55,7 +55,7 @@ class OESSHTarget(OETarget):
def stop(self, **kwargs):
pass
- def _run(self, command, timeout=None, ignore_status=True, raw=False):
+ def _run(self, command, timeout=None, ignore_status=True, raw=False, ignore_ssh_fails=False):
"""
Runs command in target using SSHProcess.
"""
@@ -66,13 +66,17 @@ class OESSHTarget(OETarget):
self.logger.debug("[Command returned '%d' after %.2f seconds]"
"" % (status, time.time() - starttime))
- if status and not ignore_status:
+ if status == 255 and not ignore_ssh_fails:
+ raise AssertionError("ssh exited with status '255' for command "
+ "'%s': this is likely an SSH failure\n%s"
+ % (command, output))
+ elif status and not ignore_status:
raise AssertionError("Command '%s' returned non-zero exit "
"status %d:\n%s" % (command, status, output))
return (status, output)
- def run(self, command, timeout=None, ignore_status=True, raw=False):
+ def run(self, command, timeout=None, ignore_status=True, raw=False, ignore_ssh_fails=False):
"""
Runs command in target.
@@ -91,7 +95,7 @@ class OESSHTarget(OETarget):
else:
processTimeout = self.timeout
- status, output = self._run(sshCmd, processTimeout, ignore_status, raw)
+ status, output = self._run(sshCmd, processTimeout, ignore_status, raw, ignore_ssh_fails)
if len(output) > (64 * 1024):
self.logger.debug('Command: %s\nStatus: %d Output length: %s\n' % (command, status, len(output)))
else:
--
2.47.3
next prev parent reply other threads:[~2025-10-07 17:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-07 17:38 [PATCH 0/4] oeqa: target: ssh: log SSH errors during tests Mathieu Dubois-Briand
2025-10-07 17:38 ` Mathieu Dubois-Briand [this message]
2025-10-07 17:38 ` [PATCH 2/4] oeqa: runtime: Ignore SSH errors during setup and tear down Mathieu Dubois-Briand
2025-10-09 14:26 ` [OE-core] " Ross Burton
2025-10-13 11:02 ` Mathieu Dubois-Briand
2025-10-07 17:38 ` [PATCH 3/4] oeqa: postactions: Ignore SSH errors Mathieu Dubois-Briand
2025-10-07 17:38 ` [PATCH 4/4] oeqa: runtime: ssh: Manage any SSH failure locally Mathieu Dubois-Briand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251007-mathieu-ssh-fails-v1-1-a6affee3571b@bootlin.com \
--to=mathieu.dubois-briand@bootlin.com \
--cc=openembedded-core@lists.openembedded.org \
--cc=thomas.petazzoni@bootlin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox