Files
poky/meta/lib/oeqa/runtime/cases/ssh.py
Jon Mason 8d405ba864 oeqa/runtime/ssh: check for all errors at the end
With the retry for the -SIGTERM, it is possible to still see that error
after the 5th attempt and mark the run a success.  Check for any
non-zero status in the final check and error out to close the gap.
While there, make the error print match the one above and be a little
more verbose.  Also, I'm seeing it take roughly 6 attempts on my local
(very slow) system to pass.  So, increasing the number of attempts to
10.

(From OE-Core rev: 3c3ebe591eef6e0479d623ec2237cfea16db5c80)

Signed-off-by: Jon Mason <jdmason@kudzu.us>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2024-07-08 09:17:09 +01:00

38 lines
1.4 KiB
Python

#
# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: MIT
#
import time
import signal
from oeqa.runtime.case import OERuntimeTestCase
from oeqa.core.decorator.depends import OETestDepends
from oeqa.runtime.decorator.package import OEHasPackage
class SSHTest(OERuntimeTestCase):
@OETestDepends(['ping.PingTest.test_ping'])
@OEHasPackage(['dropbear', 'openssh-sshd'])
def test_ssh(self):
for i in range(10):
status, output = self.target.run("uname -a", timeout=5)
if status == 0:
break
elif status == 255 or status == -signal.SIGTERM:
# ssh returns 255 only if a ssh error occurs. This could
# be an issue with "Connection refused" because the port
# isn't open yet, and this could check explicitly for that
# here. However, let's keep it simple and just retry for
# all errors a limited amount of times with a sleep to
# give it time for the port to open.
# We sometimes see -15 (SIGTERM) on slow emulation machines too, likely
# from boot/init not being 100% complete, retry for these too.
time.sleep(5)
continue
else:
self.fail("uname failed with \"%s\" (exit code %s)" % (output, status))
if status != 0:
self.fail("ssh failed with \"%s\" (exit code %s)" % (output, status))