summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2019-06-26 10:59:37 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-06-27 12:20:36 +0100
commitabfe4b3d5cd8d05c8ab99240e30ac281725fac14 (patch)
treeece59dc5b7159d0104454dee0f23d9c9c9889d31 /meta/lib/oeqa
parent91144160e1770d07994670b8b97274d1f96ed05f (diff)
downloadpoky-abfe4b3d5cd8d05c8ab99240e30ac281725fac14.tar.gz
oeqa/runtime/syslog: Improve test debug messages
Its useful to test whether the restart command returned an error code and exit early from the test if so. Also add different messages to tell if the syslog processes didn't die or didn't restart. (From OE-Core rev: f19e95b8571a0d8213c4dec0da056e3d243fbbd1) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa')
-rw-r--r--meta/lib/oeqa/runtime/cases/oe_syslog.py32
1 files changed, 20 insertions, 12 deletions
diff --git a/meta/lib/oeqa/runtime/cases/oe_syslog.py b/meta/lib/oeqa/runtime/cases/oe_syslog.py
index 0f79e5a0f3..f987dccfb1 100644
--- a/meta/lib/oeqa/runtime/cases/oe_syslog.py
+++ b/meta/lib/oeqa/runtime/cases/oe_syslog.py
@@ -43,31 +43,38 @@ class SyslogTestConfig(OERuntimeTestCase):
43 def restart_sanity(self, names, restart_cmd): 43 def restart_sanity(self, names, restart_cmd):
44 status, original_pids = self.verify_running(names) 44 status, original_pids = self.verify_running(names)
45 if status: 45 if status:
46 return 1 46 return False
47 47
48 status, output = self.target.run(restart_cmd) 48 status, output = self.target.run(restart_cmd)
49 49
50 msg = ('Could not restart %s service. Status and output: %s and %s' % (names, status, output))
51 self.assertEqual(status, 0, msg)
52
50 # Always check for an error, most likely a race between shutting down and starting up 53 # Always check for an error, most likely a race between shutting down and starting up
51 timeout = time.time() + 30 54 timeout = time.time() + 30
52 55
56 restarted = False
57 status = ""
53 while time.time() < timeout: 58 while time.time() < timeout:
54 # Verify the previous ones are no longer running 59 # Verify the previous ones are no longer running
55 status = self.verif_not_running(original_pids) 60 status = self.verif_not_running(original_pids)
56 if status: 61 if status:
62 status = "Original syslog processes still running"
57 continue 63 continue
58 64
59 status, pids = self.verify_running(names) 65 status, pids = self.verify_running(names)
60 if status: 66 if status:
67 status = "New syslog processes not running"
61 continue 68 continue
62 69
63 # Everything is fine now, so exit to continue the test 70 # Everything is fine now, so exit to continue the test
64 status = 0 71 restarted = True
65 break 72 break
66 73
67 msg = ('Could not restart %s service. Status and output: %s and %s' 74 msg = ('%s didn\'t appear to restart: %s' % (names, status))
68 %(names, status, output)) 75 self.assertTrue(restarted, msg)
69 self.assertEqual(status, 0, msg)
70 76
77 return True
71 78
72 @OETestDepends(['oe_syslog.SyslogTest.test_syslog_running']) 79 @OETestDepends(['oe_syslog.SyslogTest.test_syslog_running'])
73 def test_syslog_logger(self): 80 def test_syslog_logger(self):
@@ -88,13 +95,14 @@ class SyslogTestConfig(OERuntimeTestCase):
88 95
89 @OETestDepends(['oe_syslog.SyslogTest.test_syslog_running']) 96 @OETestDepends(['oe_syslog.SyslogTest.test_syslog_running'])
90 def test_syslog_restart(self): 97 def test_syslog_restart(self):
91 status = self.restart_sanity(['systemd-journald'], 'systemctl restart syslog.service') 98 if self.restart_sanity(['systemd-journald'], 'systemctl restart syslog.service'):
92 if status: 99 pass
93 status = self.restart_sanity(['rsyslogd'], '/etc/init.d/rsyslog restart') 100 elif self.restart_sanity(['rsyslogd'], '/etc/init.d/rsyslog restart'):
94 if status: 101 pass
95 status = self.restart_sanity(['syslogd', 'klogd'], '/etc/init.d/syslog restart') 102 elif self.restart_sanity(['syslogd', 'klogd'], '/etc/init.d/syslog restart'):
96 else: 103 pass
97 self.logger.info("No syslog found to restart, ignoring") 104 else:
105 self.logger.info("No syslog found to restart, ignoring")
98 106
99 107
100 @OETestDepends(['oe_syslog.SyslogTestConfig.test_syslog_logger']) 108 @OETestDepends(['oe_syslog.SyslogTestConfig.test_syslog_logger'])