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:42:51 +0000 |
commit | 23083e7e5e3a8ee81b346b2ee6084d9fc83e66b5 (patch) | |
tree | fd4fbdfc900949e2bf069955ed4d02c2034904d7 /meta/lib | |
parent | c6330a2783d80444b30d8fce4946fdb247c774f8 (diff) | |
download | poky-23083e7e5e3a8ee81b346b2ee6084d9fc83e66b5.tar.gz |
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.
(From OE-Core rev: 59c6c13a8fa1bfc8e0615463e00ccdef04a87a47)
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')
-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): | |||
127 | def test_systemd_journal(self): | 127 | def test_systemd_journal(self): |
128 | (status, output) = self.target.run('journalctl') | 128 | (status, output) = self.target.run('journalctl') |
129 | self.assertEqual(status, 0, output) | 129 | self.assertEqual(status, 0, output) |
130 | |||
131 | @skipUnlessPassed('test_systemd_basic') | ||
132 | def test_systemd_boot_time(self, systemd_TimeoutStartSec=90): | ||
133 | """ | ||
134 | Get the target boot time from journalctl and log it | ||
135 | |||
136 | Arguments: | ||
137 | -systemd_TimeoutStartSec, an optional argument containing systemd's | ||
138 | unit start timeout to compare against | ||
139 | """ | ||
140 | |||
141 | # the expression chain that uniquely identifies the time boot message | ||
142 | expr_items=["Startup finished","kernel", "userspace","\.$"] | ||
143 | try: | ||
144 | output = self.journalctl(args="-o cat --reverse") | ||
145 | except AssertionError: | ||
146 | self.fail("Error occurred while calling journalctl") | ||
147 | if not len(output): | ||
148 | self.fail("Error: unable to obtain the startup time from\ | ||
149 | systemd journal") | ||
150 | |||
151 | # check for the regular expression items that match the startup time | ||
152 | for line in output.split('\n'): | ||
153 | check_match = "".join(re.findall(".*".join(expr_items), line)) | ||
154 | if check_match: break | ||
155 | # put the startup time in the test log | ||
156 | if check_match: | ||
157 | print "%s" % check_match | ||
158 | else: | ||
159 | self.fail("Error while obtaining the boot time from journalctl") | ||
160 | boot_time_sec = 0 | ||
161 | |||
162 | # get the numeric values from the string and convert them to seconds | ||
163 | # same data will be placed in list and string for manipulation | ||
164 | l_boot_time = check_match.split(" ")[-2:] | ||
165 | s_boot_time = " ".join(l_boot_time) | ||
166 | # Obtain the minutes it took to boot | ||
167 | if l_boot_time[0].endswith('min') and l_boot_time[0][0].isdigit(): | ||
168 | boot_time_min = s_boot_time.split("min")[0] | ||
169 | # convert to seconds and accumulate it | ||
170 | boot_time_sec += int(boot_time_min) * 60 | ||
171 | # Obtain the seconds it took to boot and accumulate | ||
172 | boot_time_sec += float(l_boot_time[1].split("s")[0]) | ||
173 | #Assert the target boot time against systemd's unit start timeout | ||
174 | if boot_time_sec > systemd_TimeoutStartSec: | ||
175 | print "Target boot time %s exceeds systemd's TimeoutStartSec %s"\ | ||
176 | %(boot_time_sec, systemd_TimeoutStartSec) | ||