Skip to contentSkip to conversation

runqemu: add selftest and fixes

PATCH Superseded Robert Yang 2 participants 9 messages Mar 16, 2017 – Mar 20, 2017

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover runqemu: add selftest and fixes

The following changes since commit 477805b913a6c4b4b630e42f08cd9e59f1e4e254:

wic: selftest: account for occasional newline in debugfs file names (2017-03-14 14:39:34 +0000)

are available in the git repository at:

git://git.openembedded.org/openembedded-core-contrib rbt/qemu
http://cgit.openembedded.org/openembedded-core-contrib/log/?h=rbt/qemu

Robert Yang (6):
runqemu: improve when no machine specified
runqemu: add -h and --help
runqemu: only boot ramfs when specified oeqa/targetcontrol.py: modify it to test runqemu selftest/runqemu.py: add it to test runqemu targetcontrol.py: use logger.info to replace of bb.note

 meta/lib/oeqa/selftest/runqemu.py | 140 ++++++++++++++++++++++++++++++++++++++
 meta/lib/oeqa/targetcontrol.py    |  33 ++++++---
 meta/lib/oeqa/utils/commands.py   |  13 +++-
 meta/lib/oeqa/utils/qemurunner.py |  28 +++++---
 scripts/runqemu                   |  21 +++++-
 5 files changed, 208 insertions(+), 27 deletions(-)
 create mode 100644 meta/lib/oeqa/selftest/runqemu.py
Signature · 1 line
2.9.0
#1 lore raw

PATCH 1/6 runqemu: improve when no machine specified

Fixed:

$ runqemu core-image-minimal
[snip]
Exception: FSTYPE is NULL!
[snip]

Get DEPLOY_DIR_IMAGE from "bitbake -e" to make it work.

[YOCTO #10471]

---
 scripts/runqemu | 6 ++++++
 1 file changed, 6 insertions(+)
scripts/runqemu +6 -0
index c5fa88e..add48e6 100755
@@ -443,6 +443,12 @@ class BaseConfig(object):
                         self.set("DEPLOY_DIR_IMAGE", p)
             self.check_arg_machine(unknown_arg)
 
+        if not (self.get('MACHINE') or self.get('DEPLOY_DIR_IMAGE')):
+            self.load_bitbake_env()
+            s = re.search('^DEPLOY_DIR_IMAGE="(.*)"', self.bitbake_e, re.M)
+            if s:
+                self.set("DEPLOY_DIR_IMAGE", s.group(1))
+
     def check_kvm(self):
         """Check kvm and kvm-host"""
         if not (self.kvm_enabled or self.vhost_enabled):
Signature · 1 line
2.9.0
#2 lore raw

PATCH 2/6 runqemu: add -h and --help

In reply to Robert Yang

Fixed:

$ runqemu -h
runqemu - INFO - Assuming MACHINE = -h
runqemu - INFO - Running MACHINE=-h bitbake -e...
[snip]
Exception: FSTYPE is NULL!

[YOCTO #10941]

---
 scripts/runqemu | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
scripts/runqemu +3 -2
index add48e6..d43006f 100755
@@ -80,7 +80,7 @@ of the following environment variables (in any order):
   biosfilename=<filename> - specify bios filename
   qemuparams=<xyz> - specify custom parameters to QEMU
   bootparams=<xyz> - specify custom kernel parameters during boot
-  help: print this text
+  help, -h, --help: print this text
 
 Examples:
   runqemu qemuarm
@@ -1158,7 +1158,8 @@ class BaseConfig(object):
             logger.warn("Couldn't run 'bitbake -e' to gather environment information:\n%s" % err.output.decode('utf-8'))
 
 def main():
-    if len(sys.argv) == 1 or "help" in sys.argv:
+    if len(sys.argv) == 1 or "help" in sys.argv or \
+            '-h' in sys.argv or '--help' in sys.argv:
         print_usage()
         return 0
     config = BaseConfig()
Signature · 1 line
2.9.0
#3 lore raw

PATCH 3/6 runqemu: only boot ramfs when specified

In reply to Robert Yang

This can fix a problem:
IMAGE_FSTYPES += "iso"

$ bitbake core-image-minimal
$ runqemu qemux86

It may boot core-image-minimal-initramfs rather than core-image-minimal, this is not what we want usually. This patch makes it avoid booting ramfs when there are other choices, or when it is specified, for example, "runqemu qemux86 ramfs"

---
 scripts/runqemu | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
scripts/runqemu +9 -1
index d43006f..0918101 100755
@@ -660,7 +660,15 @@ class BaseConfig(object):
                 logger.info('Running %s...' % cmd)
                 qbs = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout.read().decode('utf-8')
                 if qbs:
-                    self.qemuboot = qbs.split()[0]
+                    for qb in qbs.split():
+                        # Don't use initramfs when other choices unless fstype is ramfs
+                        if '-initramfs-' in os.path.basename(qb) and self.fstype != 'cpio.gz':
+                                continue
+                        self.qemuboot = qb
+                        break
+                    if not self.qemuboot:
+                        # Use the first one when no choice
+                        self.qemuboot = qbs.split()[0]
                     self.qbconfload = True
 
         if not self.qemuboot:
Signature · 1 line
2.9.0
#4 lore raw

PATCH 4/6 oeqa/targetcontrol.py: modify it to test runqemu

In reply to Robert Yang

Modify the following files to test runqemu:
targetcontrol.py
utils/commands.py
utils/qemurunner.py

We need simulate how "runqemu" works in command line, so when test "runqemu", the targetcontrol.py, utils/commands.py and utils/qemurunner.py don't have to find the rootfs or set env vars.

[YOCTO #10249]

---
 meta/lib/oeqa/targetcontrol.py    | 20 +++++++++++++++-----
 meta/lib/oeqa/utils/commands.py   | 13 +++++++++++--
 meta/lib/oeqa/utils/qemurunner.py | 28 +++++++++++++++++-----------
 3 files changed, 43 insertions(+), 18 deletions(-)
meta/lib/oeqa/targetcontrol.py +15 -5
index 0ad3a6b..8d11cf0 100644
@@ -117,10 +117,15 @@ class QemuTarget(BaseTarget):
 
         super(QemuTarget, self).__init__(d)
 
-        self.image_fstype = image_fstype or self.get_image_fstype(d)
+        self.rootfs = ''
+        self.kernel = ''
+        self.image_fstype = ''
+
+        if d.getVar('FIND_ROOTFS') == '1':
+            self.image_fstype = image_fstype or self.get_image_fstype(d)
+            self.rootfs = os.path.join(d.getVar("DEPLOY_DIR_IMAGE"),  d.getVar("IMAGE_LINK_NAME") + '.' + self.image_fstype)
+            self.kernel = os.path.join(d.getVar("DEPLOY_DIR_IMAGE"), d.getVar("KERNEL_IMAGETYPE", False) + '-' + d.getVar('MACHINE', False) + '.bin')
         self.qemulog = os.path.join(self.testdir, "qemu_boot_log.%s" % self.datetime)
-        self.rootfs = os.path.join(d.getVar("DEPLOY_DIR_IMAGE"),  d.getVar("IMAGE_LINK_NAME") + '.' + self.image_fstype)
-        self.kernel = os.path.join(d.getVar("DEPLOY_DIR_IMAGE"), d.getVar("KERNEL_IMAGETYPE", False) + '-' + d.getVar('MACHINE', False) + '.bin')
         dump_target_cmds = d.getVar("testimage_dump_target")
         dump_host_cmds = d.getVar("testimage_dump_host")
         dump_dir = d.getVar("TESTIMAGE_DUMP_DIR")
@@ -176,8 +181,13 @@ class QemuTarget(BaseTarget):
         bb.note("Qemu log file: %s" % self.qemulog)
         super(QemuTarget, self).deploy()
 
-    def start(self, params=None, ssh=True, extra_bootparams=None, runqemuparams=''):
-        if self.runner.start(params, get_ip=ssh, extra_bootparams=extra_bootparams, runqemuparams=runqemuparams):
+    def start(self, params=None, ssh=True, extra_bootparams='', runqemuparams='', launch_cmd=''):
+        if launch_cmd:
+            start = self.runner.launch(get_ip=ssh, launch_cmd=launch_cmd)
+        else:
+            start = self.runner.start(params, get_ip=ssh, extra_bootparams=extra_bootparams, runqemuparams=runqemuparams)
+
+        if start:
             if ssh:
                 self.ip = self.runner.ip
                 self.server_ip = self.runner.server_ip
meta/lib/oeqa/utils/commands.py +11 -2
index 82c5908..6528a98 100644
@@ -218,7 +218,10 @@ def create_temp_layer(templayerdir, templayername, priority=999, recipepathspec=
 
 
 @contextlib.contextmanager
-def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None):
+def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None):
+    """
+    launch_cmd means directly run the command, don't need set rootfs or env vars.
+    """
 
     import bb.tinfoil
     import bb.build
@@ -230,6 +233,12 @@ def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None):
         import oeqa.targetcontrol
         tinfoil.config_data.setVar("TEST_LOG_DIR", "${WORKDIR}/testimage")
         tinfoil.config_data.setVar("TEST_QEMUBOOT_TIMEOUT", "1000")
+        # Tell QemuTarget() whether need find rootfs/kernel or not
+        if launch_cmd:
+            tinfoil.config_data.setVar("FIND_ROOTFS", '0')
+        else:
+            tinfoil.config_data.setVar("FIND_ROOTFS", '1')
+
         recipedata = tinfoil.parse_recipe(pn)
 
         # The QemuRunner log is saved out, but we need to ensure it is at the right
@@ -260,7 +269,7 @@ def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None):
     try:
         qemu.deploy()
         try:
-            qemu.start(ssh=ssh, runqemuparams=runqemuparams)
+            qemu.start(ssh=ssh, runqemuparams=runqemuparams, launch_cmd=launch_cmd)
         except bb.build.FuncFailed:
             raise Exception('Failed to start QEMU - see the logs in %s' % logdir)
 
meta/lib/oeqa/utils/qemurunner.py +17 -11
index 59dc11d..aebeaaf 100644
@@ -95,7 +95,7 @@ class QemuRunner:
                 self._dump_host()
                 raise SystemExit
 
-    def start(self, qemuparams = None, get_ip = True, extra_bootparams = None, runqemuparams=''):
+    def start(self, qemuparams = None, get_ip = True, extra_bootparams = None, runqemuparams='', launch_cmd=None):
         if self.display:
             os.environ["DISPLAY"] = self.display
             # Set this flag so that Qemu doesn't do any grabs as SDL grabs
@@ -115,6 +115,20 @@ class QemuRunner:
         else:
             os.environ["DEPLOY_DIR_IMAGE"] = self.deploy_dir_image
 
+        if not launch_cmd:
+            launch_cmd = 'runqemu snapshot'
+            if self.use_kvm:
+                logger.info('Using kvm for runqemu')
+                launch_cmd += ' kvm'
+            else:
+                logger.info('Not using kvm for runqemu')
+            if not self.display:
+                launch_cmd += ' nographic'
+            launch_cmd += ' %s %s' % (self.machine, self.rootfs)
+
+        return self.launch(launch_cmd, qemuparams=qemuparams, get_ip=get_ip, extra_bootparams=extra_bootparams, runqemuparams=runqemuparams)
+
+    def launch(self, launch_cmd, get_ip = True, qemuparams = None, extra_bootparams = None, runqemuparams=''):
         try:
             threadsock, threadport = self.create_socket()
             self.server_socket, self.serverport = self.create_socket()
@@ -122,27 +136,19 @@ class QemuRunner:
             logger.error("Failed to create listening socket: %s" % msg[1])
             return False
 
-
         bootparams = 'console=tty1 console=ttyS0,115200n8 printk.time=1'
         if extra_bootparams:
             bootparams = bootparams + ' ' + extra_bootparams
 
         self.qemuparams = 'bootparams="{0}" qemuparams="-serial tcp:127.0.0.1:{1}"'.format(bootparams, threadport)
-        if not self.display:
-            self.qemuparams = 'nographic ' + self.qemuparams
         if qemuparams:
             self.qemuparams = self.qemuparams[:-1] + " " + qemuparams + " " + '\"'
 
+        launch_cmd += ' tcpserial=%s %s' % (self.serverport, self.qemuparams)
+
         self.origchldhandler = signal.getsignal(signal.SIGCHLD)
         signal.signal(signal.SIGCHLD, self.handleSIGCHLD)
 
-        launch_cmd = 'runqemu snapshot %s ' % runqemuparams
-        if self.use_kvm:
-            logger.info('Using kvm for runqemu')
-            launch_cmd += 'kvm '
-        else:
-            logger.info('Not using kvm for runqemu')
-        launch_cmd += 'tcpserial=%s %s %s %s' % (self.serverport, self.machine, self.rootfs, self.qemuparams)
         logger.info('launchcmd=%s'%(launch_cmd))
 
         # FIXME: We pass in stdin=subprocess.PIPE here to work around stty
Signature · 1 line
2.9.0
#5 lore raw

Re: [PATCH 4/6] oeqa/targetcontrol.py: modify it to test runqemu

Quoted 9 lines · Robert Yang

Modify the following files to test runqemu:
    targetcontrol.py
    utils/commands.py
    utils/qemurunner.py

We need simulate how "runqemu" works in command line, so when test "runqemu", the targetcontrol.py, utils/commands.py and utils/qemurunner.py don't have to find the rootfs or set env vars.

Quoted 8 lines

[YOCTO #10249]

---
 meta/lib/oeqa/targetcontrol.py    | 20 +++++++++++++++----- meta/lib/oeqa/utils/commands.py   | 13 +++++++++++-- meta/lib/oeqa/utils/qemurunner.py | 28 +++++++++++++++++-----------

 3 files changed, 43 insertions(+), 18 deletions(-)

This change breaks "oe-selftest -r wic.Wic.test_qemu_efi" which just hangs afterwards.

Cheers,

Richard

#6 lore raw

Re: [PATCH 4/6] oeqa/targetcontrol.py: modify it to test runqemu

Quoted 19 lines · Richard Purdie
Quoted 9 lines · Robert Yang

Modify the following files to test runqemu:
targetcontrol.py
utils/commands.py
utils/qemurunner.py

We need simulate how "runqemu" works in command line, so when test "runqemu", the targetcontrol.py, utils/commands.py and utils/qemurunner.py don't have to find the rootfs or set env vars.

Quoted 8 lines

[YOCTO #10249]

---
 meta/lib/oeqa/targetcontrol.py    | 20 +++++++++++++++-----
 meta/lib/oeqa/utils/commands.py   | 13 +++++++++++--
 meta/lib/oeqa/utils/qemurunner.py | 28 +++++++++++++++++-----------
 3 files changed, 43 insertions(+), 18 deletions(-)
Quoted 2 lines

This change breaks "oe-selftest -r wic.Wic.test_qemu_efi" which just hangs afterwards.

Sorry, I will fix it.

// Robert

Quoted 5 lines

Cheers,

Richard

#7 lore raw

PATCH 5/6 selftest/runqemu.py: add it to test runqemu

In reply to Robert Yang

Usage:

$ oe-selftest -r runqemu

Current test cases:

$ runqemu nographic qemux86-64
$ runqemu nographic qemux86-64 ext4
$ runqemu nographic qemux86-64 iso
$ runqemu nographic core-image-minimal
$ runqemu nographic core-image-minimal vmdk
$ runqemu nographic core-image-minimal vdi
$ runqemu nographic tmp/deploy/images/qemux86-64
$ runqemu nographic tmp/deploy/images/qemux86-64 hddimg
$ runqemu nographic qemux86-64 slirp
$ runqemu nographic qemux86-64 slirp qcow2
$ runqemu nographic tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.qemuboot.conf
$ runqemu nographic tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.ext4

Need more later:
- Test initramfs
- Test nfs
- Test when set DEPLOY_DIR_IMAGE and OECORE_NATIVE_SYSROOT
- And others which similate runqemu runs on SDK and eSDK.

[YOCTO #10249]

---
 meta/lib/oeqa/selftest/runqemu.py | 136 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 136 insertions(+)
 create mode 100644 meta/lib/oeqa/selftest/runqemu.py
meta/lib/oeqa/selftest/runqemu.py new file +136 -0
new file mode 100644
index 0000000..c1d5c16
@@ -0,0 +1,136 @@
+#
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+
+import re
+import logging
+
+from oeqa.selftest.base import oeSelfTest
+from oeqa.utils.commands import bitbake, runqemu, get_bb_var
+from oeqa.utils.decorators import testcase
+
+class RunqemuTests(oeSelfTest):
+    """Runqemu test class"""
+
+    image_is_ready = False
+    deploy_dir_image = ''
+
+    def setUpLocal(self):
+        self.recipe = 'core-image-minimal'
+        self.machine =  'qemux86-64'
+        self.fstypes = "ext4 iso hddimg vmdk qcow2 vdi"
+        self.cmd_common = "runqemu nographic"
+
+        self.write_config(
+"""
+MACHINE = "%s"
+IMAGE_FSTYPES = "%s"
+# 10 means 1 second
+SYSLINUX_TIMEOUT = "10"
+"""
+% (self.machine, self.fstypes)
+        )
+
+        if not RunqemuTests.image_is_ready:
+            RunqemuTests.deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE')
+            bitbake(self.recipe)
+            RunqemuTests.image_is_ready = True
+
+    @testcase(2001)
+    def test_boot_machine(self):
+        """Test runqemu machine"""
+        cmd = "%s %s" % (self.cmd_common, self.machine)
+        with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
+            self.assertTrue(qemu.runner.logged, "Failed: %s" % cmd)
+
+    @testcase(2002)
+    def test_boot_machine_ext4(self):
+        """Test runqemu machine ext4"""
+        cmd = "%s %s ext4" % (self.cmd_common, self.machine)
+        with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
+            with open(qemu.qemurunnerlog) as f:
+                self.assertTrue('rootfs.ext4' in f.read(), "Failed: %s" % cmd)
+
+    @testcase(2003)
+    def test_boot_machine_iso(self):
+        """Test runqemu machine iso"""
+        cmd = "%s %s iso" % (self.cmd_common, self.machine)
+        with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
+            with open(qemu.qemurunnerlog) as f:
+                self.assertTrue(' -cdrom ' in f.read(), "Failed: %s" % cmd)
+
+    @testcase(2004)
+    def test_boot_recipe_image(self):
+        """Test runqemu recipe-image"""
+        cmd = "%s %s" % (self.cmd_common, self.recipe)
+        with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
+            self.assertTrue(qemu.runner.logged, "Failed: %s" % cmd)
+
+    @testcase(2005)
+    def test_boot_recipe_image_vmdk(self):
+        """Test runqemu recipe-image vmdk"""
+        cmd = "%s %s vmdk" % (self.cmd_common, self.recipe)
+        with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
+            with open(qemu.qemurunnerlog) as f:
+                self.assertTrue('format=vmdk' in f.read(), "Failed: %s" % cmd)
+
+    @testcase(2006)
+    def test_boot_recipe_image_vdi(self):
+        """Test runqemu recipe-image vdi"""
+        cmd = "%s %s vdi" % (self.cmd_common, self.recipe)
+        with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
+            with open(qemu.qemurunnerlog) as f:
+                self.assertTrue('format=vdi' in f.read(), "Failed: %s" % cmd)
+
+    @testcase(2007)
+    def test_boot_deploy(self):
+        """Test runqemu deploy_dir_image"""
+        cmd = "%s %s" % (self.cmd_common, self.deploy_dir_image)
+        with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
+            self.assertTrue(qemu.runner.logged, "Failed: %s" % cmd)
+
+    @testcase(2008)
+    def test_boot_deploy_hddimg(self):
+        """Test runqemu deploy_dir_image hddimg"""
+        cmd = "%s %s hddimg" % (self.cmd_common, self.deploy_dir_image)
+        with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
+            with open(qemu.qemurunnerlog) as f:
+                self.assertTrue(re.search('file=.*.hddimg', f.read()), "Failed: %s" % cmd)
+
+    @testcase(2009)
+    def test_boot_machine_slirp(self):
+        """Test runqemu machine slirp"""
+        cmd = "%s slirp %s" % (self.cmd_common, self.machine)
+        with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
+            with open(qemu.qemurunnerlog) as f:
+                self.assertTrue(' -netdev user' in f.read(), "Failed: %s" % cmd)
+
+    @testcase(2009)
+    def test_boot_machine_slirp_qcow2(self):
+        """Test runqemu machine slirp qcow2"""
+        cmd = "%s slirp qcow2 %s" % (self.cmd_common, self.machine)
+        with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
+            with open(qemu.qemurunnerlog) as f:
+                self.assertTrue('format=qcow2' in f.read(), "Failed: %s" % cmd)
+
+    @testcase(2010)
+    def test_boot_qemu_boot(self):
+        """Test runqemu /path/to/image.qemuboot.conf"""
+        qemuboot_conf = "%s-%s.qemuboot.conf" % (self.recipe, self.machine)
+        qemuboot_conf = os.path.join(self.deploy_dir_image, qemuboot_conf)
+        if not os.path.exists(qemuboot_conf):
+            self.skipTest("%s not found" % qemuboot_conf)
+        cmd = "%s %s" % (self.cmd_common, qemuboot_conf)
+        with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
+            self.assertTrue(qemu.runner.logged, "Failed: %s" % cmd)
+
+    @testcase(2011)
+    def test_boot_rootfs(self):
+        """Test runqemu /path/to/rootfs.ext4"""
+        rootfs = "%s-%s.ext4" % (self.recipe, self.machine)
+        rootfs = os.path.join(self.deploy_dir_image, rootfs)
+        if not os.path.exists(rootfs):
+            self.skipTest("%s not found" % rootfs)
+        cmd = "%s %s" % (self.cmd_common, rootfs)
+        with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
+            self.assertTrue(qemu.runner.logged, "Failed: %s" % cmd)
Signature · 1 line
2.9.0
#8 lore raw

PATCH 6/6 targetcontrol.py: use logger.info to replace of bb.note

In reply to Robert Yang

The bb.note prints multiple same lines when invoke this class again, but if we set mainlogger.propagate = False, nothing would be printed, according to logging's document:

https://docs.python.org/3/library/logging.html
Note
If you attach a handler to a logger and one or more of its ancestors, it may emit the same record multiple times. In general, you should not need to attach a handler to more than one logger - if you just attach it to the appropriate logger which is highest in the logger hierarchy, then it will see all events logged by all descendant loggers, provided that their propagate setting is left set to True. A common scenario is to attach handlers only to the root logger, and to let propagation take care of the rest.

We may need avoid using bb.note or bb.warn in oeqa since it attaches multiple log handlers which may cause confusions

This patch only sets "mainlogger.propagate = False" in selftest/runqemu.py and use logger.info to replace bb.note in targetcontrol.py to minimize the impact.

[YOCTO #10249]

---
 meta/lib/oeqa/selftest/runqemu.py |  4 ++++
 meta/lib/oeqa/targetcontrol.py    | 13 +++++++------
 2 files changed, 11 insertions(+), 6 deletions(-)
meta/lib/oeqa/selftest/runqemu.py +4 -0
index c1d5c16..58c6f96 100644
@@ -21,6 +21,10 @@ class RunqemuTests(oeSelfTest):
         self.fstypes = "ext4 iso hddimg vmdk qcow2 vdi"
         self.cmd_common = "runqemu nographic"
 
+        # Avoid emit the same record multiple times.
+        mainlogger = logging.getLogger("BitBake.Main")
+        mainlogger.propagate = False
+
         self.write_config(
 """
 MACHINE = "%s"
meta/lib/oeqa/targetcontrol.py +7 -6
index 8d11cf0..82aaf2f 100644
@@ -18,6 +18,8 @@ from oeqa.utils.dump import TargetDumper
 from oeqa.controllers.testtargetloader import TestTargetLoader
 from abc import ABCMeta, abstractmethod
 
+logger = logging.getLogger('BitBake.QemuRunner')
+
 def get_target_controller(d):
     testtarget = d.getVar("TEST_TARGET")
     # old, simple names
@@ -63,7 +65,7 @@ class BaseTarget(object, metaclass=ABCMeta):
         if os.path.islink(sshloglink):
             os.unlink(sshloglink)
         os.symlink(self.sshlog, sshloglink)
-        bb.note("SSH log file: %s" %  self.sshlog)
+        logger.info("SSH log file: %s" %  self.sshlog)
 
     @abstractmethod
     def start(self, params=None, ssh=True, extra_bootparams=None):
@@ -140,7 +142,6 @@ class QemuTarget(BaseTarget):
         import oe.path
         bb.utils.mkdirhier(self.testdir)
         self.qemurunnerlog = os.path.join(self.testdir, 'qemurunner_log.%s' % self.datetime)
-        logger = logging.getLogger('BitBake.QemuRunner')
         loggerhandler = logging.FileHandler(self.qemurunnerlog)
         loggerhandler.setFormatter(logging.Formatter("%(levelname)s: %(message)s"))
         logger.addHandler(loggerhandler)
@@ -177,8 +178,8 @@ class QemuTarget(BaseTarget):
             os.unlink(qemuloglink)
         os.symlink(self.qemulog, qemuloglink)
 
-        bb.note("rootfs file: %s" %  self.rootfs)
-        bb.note("Qemu log file: %s" % self.qemulog)
+        logger.info("rootfs file: %s" %  self.rootfs)
+        logger.info("Qemu log file: %s" % self.qemulog)
         super(QemuTarget, self).deploy()
 
     def start(self, params=None, ssh=True, extra_bootparams='', runqemuparams='', launch_cmd=''):
@@ -230,14 +231,14 @@ class SimpleRemoteTarget(BaseTarget):
             self.port = addr.split(":")[1]
         except IndexError:
             self.port = None
-        bb.note("Target IP: %s" % self.ip)
+        logger.info("Target IP: %s" % self.ip)
         self.server_ip = d.getVar("TEST_SERVER_IP")
         if not self.server_ip:
             try:
                 self.server_ip = subprocess.check_output(['ip', 'route', 'get', self.ip ]).split("\n")[0].split()[-1]
             except Exception as e:
                 bb.fatal("Failed to determine the host IP address (alternatively you can set TEST_SERVER_IP with the IP address of this machine): %s" % e)
-        bb.note("Server IP: %s" % self.server_ip)
+        logger.info("Server IP: %s" % self.server_ip)
 
     def deploy(self):
         super(SimpleRemoteTarget, self).deploy()
Signature · 1 line
2.9.0