diff options
Diffstat (limited to 'meta/lib/oeqa/runtime/cases/ssh.py')
-rw-r--r-- | meta/lib/oeqa/runtime/cases/ssh.py | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/meta/lib/oeqa/runtime/cases/ssh.py b/meta/lib/oeqa/runtime/cases/ssh.py index 60a5fbbfbf..b632a29a01 100644 --- a/meta/lib/oeqa/runtime/cases/ssh.py +++ b/meta/lib/oeqa/runtime/cases/ssh.py | |||
@@ -1,8 +1,13 @@ | |||
1 | # | 1 | # |
2 | # Copyright OpenEmbedded Contributors | ||
3 | # | ||
2 | # SPDX-License-Identifier: MIT | 4 | # SPDX-License-Identifier: MIT |
3 | # | 5 | # |
4 | 6 | ||
5 | from oeqa.runtime.case import OERuntimeTestCase | 7 | import time |
8 | import signal | ||
9 | |||
10 | from oeqa.runtime.case import OERuntimeTestCase, run_network_serialdebug | ||
6 | from oeqa.core.decorator.depends import OETestDepends | 11 | from oeqa.core.decorator.depends import OETestDepends |
7 | from oeqa.runtime.decorator.package import OEHasPackage | 12 | from oeqa.runtime.decorator.package import OEHasPackage |
8 | 13 | ||
@@ -11,9 +16,23 @@ class SSHTest(OERuntimeTestCase): | |||
11 | @OETestDepends(['ping.PingTest.test_ping']) | 16 | @OETestDepends(['ping.PingTest.test_ping']) |
12 | @OEHasPackage(['dropbear', 'openssh-sshd']) | 17 | @OEHasPackage(['dropbear', 'openssh-sshd']) |
13 | def test_ssh(self): | 18 | def test_ssh(self): |
14 | (status, output) = self.target.run('uname -a') | 19 | for i in range(5): |
15 | self.assertEqual(status, 0, msg='SSH Test failed: %s' % output) | 20 | status, output = self.target.run("uname -a", timeout=30) |
16 | (status, output) = self.target.run('cat /etc/masterimage') | 21 | if status == 0: |
17 | msg = "This isn't the right image - /etc/masterimage " \ | 22 | break |
18 | "shouldn't be here %s" % output | 23 | elif status == 255 or status == -signal.SIGTERM: |
19 | self.assertEqual(status, 1, msg=msg) | 24 | # ssh returns 255 only if a ssh error occurs. This could |
25 | # be an issue with "Connection refused" because the port | ||
26 | # isn't open yet, and this could check explicitly for that | ||
27 | # here. However, let's keep it simple and just retry for | ||
28 | # all errors a limited amount of times with a sleep to | ||
29 | # give it time for the port to open. | ||
30 | # We sometimes see -15 (SIGTERM) on slow emulation machines too, likely | ||
31 | # from boot/init not being 100% complete, retry for these too. | ||
32 | time.sleep(5) | ||
33 | continue | ||
34 | else: | ||
35 | run_network_serialdebug(self.target.runner) | ||
36 | self.fail("uname failed with \"%s\" (exit code %s)" % (output, status)) | ||
37 | if status != 0: | ||
38 | self.fail("ssh failed with \"%s\" (exit code %s)" % (output, status)) | ||