1#
2# SPDX-License-Identifier: MIT
3#
4
5from oeqa.runtime.case import OERuntimeTestCase
6from oeqa.core.decorator.depends import OETestDepends
7from oeqa.runtime.decorator.package import OEHasPackage
8
9class ConnmanTest(OERuntimeTestCase):
10
11    def service_status(self, service):
12        if 'systemd' in self.tc.td['DISTRO_FEATURES']:
13            (_, output) = self.target.run('systemctl status -l %s' % service)
14            return output
15        else:
16            return "Unable to get status or logs for %s" % service
17
18    @OETestDepends(['ssh.SSHTest.test_ssh'])
19    @OEHasPackage(["connman"])
20    def test_connmand_help(self):
21        (status, output) = self.target.run('/usr/sbin/connmand --help')
22        msg = 'Failed to get connman help. Output: %s' % output
23        self.assertEqual(status, 0, msg=msg)
24
25    @OETestDepends(['connman.ConnmanTest.test_connmand_help'])
26    def test_connmand_running(self):
27        cmd = '%s | grep [c]onnmand' % self.tc.target_cmds['ps']
28        (status, output) = self.target.run(cmd)
29        if status != 0:
30            self.logger.info(self.service_status("connman"))
31            self.fail("No connmand process running")
32