diff options
author | Aníbal Limón <anibal.limon@linux.intel.com> | 2017-01-31 15:05:54 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-01-31 23:27:47 +0000 |
commit | 90b4e075f4e0c180f4e52e29c4443c6294687363 (patch) | |
tree | 5b2c13a30d3fa937b95d522d37d47b43821767fb /meta/lib/oeqa/runtime/cases/oe_syslog.py | |
parent | 3eef8f7955d09063b1ebfd7ea5cc74ee67fcc4a2 (diff) | |
download | poky-90b4e075f4e0c180f4e52e29c4443c6294687363.tar.gz |
oeqa/runtime/cases: Rename syslog module to oe_syslog
Debian based distros has a builtin syslog module so when
try to load tests using unittest it references the builtin
module instead of runtime/cases.
[YOCTO #10964]
(From OE-Core rev: 9923e3cdb58c2b3c54ec5fe99b2cec4cdc9fff92)
Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/runtime/cases/oe_syslog.py')
-rw-r--r-- | meta/lib/oeqa/runtime/cases/oe_syslog.py | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/meta/lib/oeqa/runtime/cases/oe_syslog.py b/meta/lib/oeqa/runtime/cases/oe_syslog.py new file mode 100644 index 0000000000..005b6978d9 --- /dev/null +++ b/meta/lib/oeqa/runtime/cases/oe_syslog.py | |||
@@ -0,0 +1,66 @@ | |||
1 | from oeqa.runtime.case import OERuntimeTestCase | ||
2 | from oeqa.core.decorator.depends import OETestDepends | ||
3 | from oeqa.core.decorator.oeid import OETestID | ||
4 | from oeqa.core.decorator.data import skipIfDataVar | ||
5 | from oeqa.runtime.decorator.package import OEHasPackage | ||
6 | |||
7 | class SyslogTest(OERuntimeTestCase): | ||
8 | |||
9 | @OETestID(201) | ||
10 | @OETestDepends(['ssh.SSHTest.test_ssh']) | ||
11 | @OEHasPackage(["busybox-syslog", "sysklogd"]) | ||
12 | def test_syslog_running(self): | ||
13 | cmd = '%s | grep -i [s]yslogd' % self.tc.target_cmds['ps'] | ||
14 | status, output = self.target.run(cmd) | ||
15 | msg = "No syslogd process; ps output: %s" % output | ||
16 | self.assertEqual(status, 0, msg=msg) | ||
17 | |||
18 | class SyslogTestConfig(OERuntimeTestCase): | ||
19 | |||
20 | @OETestID(1149) | ||
21 | @OETestDepends(['oe_syslog.SyslogTest.test_syslog_running']) | ||
22 | def test_syslog_logger(self): | ||
23 | status, output = self.target.run('logger foobar') | ||
24 | msg = "Can't log into syslog. Output: %s " % output | ||
25 | self.assertEqual(status, 0, msg=msg) | ||
26 | |||
27 | status, output = self.target.run('grep foobar /var/log/messages') | ||
28 | if status != 0: | ||
29 | if self.tc.td.get("VIRTUAL-RUNTIME_init_manager") == "systemd": | ||
30 | status, output = self.target.run('journalctl -o cat | grep foobar') | ||
31 | else: | ||
32 | status, output = self.target.run('logread | grep foobar') | ||
33 | msg = ('Test log string not found in /var/log/messages or logread.' | ||
34 | ' Output: %s ' % output) | ||
35 | self.assertEqual(status, 0, msg=msg) | ||
36 | |||
37 | @OETestID(1150) | ||
38 | @OETestDepends(['oe_syslog.SyslogTest.test_syslog_running']) | ||
39 | def test_syslog_restart(self): | ||
40 | if "systemd" != self.tc.td.get("VIRTUAL-RUNTIME_init_manager", ""): | ||
41 | (_, _) = self.target.run('/etc/init.d/syslog restart') | ||
42 | else: | ||
43 | (_, _) = self.target.run('systemctl restart syslog.service') | ||
44 | |||
45 | |||
46 | @OETestID(202) | ||
47 | @OETestDepends(['oe_syslog.SyslogTestConfig.test_syslog_logger']) | ||
48 | @OEHasPackage(["!sysklogd", "busybox"]) | ||
49 | @skipIfDataVar('VIRTUAL-RUNTIME_init_manager', 'systemd', | ||
50 | 'Not appropiate for systemd image') | ||
51 | def test_syslog_startup_config(self): | ||
52 | cmd = 'echo "LOGFILE=/var/log/test" >> /etc/syslog-startup.conf' | ||
53 | self.target.run(cmd) | ||
54 | status, output = self.target.run('/etc/init.d/syslog restart') | ||
55 | msg = ('Could not restart syslog service. Status and output:' | ||
56 | ' %s and %s' % (status,output)) | ||
57 | self.assertEqual(status, 0, msg) | ||
58 | |||
59 | cmd = 'logger foobar && grep foobar /var/log/test' | ||
60 | status,output = self.target.run(cmd) | ||
61 | msg = 'Test log string not found. Output: %s ' % output | ||
62 | self.assertEqual(status, 0, msg=msg) | ||
63 | |||
64 | cmd = "sed -i 's#LOGFILE=/var/log/test##' /etc/syslog-startup.conf" | ||
65 | self.target.run(cmd) | ||
66 | self.target.run('/etc/init.d/syslog restart') | ||