diff options
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 | ||