oeqa: some minor fixes and cleanups
cover oeqa: some minor fixes and cleanups
This is a collection of minor fixes and cleanups I came across when digging through oeqa code.
Enrico Jorns (10):
oeqa/selftest/cases/runqemu: update imports oeqa/targetcontrol: fix misspelled RuntimeError oeqa/targetcontrol: do not set dump_host_cmds redundantly oeqa/targetcontrol: remove unused imports oeqa/utils/commands: fix usage of undefined EPIPE oeqa/utils/commands: remove unused imports oeqa/utils/qemurunner: replace hard-coded user 'root' in debug output oeqa/utils/qemurunner: limit precision of timing debugging output oeqa/utils/qemurunner: fix undefined TimeoutExpired
oeqa: whitespace and indentation cleanups
meta/lib/oeqa/selftest/cases/runqemu.py | 16 ++++++------ meta/lib/oeqa/targetcontrol.py | 12 +++------ meta/lib/oeqa/utils/commands.py | 8 +++--- meta/lib/oeqa/utils/qemurunner.py | 34 ++++++++++++------------- 4 files changed, 32 insertions(+), 38 deletions(-)
Signature · 1 line
2.39.2
PATCH 1/10 oeqa/selftest/cases/runqemu: update imports
'tempfile' and 'oeqa.utils.command.runCmd' are unused while 'os' is actually used.
--- meta/lib/oeqa/selftest/cases/runqemu.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
meta/lib/oeqa/selftest/cases/runqemu.py +2 -2
@@ -4,14 +4,14 @@ # SPDX-License-Identifier: MIT # +import os import re -import tempfile import time import oe.types from oeqa.core.decorator import OETestTag from oeqa.core.decorator.data import skipIfNotArch, skipIfNotMachine from oeqa.selftest.case import OESelftestTestCase -from oeqa.utils.commands import bitbake, runqemu, get_bb_var, runCmd +from oeqa.utils.commands import bitbake, runqemu, get_bb_var @OETestTag("runqemu") class RunqemuTests(OESelftestTestCase):
Signature · 1 line
2.39.2
PATCH 2/10 oeqa/targetcontrol: fix misspelled RuntimeError
In reply to Enrico Jorns--- meta/lib/oeqa/targetcontrol.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/lib/oeqa/targetcontrol.py +1 -1
@@ -205,7 +205,7 @@ class QemuTarget(BaseTarget): self.server_ip = self.runner.server_ip self.connection = SSHControl(ip=self.ip, logfile=self.sshlog) else: - raise RuntimError("%s - FAILED to re-start qemu - check the task log and the boot log" % self.pn) + raise RuntimeError("%s - FAILED to re-start qemu - check the task log and the boot log" % self.pn) def run_serial(self, command, timeout=60): return self.runner.run_serial(command, timeout=timeout)
Signature · 1 line
2.39.2
PATCH 3/10 oeqa/targetcontrol: do not set dump_host_cmds redundantly
In reply to Enrico JornsThis is already set above, thus simply use the set value from there.
--- meta/lib/oeqa/targetcontrol.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/lib/oeqa/targetcontrol.py +1 -1
@@ -145,7 +145,7 @@ class QemuTarget(BaseTarget): boottime = int(d.getVar("TEST_QEMUBOOT_TIMEOUT")), use_kvm = use_kvm, dump_dir = dump_dir, - dump_host_cmds = d.getVar("testimage_dump_host"), + dump_host_cmds = dump_host_cmds, logger = logger, tmpfsdir = d.getVar("RUNQEMU_TMPFS_DIR"), serial_ports = len(d.getVar("SERIAL_CONSOLES").split()))
Signature · 1 line
2.39.2
PATCH 4/10 oeqa/targetcontrol: remove unused imports
In reply to Enrico Jorns--- meta/lib/oeqa/targetcontrol.py | 4 ---- 1 file changed, 4 deletions(-)
meta/lib/oeqa/targetcontrol.py +0 -4
@@ -7,18 +7,14 @@ # This module is used by testimage.bbclass for setting up and controlling a target machine. import os -import shutil import subprocess import bb -import traceback -import sys 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.utils.dump import MonitorDumper -from oeqa.controllers.testtargetloader import TestTargetLoader from abc import ABCMeta, abstractmethod class BaseTarget(object, metaclass=ABCMeta):
Signature · 1 line
2.39.2
PATCH 5/10 oeqa/utils/commands: fix usage of undefined EPIPE
In reply to Enrico Jorns--- meta/lib/oeqa/utils/commands.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
meta/lib/oeqa/utils/commands.py +2 -1
@@ -21,6 +21,7 @@ from oeqa.utils import CommandError from oeqa.utils import ftools import re import contextlib +import errno # Export test doesn't require bb try: import bb
@@ -85,7 +86,7 @@ class Command(object): except OSError as ex: # It's not an error when the command does not consume all # of our data. subprocess.communicate() also ignores that. - if ex.errno != EPIPE: + if ex.errno != errno.EPIPE: raise # We write in a separate thread because then we can read
Signature · 1 line
2.39.2
PATCH 6/10 oeqa/utils/commands: remove unused imports
In reply to Enrico Jorns--- meta/lib/oeqa/utils/commands.py | 3 --- 1 file changed, 3 deletions(-)
meta/lib/oeqa/utils/commands.py +0 -3
@@ -8,11 +8,8 @@ # This module is mainly used by scripts/oe-selftest and modules under meta/oeqa/selftest # It provides a class and methods for running commands on the host in a convienent way for tests. - - import os import sys -import signal import subprocess import threading import time
Signature · 1 line
2.39.2
PATCH 7/10 oeqa/utils/qemurunner: replace hard-coded user 'root' in debug output
In reply to Enrico JornsSince login user is configurable with boot_patterns['send_login_user'], unconditionally using 'root' in the debug message can be confusing.
Also fix the debug message to say 'Logged in' instead of 'Logged'.
--- meta/lib/oeqa/utils/qemurunner.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
meta/lib/oeqa/utils/qemurunner.py +2 -2
@@ -516,7 +516,7 @@ class QemuRunner: (status, output) = self.run_serial(self.boot_patterns['send_login_user'], raw=True, timeout=120) if re.search(self.boot_patterns['search_login_succeeded'], output): self.logged = True - self.logger.debug("Logged as root in serial console") + self.logger.debug("Logged in as %s in serial console" % self.boot_patterns['send_login_user'].replace("\n", "")) if netconf: # configure guest networking cmd = "ifconfig eth0 %s netmask %s up\n" % (self.ip, self.netmask)
@@ -527,7 +527,7 @@ class QemuRunner: self.logger.debug("Couldn't configure guest networking") else: self.logger.warning("Couldn't login into serial console" - " as root using blank password") + " as %s using blank password" % self.boot_patterns['send_login_user'].replace("\n", "")) self.logger.warning("The output:\n%s" % output) except: self.logger.warning("Serial console failed while trying to login")
Signature · 1 line
2.39.2
PATCH 8/10 oeqa/utils/qemurunner: limit precision of timing debugging output
In reply to Enrico Jorns* There is no need to be that precise. It just irritates in the logs.
* There is also no point in printing plain time.time() value a single time while only using formatted printout everywhere else, thus remove it.
* Use %d for printing integer times
--- meta/lib/oeqa/utils/qemurunner.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
meta/lib/oeqa/utils/qemurunner.py +7 -7
@@ -275,7 +275,7 @@ class QemuRunner: os._exit(0) self.logger.debug("runqemu started, pid is %s" % self.runqemu.pid) - self.logger.debug("waiting at most %s seconds for qemu pid (%s)" % + self.logger.debug("waiting at most %d seconds for qemu pid (%s)" % (self.runqemutime, time.strftime("%D %H:%M:%S"))) endtime = time.time() + self.runqemutime while not self.is_alive() and time.time() < endtime:
@@ -299,7 +299,7 @@ class QemuRunner: self.logger.warning('runqemu exited with code %d' % self.runqemu.returncode) if not self.is_alive(): - self.logger.error("Qemu pid didn't appear in %s seconds (%s)" % + self.logger.error("Qemu pid didn't appear in %d seconds (%s)" % (self.runqemutime, time.strftime("%D %H:%M:%S"))) qemu_pid = None
@@ -354,7 +354,7 @@ class QemuRunner: self.qmp.settimeout(self.runqemutime) self.qmp.connect() connect_time = time.time() - self.logger.info("QMP connected to QEMU at %s and took %s seconds" % + self.logger.info("QMP connected to QEMU at %s and took %.2f seconds" % (time.strftime("%D %H:%M:%S"), time.time() - launch_time)) except OSError as msg:
@@ -388,14 +388,14 @@ class QemuRunner: # Release the qemu process to continue running self.run_monitor('cont') - self.logger.info("QMP released QEMU at %s and took %s seconds from connect" % + self.logger.info("QMP released QEMU at %s and took %.2f seconds from connect" % (time.strftime("%D %H:%M:%S"), time.time() - connect_time)) # We are alive: qemu is running out = self.getOutput(output) netconf = False # network configuration is not required by default - self.logger.debug("qemu started in %s seconds - qemu procces pid is %s (%s)" % + self.logger.debug("qemu started in %.2f seconds - qemu procces pid is %s (%s)" % (time.time() - (endtime - self.runqemutime), self.qemupid, time.strftime("%D %H:%M:%S"))) cmdline = ''
@@ -486,9 +486,9 @@ class QemuRunner: self.server_socket = qemusock stopread = True reachedlogin = True - self.logger.debug("Reached login banner in %s seconds (%s, %s)" % + self.logger.debug("Reached login banner in %.2f seconds (%s)" % (time.time() - (endtime - self.boottime), - time.strftime("%D %H:%M:%S"), time.time())) + time.strftime("%D %H:%M:%S"))) else: # no need to check if reachedlogin unless we support multiple connections self.logger.debug("QEMU socket disconnected before login banner reached. (%s)" %
Signature · 1 line
2.39.2
PATCH 9/10 oeqa/utils/qemurunner: fix undefined TimeoutExpired
In reply to Enrico Jorns--- meta/lib/oeqa/utils/qemurunner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/lib/oeqa/utils/qemurunner.py +1 -1
@@ -553,7 +553,7 @@ class QemuRunner: self.logger.info("Output from runqemu:\n%s", outs.decode("utf-8")) if errs: self.logger.info("Stderr from runqemu:\n%s", errs.decode("utf-8")) - except TimeoutExpired: + except subprocess.TimeoutExpired: self.logger.debug("Sending SIGKILL to runqemu") os.killpg(os.getpgid(self.runqemu.pid), signal.SIGKILL) if not self.runqemu.stdout.closed:
Signature · 1 line
2.39.2
PATCH 10/10 oeqa: whitespace and indentation cleanups
In reply to Enrico Jorns--- meta/lib/oeqa/selftest/cases/runqemu.py | 12 ++++++------ meta/lib/oeqa/targetcontrol.py | 4 ++-- meta/lib/oeqa/utils/commands.py | 2 +- meta/lib/oeqa/utils/qemurunner.py | 14 +++++++------- 4 files changed, 16 insertions(+), 16 deletions(-)
meta/lib/oeqa/selftest/cases/runqemu.py +6 -6
@@ -13,6 +13,7 @@ from oeqa.core.decorator.data import skipIfNotArch, skipIfNotMachine from oeqa.selftest.case import OESelftestTestCase from oeqa.utils.commands import bitbake, runqemu, get_bb_var + @OETestTag("runqemu") class RunqemuTests(OESelftestTestCase): """Runqemu test class"""
@@ -23,8 +24,8 @@ class RunqemuTests(OESelftestTestCase): def setUpLocal(self): super(RunqemuTests, self).setUpLocal() self.recipe = 'core-image-minimal' - self.machine = self.td['MACHINE'] - self.image_link_name = get_bb_var('IMAGE_LINK_NAME', self.recipe) + self.machine = self.td['MACHINE'] + self.image_link_name = get_bb_var('IMAGE_LINK_NAME', self.recipe) self.fstypes = "ext4" if self.td["HOST_ARCH"] in ('i586', 'i686', 'x86_64'):
@@ -102,7 +103,6 @@ SYSLINUX_TIMEOUT = "10" with open(qemu.qemurunnerlog) as f: self.assertTrue(qemu.runner.logged, "Failed: %s, %s" % (cmd, f.read())) - @skipIfNotArch(['i586', 'i686', 'x86_64']) def test_boot_deploy_hddimg(self): """Test runqemu deploy_dir_image hddimg"""
@@ -166,9 +166,9 @@ class QemuTest(OESelftestTestCase): def setUpClass(cls): super(QemuTest, cls).setUpClass() cls.recipe = 'core-image-minimal' - cls.machine = get_bb_var('MACHINE') - cls.deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE') - cls.image_link_name = get_bb_var('IMAGE_LINK_NAME', cls.recipe) + cls.machine = get_bb_var('MACHINE') + cls.deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE') + cls.image_link_name = get_bb_var('IMAGE_LINK_NAME', cls.recipe) cls.cmd_common = "runqemu nographic" cls.qemuboot_conf = "%s.qemuboot.conf" % (cls.image_link_name) cls.qemuboot_conf = os.path.join(cls.deploy_dir_image, cls.qemuboot_conf)
meta/lib/oeqa/targetcontrol.py +2 -2
@@ -38,7 +38,7 @@ class BaseTarget(object, metaclass=ABCMeta): if os.path.islink(sshloglink): os.unlink(sshloglink) os.symlink(self.sshlog, sshloglink) - self.logger.info("SSH log file: %s" % self.sshlog) + self.logger.info("SSH log file: %s" % self.sshlog) @abstractmethod def start(self, params=None, ssh=True, extra_bootparams=None):
@@ -159,7 +159,7 @@ class QemuTarget(BaseTarget): os.unlink(qemuloglink) os.symlink(self.qemulog, qemuloglink) - self.logger.info("rootfs file: %s" % self.rootfs) + self.logger.info("rootfs file: %s" % self.rootfs) self.logger.info("Qemu log file: %s" % self.qemulog) super(QemuTarget, self).deploy()
meta/lib/oeqa/utils/commands.py +1 -1
@@ -115,7 +115,7 @@ class Command(object): else: deadline = time.time() + self.timeout for thread in self.threads: - timeout = deadline - time.time() + timeout = deadline - time.time() if timeout < 0: timeout = 0 thread.join(timeout)
meta/lib/oeqa/utils/qemurunner.py +7 -7
@@ -238,7 +238,7 @@ class QemuRunner: self.origchldhandler = signal.getsignal(signal.SIGCHLD) signal.signal(signal.SIGCHLD, self.handleSIGCHLD) - self.logger.debug('launchcmd=%s'%(launch_cmd)) + self.logger.debug('launchcmd=%s' % (launch_cmd)) # FIXME: We pass in stdin=subprocess.PIPE here to work around stty # blocking at the end of the runqemu script when using this within
@@ -332,8 +332,8 @@ class QemuRunner: try: os.chdir(os.path.dirname(qmp_port)) try: - from qmp.legacy import QEMUMonitorProtocol - self.qmp = QEMUMonitorProtocol(os.path.basename(qmp_port)) + from qmp.legacy import QEMUMonitorProtocol + self.qmp = QEMUMonitorProtocol(os.path.basename(qmp_port)) except OSError as msg: self.logger.warning("Failed to initialize qemu monitor socket: %s File: %s" % (msg, msg.filename)) return False
@@ -343,8 +343,8 @@ class QemuRunner: self.logger.debug("QMP Port does not exist waiting for it to be created") endtime = time.time() + self.runqemutime while not os.path.exists(qmp_port) and self.is_alive() and time.time() < endtime: - self.logger.info("QMP port does not exist yet!") - time.sleep(0.5) + self.logger.info("QMP port does not exist yet!") + time.sleep(0.5) if not os.path.exists(qmp_port) and self.is_alive(): self.logger.warning("QMP Port still does not exist but QEMU is alive") return False
@@ -419,7 +419,7 @@ class QemuRunner: except (IndexError, ValueError): # Try to get network configuration from runqemu output match = re.match(r'.*Network configuration: (?:ip=)*([0-9.]+)::([0-9.]+):([0-9.]+).*', - out, re.MULTILINE|re.DOTALL) + out, re.MULTILINE | re.DOTALL) if match: self.ip, self.server_ip, self.netmask = match.groups() # network configuration is required as we couldn't get it
@@ -548,7 +548,7 @@ class QemuRunner: if e.errno != errno.ESRCH: raise try: - outs, errs = self.runqemu.communicate(timeout = self.runqemutime) + outs, errs = self.runqemu.communicate(timeout=self.runqemutime) if outs: self.logger.info("Output from runqemu:\n%s", outs.decode("utf-8")) if errs:
Signature · 1 line
2.39.2