diff options
Diffstat (limited to 'meta/lib/oeqa/runtime/cases/syslog.py')
| -rw-r--r-- | meta/lib/oeqa/runtime/cases/syslog.py | 57 |
1 files changed, 57 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..1016e67e93 --- /dev/null +++ b/meta/lib/oeqa/runtime/cases/syslog.py | |||
| @@ -0,0 +1,57 @@ | |||
| 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(['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(202) | ||
| 38 | @OETestDepends(['syslog.SyslogTestConfig.test_syslog_logger']) | ||
| 39 | @OEHasPackage(["!sysklogd", "busybox"]) | ||
| 40 | @skipIfDataVar('VIRTUAL-RUNTIME_init_manager', 'systemd', | ||
| 41 | 'Not appropiate for systemd image') | ||
| 42 | def test_syslog_startup_config(self): | ||
| 43 | cmd = 'echo "LOGFILE=/var/log/test" >> /etc/syslog-startup.conf' | ||
| 44 | self.target.run(cmd) | ||
| 45 | status, output = self.target.run('/etc/init.d/syslog restart') | ||
| 46 | msg = ('Could not restart syslog service. Status and output:' | ||
| 47 | ' %s and %s' % (status,output)) | ||
| 48 | self.assertEqual(status, 0, msg) | ||
| 49 | |||
| 50 | cmd = 'logger foobar && grep foobar /var/log/test' | ||
| 51 | status,output = self.target.run(cmd) | ||
| 52 | msg = 'Test log string not found. Output: %s ' % output | ||
| 53 | self.assertEqual(status, 0, msg=msg) | ||
| 54 | |||
| 55 | cmd = "sed -i 's#LOGFILE=/var/log/test##' /etc/syslog-startup.conf" | ||
| 56 | self.target.run(cmd) | ||
| 57 | self.target.run('/etc/init.d/syslog restart') | ||
