diff options
author | Benjamin Esquivel <benjamin.esquivel@linux.intel.com> | 2015-12-03 16:02:26 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-12-12 23:42:51 +0000 |
commit | c6330a2783d80444b30d8fce4946fdb247c774f8 (patch) | |
tree | b1918722fc4cf2e099f624f1611831803a27a72c /meta/lib/oeqa | |
parent | 220a78b47e2e707e9e5364cd3d96a247c124b283 (diff) | |
download | poky-c6330a2783d80444b30d8fce4946fdb247c774f8.tar.gz |
oeqa/systemd: journalctl helper function
a function to request for the journalctl output to the current target
system with l_match_units support
(From OE-Core rev: b411fec74f39d1efa7276046a32d6048b35dd199)
Signed-off-by: Benjamin Esquivel <benjamin.esquivel@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa')
-rw-r--r-- | meta/lib/oeqa/runtime/systemd.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/meta/lib/oeqa/runtime/systemd.py b/meta/lib/oeqa/runtime/systemd.py index c74394ca54..d0b9b2f4b9 100644 --- a/meta/lib/oeqa/runtime/systemd.py +++ b/meta/lib/oeqa/runtime/systemd.py | |||
@@ -21,6 +21,34 @@ class SystemdTest(oeRuntimeTest): | |||
21 | self.assertEqual(status, expected, message) | 21 | self.assertEqual(status, expected, message) |
22 | return output | 22 | return output |
23 | 23 | ||
24 | #TODO: use pyjournalctl instead | ||
25 | def journalctl(self, args='',l_match_units=[]): | ||
26 | """ | ||
27 | Request for the journalctl output to the current target system | ||
28 | |||
29 | Arguments: | ||
30 | -args, an optional argument pass through argument | ||
31 | -l_match_units, an optional list of units to filter the output | ||
32 | Returns: | ||
33 | -string output of the journalctl command | ||
34 | Raises: | ||
35 | -AssertionError, on remote commands that fail | ||
36 | -ValueError, on a journalctl call with filtering by l_match_units that | ||
37 | returned no entries | ||
38 | """ | ||
39 | query_units="" | ||
40 | if len(l_match_units): | ||
41 | query_units = ['_SYSTEMD_UNIT='+unit for unit in l_match_units] | ||
42 | query_units = " ".join(query_units) | ||
43 | command = 'journalctl %s %s' %(args, query_units) | ||
44 | status, output = self.target.run(command) | ||
45 | if status: | ||
46 | raise AssertionError("Command '%s' returned non-zero exit \ | ||
47 | code %d:\n%s" % (command, status, output)) | ||
48 | if len(output) == 1 and "-- No entries --" in output: | ||
49 | raise ValueError("List of units to match: %s, returned no entries" | ||
50 | % l_match_units) | ||
51 | return output | ||
24 | 52 | ||
25 | class SystemdBasicTests(SystemdTest): | 53 | class SystemdBasicTests(SystemdTest): |
26 | 54 | ||