1c342db35SBrad Bishop#
292b42cb3SPatrick Williams# Copyright OpenEmbedded Contributors
392b42cb3SPatrick Williams#
4c342db35SBrad Bishop# SPDX-License-Identifier: MIT
5c342db35SBrad Bishop#
6c342db35SBrad Bishop
7eb8dc403SDave Cobbleyfrom oeqa.runtime.case import OERuntimeTestCase
8eb8dc403SDave Cobbleyfrom oeqa.core.decorator.depends import OETestDepends
9977dc1acSBrad Bishopfrom oeqa.runtime.decorator.package import OEHasPackage
10eb8dc403SDave Cobbley
11eb8dc403SDave Cobbleyclass SSHTest(OERuntimeTestCase):
12eb8dc403SDave Cobbley
13eb8dc403SDave Cobbley    @OETestDepends(['ping.PingTest.test_ping'])
14977dc1acSBrad Bishop    @OEHasPackage(['dropbear', 'openssh-sshd'])
15eb8dc403SDave Cobbley    def test_ssh(self):
16*ac13d5f3SPatrick Williams        (status, output) = self.target.run('sleep 20', timeout=2)
17*ac13d5f3SPatrick Williams        msg='run() timed out but return code was zero.'
18*ac13d5f3SPatrick Williams        self.assertNotEqual(status, 0, msg=msg)
19eb8dc403SDave Cobbley        (status, output) = self.target.run('uname -a')
20eb8dc403SDave Cobbley        self.assertEqual(status, 0, msg='SSH Test failed: %s' % output)
217e0e3c0cSAndrew Geissler        (status, output) = self.target.run('cat /etc/controllerimage')
227e0e3c0cSAndrew Geissler        msg = "This isn't the right image  - /etc/controllerimage " \
23eb8dc403SDave Cobbley              "shouldn't be here %s" % output
24eb8dc403SDave Cobbley        self.assertEqual(status, 1, msg=msg)
25