blob: 2601dd9ea8985d02b04ae8d548534d14abc45981 [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("busybox-syslog") or oeRuntimeTest.hasPackage("sysklogd")):
7 skipModule("No syslog package in image")
8
9class SyslogTest(oeRuntimeTest):
10
11 @testcase(201)
12 @skipUnlessPassed("test_syslog_help")
13 def test_syslog_running(self):
14 (status,output) = self.target.run(oeRuntimeTest.pscmd + ' | grep -i [s]yslogd')
15 self.assertEqual(status, 0, msg="no syslogd process, ps output: %s" % self.target.run(oeRuntimeTest.pscmd)[1])
16
17class SyslogTestConfig(oeRuntimeTest):
18
19 @testcase(1149)
20 @skipUnlessPassed("test_syslog_running")
21 def test_syslog_logger(self):
22 (status,output) = self.target.run('logger foobar && test -e /var/log/messages && grep foobar /var/log/messages || logread | grep foobar')
23 self.assertEqual(status, 0, msg="Test log string not found in /var/log/messages. Output: %s " % output)
24
25 @testcase(1150)
26 @skipUnlessPassed("test_syslog_running")
27 def test_syslog_restart(self):
28 if "systemd" != oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager", False):
29 (status,output) = self.target.run('/etc/init.d/syslog restart')
30 else:
31 (status,output) = self.target.run('systemctl restart syslog.service')
32
33 @testcase(202)
34 @skipUnlessPassed("test_syslog_restart")
35 @skipUnlessPassed("test_syslog_logger")
36 @unittest.skipIf("systemd" == oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager", False), "Not appropiate for systemd image")
37 @unittest.skipIf(oeRuntimeTest.hasPackage("sysklogd") or not oeRuntimeTest.hasPackage("busybox"), "Non-busybox syslog")
38 def test_syslog_startup_config(self):
39 self.target.run('echo "LOGFILE=/var/log/test" >> /etc/syslog-startup.conf')
40 (status,output) = self.target.run('/etc/init.d/syslog restart')
41 self.assertEqual(status, 0, msg="Could not restart syslog service. Status and output: %s and %s" % (status,output))
42 (status,output) = self.target.run('logger foobar && grep foobar /var/log/test')
43 self.assertEqual(status, 0, msg="Test log string not found. Output: %s " % output)
44 self.target.run("sed -i 's#LOGFILE=/var/log/test##' /etc/syslog-startup.conf")
45 self.target.run('/etc/init.d/syslog restart')