From f3b60ee389567c7782761d224621692b1fc31f76 Mon Sep 17 00:00:00 2001 From: Luca Fancellu Date: Fri, 26 Jul 2024 11:05:31 +0100 Subject: [PATCH] arm/oeqa: Introduce retry mechanism for fvp_devices run_cmd Currently the run_cmd, which is a wrapper for self.target.run() that uses SSH to spawn commands on the target, can fail spuriously with error 255 and cause the test to fail on slow systems. In order to address that, introduce a retry mechanism for the call, that is able to wait some time for the system to settle and retry the command when the error code from SSH is 255. Signed-off-by: Luca Fancellu Signed-off-by: Jon Mason --- meta-arm/lib/oeqa/runtime/cases/fvp_devices.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/meta-arm/lib/oeqa/runtime/cases/fvp_devices.py b/meta-arm/lib/oeqa/runtime/cases/fvp_devices.py index 0246e76a..c9d08c03 100644 --- a/meta-arm/lib/oeqa/runtime/cases/fvp_devices.py +++ b/meta-arm/lib/oeqa/runtime/cases/fvp_devices.py @@ -1,16 +1,29 @@ from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.data import skipIfNotInDataVar from oeqa.core.decorator.depends import OETestDepends +from time import sleep class FvpDevicesTest(OERuntimeTestCase): - def run_cmd(self, cmd, check=True): + def run_cmd(self, cmd, check=True, retry=3): """ A wrapper around self.target.run, which: * Fails the test on command failure by default * Allows the "run" behavior to be overridden in sub-classes + * Has a retry mechanism when SSH returns 255 """ - (status, output) = self.target.run(cmd) + status = 255 + # The loop is retrying the self.target.run() which uses SSH only when + # the SSH return code is 255, which might be an issue with + # "Connection refused" because the port isn't open yet + while status == 255 and retry > 0: + (status, output) = self.target.run(cmd) + retry -= 1 + # In case the status is 255, delay the next retry to give time to + # the system to settle + if status == 255: + sleep(30) + if status and check: self.fail("Command '%s' returned non-zero exit " "status %d:\n%s" % (cmd, status, output))