diff options
author | Benjamin Esquivel <benjamin.esquivel@linux.intel.com> | 2015-12-03 16:02:27 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-12-12 23:31:40 +0000 |
commit | 59c6c13a8fa1bfc8e0615463e00ccdef04a87a47 (patch) | |
tree | fffddf884a4d49690d0ef58ebee6f603d76d6a20 | |
parent | b411fec74f39d1efa7276046a32d6048b35dd199 (diff) | |
download | openembedded-core-59c6c13a8fa1bfc8e0615463e00ccdef04a87a47.tar.gz openembedded-core-59c6c13a8fa1bfc8e0615463e00ccdef04a87a47.tar.bz2 openembedded-core-59c6c13a8fa1bfc8e0615463e00ccdef04a87a47.zip |
oeqa/systemd: get runtest target boot time and log
oeqa.runtime.systemd.SystemdJournalTests.test_systemd_boot_time
this test will query the target boot time from journactl and will
print it to the output, if the time is obtained, the test passes
it then compares the boot time against the default systemd's
timeout TimeoutStartSec and if the boot time is greater than the
it will print it too
this test prints the startup time in the test log like:
...
test_systemd_boot_time (oeqa.runtime.systemd.SystemdJournalTests) ...
Startup finished in 6.922s (kernel) + 52.089s (userspace) = 59.011s.
Signed-off-by: Benjamin Esquivel <benjamin.esquivel@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
-rw-r--r-- | meta/lib/oeqa/runtime/systemd.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/meta/lib/oeqa/runtime/systemd.py b/meta/lib/oeqa/runtime/systemd.py index d0b9b2f4b9..03c56ef9f0 100644 --- a/meta/lib/oeqa/runtime/systemd.py +++ b/meta/lib/oeqa/runtime/systemd.py @@ -127,3 +127,50 @@ class SystemdJournalTests(SystemdTest): def test_systemd_journal(self): (status, output) = self.target.run('journalctl') self.assertEqual(status, 0, output) + + @skipUnlessPassed('test_systemd_basic') + def test_systemd_boot_time(self, systemd_TimeoutStartSec=90): + """ + Get the target boot time from journalctl and log it + + Arguments: + -systemd_TimeoutStartSec, an optional argument containing systemd's + unit start timeout to compare against + """ + + # the expression chain that uniquely identifies the time boot message + expr_items=["Startup finished","kernel", "userspace","\.$"] + try: + output = self.journalctl(args="-o cat --reverse") + except AssertionError: + self.fail("Error occurred while calling journalctl") + if not len(output): + self.fail("Error: unable to obtain the startup time from\ + systemd journal") + + # check for the regular expression items that match the startup time + for line in output.split('\n'): + check_match = "".join(re.findall(".*".join(expr_items), line)) + if check_match: break + # put the startup time in the test log + if check_match: + print "%s" % check_match + else: + self.fail("Error while obtaining the boot time from journalctl") + boot_time_sec = 0 + + # get the numeric values from the string and convert them to seconds + # same data will be placed in list and string for manipulation + l_boot_time = check_match.split(" ")[-2:] + s_boot_time = " ".join(l_boot_time) + # Obtain the minutes it took to boot + if l_boot_time[0].endswith('min') and l_boot_time[0][0].isdigit(): + boot_time_min = s_boot_time.split("min")[0] + # convert to seconds and accumulate it + boot_time_sec += int(boot_time_min) * 60 + # Obtain the seconds it took to boot and accumulate + boot_time_sec += float(l_boot_time[1].split("s")[0]) + #Assert the target boot time against systemd's unit start timeout + if boot_time_sec > systemd_TimeoutStartSec: + print "Target boot time %s exceeds systemd's TimeoutStartSec %s"\ + %(boot_time_sec, systemd_TimeoutStartSec) |