aboutsummaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorBenjamin Esquivel <benjamin.esquivel@linux.intel.com>2015-12-03 16:02:26 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-12-12 23:31:39 +0000
commitb411fec74f39d1efa7276046a32d6048b35dd199 (patch)
treedfc4eaefad4b92d8f19c4a481efdf42827c806bf /meta/lib
parent2d3a6d22e155911e39e4b7e323317f4a7cb1cb95 (diff)
downloadopenembedded-core-contrib-b411fec74f39d1efa7276046a32d6048b35dd199.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 Signed-off-by: Benjamin Esquivel <benjamin.esquivel@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/runtime/systemd.py28
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):
self.assertEqual(status, expected, message)
return output
+ #TODO: use pyjournalctl instead
+ def journalctl(self, args='',l_match_units=[]):
+ """
+ Request for the journalctl output to the current target system
+
+ Arguments:
+ -args, an optional argument pass through argument
+ -l_match_units, an optional list of units to filter the output
+ Returns:
+ -string output of the journalctl command
+ Raises:
+ -AssertionError, on remote commands that fail
+ -ValueError, on a journalctl call with filtering by l_match_units that
+ returned no entries
+ """
+ query_units=""
+ if len(l_match_units):
+ query_units = ['_SYSTEMD_UNIT='+unit for unit in l_match_units]
+ query_units = " ".join(query_units)
+ command = 'journalctl %s %s' %(args, query_units)
+ status, output = self.target.run(command)
+ if status:
+ raise AssertionError("Command '%s' returned non-zero exit \
+ code %d:\n%s" % (command, status, output))
+ if len(output) == 1 and "-- No entries --" in output:
+ raise ValueError("List of units to match: %s, returned no entries"
+ % l_match_units)
+ return output
class SystemdBasicTests(SystemdTest):