summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaul Wold <Saul.Wold@windriver.com>2021-06-30 14:17:06 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-07-02 23:14:32 +0100
commitbb534a9c02ea062cd6f4d812b4744465101d5353 (patch)
tree9949ea0cd9f66a629c0103397d273f1be477f7cd
parent879545999f6277bd441415a0a3815ff57fc004d3 (diff)
downloadpoky-bb534a9c02ea062cd6f4d812b4744465101d5353.tar.gz
oeqa/dump.py: Add support for QMP command arguments
Need to ensure that the dump_dir is created correctly and available When command arguemnts are passed construct a filename if needed and convert the arguements to a json object to pass to QMP. (From OE-Core rev: 9a2f4e1e95f4a3f7ebbf08f46445c8ea670adce3) Signed-off-by: Saul Wold <saul.wold@windriver.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/targetcontrol.py2
-rw-r--r--meta/lib/oeqa/utils/dump.py23
2 files changed, 20 insertions, 5 deletions
diff --git a/meta/lib/oeqa/targetcontrol.py b/meta/lib/oeqa/targetcontrol.py
index 005ebaa7f3..1fdff82889 100644
--- a/meta/lib/oeqa/targetcontrol.py
+++ b/meta/lib/oeqa/targetcontrol.py
@@ -152,6 +152,8 @@ class QemuTarget(BaseTarget):
152 152
153 self.target_dumper = TargetDumper(dump_target_cmds, dump_dir, self.runner) 153 self.target_dumper = TargetDumper(dump_target_cmds, dump_dir, self.runner)
154 self.monitor_dumper = MonitorDumper(dump_monitor_cmds, dump_dir, self.runner) 154 self.monitor_dumper = MonitorDumper(dump_monitor_cmds, dump_dir, self.runner)
155 if (self.monitor_dumper):
156 self.monitor_dumper.create_dir("qmp")
155 157
156 def deploy(self): 158 def deploy(self):
157 bb.utils.mkdirhier(self.testdir) 159 bb.utils.mkdirhier(self.testdir)
diff --git a/meta/lib/oeqa/utils/dump.py b/meta/lib/oeqa/utils/dump.py
index 843e19fe8a..bb067f4846 100644
--- a/meta/lib/oeqa/utils/dump.py
+++ b/meta/lib/oeqa/utils/dump.py
@@ -18,6 +18,7 @@ class BaseDumper(object):
18 # Some testing doesn't inherit testimage, so it is needed 18 # Some testing doesn't inherit testimage, so it is needed
19 # to set some defaults. 19 # to set some defaults.
20 self.parent_dir = parent_dir 20 self.parent_dir = parent_dir
21 self.dump_dir = parent_dir
21 dft_cmds = """ top -bn1 22 dft_cmds = """ top -bn1
22 iostat -x -z -N -d -p ALL 20 2 23 iostat -x -z -N -d -p ALL 20 2
23 ps -ef 24 ps -ef
@@ -47,7 +48,7 @@ class BaseDumper(object):
47 raise err 48 raise err
48 self.dump_dir = dump_dir 49 self.dump_dir = dump_dir
49 50
50 def _write_dump(self, command, output): 51 def _construct_filename(self, command):
51 if isinstance(self, HostDumper): 52 if isinstance(self, HostDumper):
52 prefix = "host" 53 prefix = "host"
53 elif isinstance(self, TargetDumper): 54 elif isinstance(self, TargetDumper):
@@ -61,6 +62,10 @@ class BaseDumper(object):
61 fullname = os.path.join(self.dump_dir, filename) 62 fullname = os.path.join(self.dump_dir, filename)
62 if not os.path.exists(fullname): 63 if not os.path.exists(fullname):
63 break 64 break
65 return fullname
66
67 def _write_dump(self, command, output):
68 fullname = self._construct_filename(command)
64 if isinstance(self, MonitorDumper): 69 if isinstance(self, MonitorDumper):
65 with open(fullname, 'w') as json_file: 70 with open(fullname, 'w') as json_file:
66 json.dump(output, json_file, indent=4) 71 json.dump(output, json_file, indent=4)
@@ -117,8 +122,16 @@ class MonitorDumper(BaseDumper):
117 if dump_dir: 122 if dump_dir:
118 self.dump_dir = dump_dir 123 self.dump_dir = dump_dir
119 for cmd in self.cmds: 124 for cmd in self.cmds:
125 cmd_name = cmd.split()[0]
120 try: 126 try:
121 output = self.runner.run_monitor(cmd) 127 if len(cmd.split()) > 1:
122 self._write_dump(cmd, output) 128 cmd_args = cmd.split()[1]
123 except: 129 if "%s" in cmd_args:
124 print("Failed to dump QMP CMD: %s" % (cmd)) 130 filename = self._construct_filename(cmd_name)
131 cmd_data = json.loads(cmd_args % (filename))
132 output = self.runner.run_monitor(cmd_name, cmd_data)
133 else:
134 output = self.runner.run_monitor(cmd_name)
135 self._write_dump(cmd_name, output)
136 except Exception as e:
137 print("Failed to dump QMP CMD: %s with\nExecption: %s" % (cmd_name, e))