Patchwork [3/4] lib/oeqa/runtime: rework syslog test

login
register
mail settings
Submitter Stanacar, StefanX
Date Aug. 9, 2013, 3:04 p.m.
Message ID <26b1bddb83dc438938ae4cac4c21e63aa07aca34.1376060086.git.stefanx.stanacar@intel.com>
Download mbox | patch
Permalink /patch/55425/
State Accepted
Commit 1990a6c507240fff0c8a65e28b065096bf4031e5
Headers show

Comments

Stanacar, StefanX - Aug. 9, 2013, 3:04 p.m.
Add separate tests for restarting syslog and using logger, and
skip the configuration test for systemd images which always fail
because syslog's systemd service doesn't read a config by default
(see YB#4860).

Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
---
 meta/lib/oeqa/runtime/syslog.py | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

Patch

diff --git a/meta/lib/oeqa/runtime/syslog.py b/meta/lib/oeqa/runtime/syslog.py
index cec4f97..5ff2962 100644
--- a/meta/lib/oeqa/runtime/syslog.py
+++ b/meta/lib/oeqa/runtime/syslog.py
@@ -14,24 +14,33 @@  class SyslogTest(oeRuntimeTest):
         self.assertEqual(status, 1, msg="status and output: %s and %s" % (status,output))
 
     @skipUnlessPassed("test_syslog_help")
-    def test_syslogd_running(self):
+    def test_syslog_running(self):
         (status,output) = self.target.run(oeRuntimeTest.pscmd + ' | grep -i [s]yslogd')
         self.assertEqual(status, 0, msg="no syslogd process, ps output: %s" % self.target.run(oeRuntimeTest.pscmd)[1])
 
+
 class SyslogTestConfig(oeRuntimeTest):
 
-    def setUp(self):
-        self.target.run('echo "LOGFILE=/var/log/test" >> /etc/syslog-startup.conf')
+    @skipUnlessPassed("test_syslog_running")
+    def test_syslog_logger(self):
+        (status,output) = self.target.run('logger foobar && grep foobar /var/log/messages')
+        self.assertEqual(status, 0, msg="Test log string not found in /var/log/messages. Output: %s " % output)
 
-    @skipUnlessPassed("test_syslogd_running")
-    def test_syslogd_configurable(self):
+    @skipUnlessPassed("test_syslog_running")
+    def test_syslog_restart(self):
         if "systemd" != oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager"):
             (status,output) = self.target.run('/etc/init.d/syslog restart')
         else:
             (status,output) = self.target.run('systemctl restart syslog.service')
+
+    @skipUnlessPassed("test_syslog_restart")
+    @skipUnlessPassed("test_syslog_logger")
+    @unittest.skipIf("systemd" == oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager"), "Not appropiate for systemd image")
+    def test_syslog_startup_config(self):
+        self.target.run('echo "LOGFILE=/var/log/test" >> /etc/syslog-startup.conf')
+        (status,output) = self.target.run('/etc/init.d/syslog restart')
         self.assertEqual(status, 0, msg="Could not restart syslog service. Status and output: %s and %s" % (status,output))
         (status,output) = self.target.run('logger foobar && grep foobar /var/log/test')
         self.assertEqual(status, 0, msg="Test log string not found. Output: %s " % output)
-
-    def tearDown(self):
         self.target.run("sed -i 's#LOGFILE=/var/log/test##' /etc/syslog-startup.conf")
+        self.target.run('/etc/init.d/syslog restart')