blob: ee69e5df9615d611c673d97c2fa3f6cca107b19e [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001import unittest
2from oeqa.oetest import oeRuntimeTest, skipModule
3from oeqa.utils.decorators import *
4
5def setUpModule():
6 if not oeRuntimeTest.hasPackage("connman"):
7 skipModule("No connman package in image")
8
9
10class ConnmanTest(oeRuntimeTest):
11
12 def service_status(self, service):
13 if oeRuntimeTest.hasFeature("systemd"):
14 (status, output) = self.target.run('systemctl status -l %s' % service)
15 return output
16 else:
17 return "Unable to get status or logs for %s" % service
18
19 @testcase(961)
20 @skipUnlessPassed('test_ssh')
21 def test_connmand_help(self):
22 (status, output) = self.target.run('/usr/sbin/connmand --help')
23 self.assertEqual(status, 0, msg="status and output: %s and %s" % (status,output))
24
25 @testcase(221)
26 @skipUnlessPassed('test_connmand_help')
27 def test_connmand_running(self):
28 (status, output) = self.target.run(oeRuntimeTest.pscmd + ' | grep [c]onnmand')
29 if status != 0:
30 print self.service_status("connman")
31 self.fail("No connmand process running")
32
33 @testcase(223)
34 def test_only_one_connmand_in_background(self):
35 """
36 Summary: Only one connmand in background
37 Expected: There will be only one connmand instance in background.
38 Product: BSPs
39 Author: Alexandru Georgescu <alexandru.c.georgescu@intel.com>
40 AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
41 """
42
43 # Make sure that 'connmand' is running in background
44 (status, output) = self.target.run(oeRuntimeTest.pscmd + ' | grep [c]onnmand')
45 self.assertEqual(0, status, 'Failed to find "connmand" process running in background.')
46
47 # Start a new instance of 'connmand'
48 (status, output) = self.target.run('connmand')
49 self.assertEqual(0, status, 'Failed to start a new "connmand" process.')
50
51 # Make sure that only one 'connmand' is running in background
52 (status, output) = self.target.run(oeRuntimeTest.pscmd + ' | grep [c]onnmand | wc -l')
53 self.assertEqual(0, status, 'Failed to find "connmand" process running in background.')
54 self.assertEqual(1, int(output), 'Found {} connmand processes running, expected 1.'.format(output))