Get dumps when qemu fails
cover Get dumps when qemu fails
From: Mariano Lopez <[email protected]>
This provides classes for dump logs from the host and the target. This way it's easier to get dumps from the runner or the target and not just from the test. With this now the qemurunner instance get the dumps from the host when qemu fails.
This also allows to have datastore vars in the commands and removes the special case commands.
This depends on:
http://lists.openembedded.org/pipermail/openembedded-core/2015-August/108912.html
[YOCTO #8118]
Mariano Lopez (3):
dump: Created new classes for dump host and target
qemurunner: Added host dumps when there are errors
dump: allow to have datastore vars on dump commands
meta/classes/testimage.bbclass | 14 +++++-- meta/lib/oeqa/oetest.py | 52 +++-------------------- meta/lib/oeqa/targetcontrol.py | 16 +++---- meta/lib/oeqa/utils/dump.py | 88 +++++++++++++++++++++++++++++++++++++++ meta/lib/oeqa/utils/qemurunner.py | 15 ++++++- 5 files changed, 127 insertions(+), 58 deletions(-) create mode 100644 meta/lib/oeqa/utils/dump.py
Signature · 1 line
1.8.4.5
PATCH 1/3 dump: Created new classes for dump host and target
From: Mariano Lopez <[email protected]>
It makes sense to separate the dump commands from the oeRuntimeTest class, this way it can be used in all the test context.
These are the changes included in this patch:
- Created classes: BaseDumper, HostDumper, TargetDumper
- Create an instance of HostDumper in imagetest.bbclass and add it to TestContext class, this way any class that have access to the TestContext would be able to dump logs from the host
- Create an instance of TargetDumper in QemuTarget class after get the runner, this way it is accessible during the tests.
[YOCTO #8118]
--- meta/classes/testimage.bbclass | 5 +++ meta/lib/oeqa/oetest.py | 52 ++++------------------------ meta/lib/oeqa/targetcontrol.py | 6 ++-- meta/lib/oeqa/utils/dump.py | 77 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 91 insertions(+), 49 deletions(-) create mode 100644 meta/lib/oeqa/utils/dump.py
meta/classes/testimage.bbclass +5 -0
@@ -231,6 +231,7 @@ def testimage_main(d): import time from oeqa.oetest import loadTests, runTests from oeqa.targetcontrol import get_target_controller + from oeqa.utils.dump import get_host_dumper pn = d.getVar("PN", True) export = oe.utils.conditional("TEST_EXPORT_ONLY", "1", True, False, d)
@@ -245,6 +246,9 @@ def testimage_main(d): testslist = get_tests_list(d) testsrequired = [t for t in d.getVar("TEST_SUITES", True).split() if t != "auto"] + # we need the host dumper in test context + host_dumper = get_host_dumper(d) + # the robot dance target = get_target_controller(d)
@@ -255,6 +259,7 @@ def testimage_main(d): self.testsrequired = testsrequired self.filesdir = os.path.join(os.path.dirname(os.path.abspath(oeqa.runtime.__file__)),"files") self.target = target + self.host_dumper = host_dumper self.imagefeatures = d.getVar("IMAGE_FEATURES", True).split() self.distrofeatures = d.getVar("DISTRO_FEATURES", True).split() manifest = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("IMAGE_LINK_NAME", True) + ".manifest")
meta/lib/oeqa/oetest.py +6 -46
65 lines not on this page · raw message
meta/lib/oeqa/targetcontrol.py +3 -3
@@ -14,6 +14,7 @@ import logging from oeqa.utils.sshcontrol import SSHControl from oeqa.utils.qemurunner import QemuRunner from oeqa.utils.qemutinyrunner import QemuTinyRunner +from oeqa.utils.dump import TargetDumper from oeqa.controllers.testtargetloader import TestTargetLoader from abc import ABCMeta, abstractmethod
@@ -123,9 +124,6 @@ class QemuTarget(BaseTarget): self.origrootfs = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("IMAGE_LINK_NAME", True) + '.' + self.image_fstype) self.rootfs = os.path.join(self.testdir, d.getVar("IMAGE_LINK_NAME", True) + '-testimage.' + self.image_fstype) self.kernel = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("KERNEL_IMAGETYPE", False) + '-' + d.getVar('MACHINE', False) + '.bin') - self.dump_target = d.getVar("testimage_dump_target", True) - self.dump_host = d.getVar("testimage_dump_host", True) - self.dump_dir = d.getVar("TESTIMAGE_DUMP_DIR", True) # Log QemuRunner log output to a file import oe.path
@@ -155,6 +153,8 @@ class QemuTarget(BaseTarget): logfile = self.qemulog, boottime = int(d.getVar("TEST_QEMUBOOT_TIMEOUT", True))) + self.target_dumper = TargetDumper(d, self.runner) + def deploy(self): try: bb.utils.mkdirhier(self.testdir)
meta/lib/oeqa/utils/dump.py new file +77 -0
77 lines not on this page · raw message
Signature · 1 line
1.8.4.5
PATCH 2/3 qemurunner: Added host dumps when there are errors
In reply to [email protected]From: Mariano Lopez <[email protected]>
This adds an instance of HostDumper to qemurunner, with this instance now is possible to get dumps from the host when there is an error.
This also adds dump points in the next cases:
- runqemu exits before seeing qemu pid
- Fail to get qemu process arguments
- Not reach login banner before timeout
- qemu pid never appears
[YOCTO #8118]
--- meta/classes/testimage.bbclass | 2 +- meta/lib/oeqa/targetcontrol.py | 10 ++++++---- meta/lib/oeqa/utils/qemurunner.py | 15 +++++++++++++-- 3 files changed, 20 insertions(+), 7 deletions(-)
meta/classes/testimage.bbclass +1 -1
@@ -250,7 +250,7 @@ def testimage_main(d): host_dumper = get_host_dumper(d) # the robot dance - target = get_target_controller(d) + target = get_target_controller(d, host_dumper) class TestContext(object): def __init__(self):
meta/lib/oeqa/targetcontrol.py +6 -4
@@ -18,11 +18,11 @@ from oeqa.utils.dump import TargetDumper from oeqa.controllers.testtargetloader import TestTargetLoader from abc import ABCMeta, abstractmethod -def get_target_controller(d): +def get_target_controller(d, host_dumper): testtarget = d.getVar("TEST_TARGET", True) # old, simple names if testtarget == "qemu": - return QemuTarget(d) + return QemuTarget(d, host_dumper) elif testtarget == "simpleremote": return SimpleRemoteTarget(d) else:
@@ -115,7 +115,7 @@ class QemuTarget(BaseTarget): supported_image_fstypes = ['ext3', 'ext4', 'cpio.gz'] - def __init__(self, d): + def __init__(self, d, host_dumper): super(QemuTarget, self).__init__(d)
@@ -124,6 +124,7 @@ class QemuTarget(BaseTarget): self.origrootfs = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("IMAGE_LINK_NAME", True) + '.' + self.image_fstype) self.rootfs = os.path.join(self.testdir, d.getVar("IMAGE_LINK_NAME", True) + '-testimage.' + self.image_fstype) self.kernel = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("KERNEL_IMAGETYPE", False) + '-' + d.getVar('MACHINE', False) + '.bin') + self.host_dumper = host_dumper # Log QemuRunner log output to a file import oe.path
@@ -151,7 +152,8 @@ class QemuTarget(BaseTarget): deploy_dir_image = d.getVar("DEPLOY_DIR_IMAGE", True), display = d.getVar("BB_ORIGENV", False).getVar("DISPLAY", True), logfile = self.qemulog, - boottime = int(d.getVar("TEST_QEMUBOOT_TIMEOUT", True))) + boottime = int(d.getVar("TEST_QEMUBOOT_TIMEOUT", True)), + host_dumper = self.host_dumper) self.target_dumper = TargetDumper(d, self.runner)
meta/lib/oeqa/utils/qemurunner.py +13 -2
@@ -19,7 +19,7 @@ logger = logging.getLogger("BitBake.QemuRunner") class QemuRunner: - def __init__(self, machine, rootfs, display, tmpdir, deploy_dir_image, logfile, boottime): + def __init__(self, machine, rootfs, display, tmpdir, deploy_dir_image, logfile, boottime, host_dumper): # Popen object for runqemu self.runqemu = None
@@ -37,8 +37,9 @@ class QemuRunner: self.deploy_dir_image = deploy_dir_image self.logfile = logfile self.boottime = boottime - self.logged = False + self.host_dumper = host_dumper + self.logged = False self.runqemutime = 60 def create_socket(self):
@@ -117,6 +118,7 @@ class QemuRunner: if self.runqemu.returncode: # No point waiting any longer logger.info('runqemu exited with code %d' % self.runqemu.returncode) + self._dump_host() self.stop() logger.info("Output from runqemu:\n%s" % getOutput(output)) return False
@@ -136,6 +138,7 @@ class QemuRunner: self.server_ip = ips[1] except IndexError, ValueError: logger.info("Couldn't get ip from qemu process arguments! Here is the qemu command line used:\n%s\nand output from runqemu:\n%s" % (cmdline, getOutput(output))) + self._dump_host() self.stop() return False logger.info("Target IP: %s" % self.ip)
@@ -174,6 +177,7 @@ class QemuRunner: lines = "\n".join(self.bootlog.splitlines()[-25:]) logger.info("Last 25 lines of text:\n%s" % lines) logger.info("Check full boot log: %s" % self.logfile) + self._dump_host() self.stop() return False
@@ -187,6 +191,7 @@ class QemuRunner: else: logger.info("Qemu pid didn't appeared in %s seconds" % self.runqemutime) + self._dump_host() self.stop() logger.info("Output from runqemu:\n%s" % getOutput(output)) return False
@@ -312,3 +317,9 @@ class QemuRunner: if (status_cmd == "0"): status = 1 return (status, str(data)) + + def _dump_host(self): + self.host_dumper.create_dir("qemu") + logger.error("Qemu ended unexpectedly, dump data from host" + " is in %s" % self.host_dumper.dump_dir) + self.host_dumper.dump_host()
Signature · 1 line
1.8.4.5
PATCH 3/3 dump: allow to have datastore vars on dump commands
In reply to [email protected]From: Mariano Lopez <[email protected]>
This allows to have datastore variables in the dump commands and will get the data when a new instance it's created.
Also this remove special cases from the commands.
[YOCTO #8118]
--- meta/classes/testimage.bbclass | 7 +++++-- meta/lib/oeqa/utils/dump.py | 43 ++++++++++++++++++++++++++---------------- 2 files changed, 32 insertions(+), 18 deletions(-)
meta/classes/testimage.bbclass +5 -2
@@ -63,11 +63,14 @@ testimage_dump_target () { ps free df - _ping + # The next command will export the default gateway IP + export DEFAULT_GATEWAY=$(ip route | awk '/default/ { print $3}') + ping -c3 $DEFAULT_GATEWAY dmesg netstat -an ip address - _logs + # Next command will dump logs from /var/log/ + find /var/log/ -type f 2>/dev/null -exec echo "====================" \; -exec echo {} \; -exec echo "====================" \; -exec cat {} \; -exec echo "" \; } testimage_dump_host () {
meta/lib/oeqa/utils/dump.py +27 -16
75 lines not on this page · raw message
Signature · 1 line
1.8.4.5