diff options
author | Sakib Sajal <sakib.sajal@windriver.com> | 2021-06-08 10:57:34 -0400 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-06-12 08:38:29 +0100 |
commit | b44849c32c87fbb8c5a465ecc29a6182e6781d78 (patch) | |
tree | 686d7be75b3d89df1634c2435ac8678037d44569 /meta | |
parent | a71c3b390dc5d1de9047bbea8557f8939a7a8141 (diff) | |
download | poky-b44849c32c87fbb8c5a465ecc29a6182e6781d78.tar.gz |
oeqa/core/target/qemu.py: display contents of dumped files
During do_testimage, if the target is not started within a certain
timeout, TEST_QEMUBOOT_TIMEOUT, host data is dumped to files for
each command in
${TMPDIR}/log/runtime-hostdump/<datetime>_qemu/host_<seq>_<command>.
Display the first 20 lines of top output and the last 20 lines of
bootlog to standard output for more context for the target not being
started up.
(From OE-Core rev: 441390b707bf681bc308c9ebd45ea2ae20c37d7c)
Signed-off-by: Sakib Sajal <sakib.sajal@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/lib/oeqa/core/target/qemu.py | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/meta/lib/oeqa/core/target/qemu.py b/meta/lib/oeqa/core/target/qemu.py index 4a5df4a9a8..79fd724f7d 100644 --- a/meta/lib/oeqa/core/target/qemu.py +++ b/meta/lib/oeqa/core/target/qemu.py | |||
@@ -8,6 +8,8 @@ import os | |||
8 | import sys | 8 | import sys |
9 | import signal | 9 | import signal |
10 | import time | 10 | import time |
11 | import glob | ||
12 | import subprocess | ||
11 | from collections import defaultdict | 13 | from collections import defaultdict |
12 | 14 | ||
13 | from .ssh import OESSHTarget | 15 | from .ssh import OESSHTarget |
@@ -36,6 +38,8 @@ class OEQemuTarget(OESSHTarget): | |||
36 | self.ovmf = ovmf | 38 | self.ovmf = ovmf |
37 | self.use_slirp = slirp | 39 | self.use_slirp = slirp |
38 | self.boot_patterns = boot_patterns | 40 | self.boot_patterns = boot_patterns |
41 | self.dump_dir = dump_dir | ||
42 | self.bootlog = bootlog | ||
39 | 43 | ||
40 | self.runner = QemuRunner(machine=machine, rootfs=rootfs, tmpdir=tmpdir, | 44 | self.runner = QemuRunner(machine=machine, rootfs=rootfs, tmpdir=tmpdir, |
41 | deploy_dir_image=dir_image, display=display, | 45 | deploy_dir_image=dir_image, display=display, |
@@ -74,7 +78,28 @@ class OEQemuTarget(OESSHTarget): | |||
74 | self.server_ip = self.runner.server_ip | 78 | self.server_ip = self.runner.server_ip |
75 | else: | 79 | else: |
76 | self.stop() | 80 | self.stop() |
77 | raise RuntimeError("FAILED to start qemu - check the task log and the boot log") | 81 | # Display the first 20 lines of top and |
82 | # last 20 lines of the bootlog when the | ||
83 | # target is not being booted up. | ||
84 | topfile = glob.glob(self.dump_dir + "/*_qemu/host_*_top") | ||
85 | msg = "\n\n===== start: snippet =====\n\n" | ||
86 | for f in topfile: | ||
87 | msg += "file: %s\n\n" % f | ||
88 | with open(f) as tf: | ||
89 | for x in range(20): | ||
90 | msg += next(tf) | ||
91 | msg += "\n\n===== end: snippet =====\n\n" | ||
92 | blcmd = ["tail", "-20", self.bootlog] | ||
93 | msg += "===== start: snippet =====\n\n" | ||
94 | try: | ||
95 | out = subprocess.check_output(blcmd, stderr=subprocess.STDOUT, timeout=1).decode('utf-8') | ||
96 | msg += "file: %s\n\n" % self.bootlog | ||
97 | msg += out | ||
98 | except (subprocess.CalledProcessError, subprocess.TimeoutExpired, FileNotFoundError) as err: | ||
99 | msg += "Error running command: %s\n%s\n" % (blcmd, err) | ||
100 | msg += "\n\n===== end: snippet =====\n" | ||
101 | |||
102 | raise RuntimeError("FAILED to start qemu - check the task log and the boot log %s" % (msg)) | ||
78 | 103 | ||
79 | def stop(self): | 104 | def stop(self): |
80 | self.runner.stop() | 105 | self.runner.stop() |