summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/runtime_cases/syslog.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/runtime_cases/syslog.py')
-rw-r--r--meta/lib/oeqa/runtime_cases/syslog.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/meta/lib/oeqa/runtime_cases/syslog.py b/meta/lib/oeqa/runtime_cases/syslog.py
new file mode 100644
index 0000000000..8f550329e7
--- /dev/null
+++ b/meta/lib/oeqa/runtime_cases/syslog.py
@@ -0,0 +1,52 @@
1import 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 def test_syslog_running(self):
13 (status,output) = self.target.run(oeRuntimeTest.pscmd + ' | grep -i [s]yslogd')
14 self.assertEqual(status, 0, msg="no syslogd process, ps output: %s" % self.target.run(oeRuntimeTest.pscmd)[1])
15
16class SyslogTestConfig(oeRuntimeTest):
17
18 @testcase(1149)
19 @skipUnlessPassed("test_syslog_running")
20 def test_syslog_logger(self):
21 (status, output) = self.target.run('logger foobar')
22 self.assertEqual(status, 0, msg="Can't log into syslog. Output: %s " % output)
23
24 (status, output) = self.target.run('grep foobar /var/log/messages')
25 if status != 0:
26 if oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager", "") == "systemd":
27 (status, output) = self.target.run('journalctl -o cat | grep foobar')
28 else:
29 (status, output) = self.target.run('logread | grep foobar')
30 self.assertEqual(status, 0, msg="Test log string not found in /var/log/messages or logread. Output: %s " % output)
31
32 @testcase(1150)
33 @skipUnlessPassed("test_syslog_running")
34 def test_syslog_restart(self):
35 if "systemd" != oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager", False):
36 (status,output) = self.target.run('/etc/init.d/syslog restart')
37 else:
38 (status,output) = self.target.run('systemctl restart syslog.service')
39
40 @testcase(202)
41 @skipUnlessPassed("test_syslog_restart")
42 @skipUnlessPassed("test_syslog_logger")
43 @unittest.skipIf("systemd" == oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager", False), "Not appropiate for systemd image")
44 @unittest.skipIf(oeRuntimeTest.hasPackage("sysklogd") or not oeRuntimeTest.hasPackage("busybox"), "Non-busybox syslog")
45 def test_syslog_startup_config(self):
46 self.target.run('echo "LOGFILE=/var/log/test" >> /etc/syslog-startup.conf')
47 (status,output) = self.target.run('/etc/init.d/syslog restart')
48 self.assertEqual(status, 0, msg="Could not restart syslog service. Status and output: %s and %s" % (status,output))
49 (status,output) = self.target.run('logger foobar && grep foobar /var/log/test')
50 self.assertEqual(status, 0, msg="Test log string not found. Output: %s " % output)
51 self.target.run("sed -i 's#LOGFILE=/var/log/test##' /etc/syslog-startup.conf")
52 self.target.run('/etc/init.d/syslog restart')