diff options
Diffstat (limited to 'poky/meta/lib/oeqa/utils')
-rw-r--r-- | poky/meta/lib/oeqa/utils/dump.py | 23 | ||||
-rw-r--r-- | poky/meta/lib/oeqa/utils/qemurunner.py | 31 |
2 files changed, 41 insertions, 13 deletions
diff --git a/poky/meta/lib/oeqa/utils/dump.py b/poky/meta/lib/oeqa/utils/dump.py index 843e19fe8..bb067f484 100644 --- a/poky/meta/lib/oeqa/utils/dump.py +++ b/poky/meta/lib/oeqa/utils/dump.py @@ -18,6 +18,7 @@ class BaseDumper(object): # Some testing doesn't inherit testimage, so it is needed # to set some defaults. self.parent_dir = parent_dir + self.dump_dir = parent_dir dft_cmds = """ top -bn1 iostat -x -z -N -d -p ALL 20 2 ps -ef @@ -47,7 +48,7 @@ class BaseDumper(object): raise err self.dump_dir = dump_dir - def _write_dump(self, command, output): + def _construct_filename(self, command): if isinstance(self, HostDumper): prefix = "host" elif isinstance(self, TargetDumper): @@ -61,6 +62,10 @@ class BaseDumper(object): fullname = os.path.join(self.dump_dir, filename) if not os.path.exists(fullname): break + return fullname + + def _write_dump(self, command, output): + fullname = self._construct_filename(command) if isinstance(self, MonitorDumper): with open(fullname, 'w') as json_file: json.dump(output, json_file, indent=4) @@ -117,8 +122,16 @@ class MonitorDumper(BaseDumper): if dump_dir: self.dump_dir = dump_dir for cmd in self.cmds: + cmd_name = cmd.split()[0] try: - output = self.runner.run_monitor(cmd) - self._write_dump(cmd, output) - except: - print("Failed to dump QMP CMD: %s" % (cmd)) + if len(cmd.split()) > 1: + cmd_args = cmd.split()[1] + if "%s" in cmd_args: + filename = self._construct_filename(cmd_name) + cmd_data = json.loads(cmd_args % (filename)) + output = self.runner.run_monitor(cmd_name, cmd_data) + else: + output = self.runner.run_monitor(cmd_name) + self._write_dump(cmd_name, output) + except Exception as e: + print("Failed to dump QMP CMD: %s with\nExecption: %s" % (cmd_name, e)) diff --git a/poky/meta/lib/oeqa/utils/qemurunner.py b/poky/meta/lib/oeqa/utils/qemurunner.py index abbc7f7d1..5c9d2b24a 100644 --- a/poky/meta/lib/oeqa/utils/qemurunner.py +++ b/poky/meta/lib/oeqa/utils/qemurunner.py @@ -236,6 +236,7 @@ class QemuRunner: # to be a proper fix but this will suffice for now. self.runqemu = subprocess.Popen(launch_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE, preexec_fn=os.setpgrp, env=env, cwd=self.tmpdir) output = self.runqemu.stdout + launch_time = time.time() # # We need the preexec_fn above so that all runqemu processes can easily be killed @@ -339,6 +340,10 @@ class QemuRunner: try: self.qmp.connect() + connect_time = time.time() + self.logger.info("QMP connected to QEMU at %s and took %s seconds" % + (time.strftime("%D %H:%M:%S"), + time.time() - launch_time)) except OSError as msg: self.logger.warning("Failed to connect qemu monitor socket: %s File: %s" % (msg, msg.filename)) return False @@ -354,19 +359,25 @@ class QemuRunner: mapdir = "/proc/" + str(self.qemupid) + "/map_files/" try: for f in os.listdir(mapdir): - linktarget = os.readlink(os.path.join(mapdir, f)) - if not linktarget.startswith("/") or linktarget.startswith("/dev") or "deleted" in linktarget: + try: + linktarget = os.readlink(os.path.join(mapdir, f)) + if not linktarget.startswith("/") or linktarget.startswith("/dev") or "deleted" in linktarget: + continue + with open(linktarget, "rb") as readf: + data = True + while data: + data = readf.read(4096) + except FileNotFoundError: continue - with open(linktarget, "rb") as readf: - data = True - while data: - data = readf.read(4096) # Centos7 doesn't allow us to read /map_files/ except PermissionError: pass # 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" % + (time.strftime("%D %H:%M:%S"), + time.time() - connect_time)) # We are alive: qemu is running out = self.getOutput(output) @@ -594,8 +605,12 @@ class QemuRunner: return True return False - def run_monitor(self, command, timeout=60): - return self.qmp.cmd(command) + def run_monitor(self, command, args=None, timeout=60): + if hasattr(self, 'qmp') and self.qmp: + if args is not None: + return self.qmp.cmd(command, args) + else: + return self.qmp.cmd(command) def run_serial(self, command, raw=False, timeout=60): # We assume target system have echo to get command status |