mirror of
https://git.yoctoproject.org/poky
synced 2026-06-01 00:59:48 +00:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
879545999f
commit
bb534a9c02
@@ -152,6 +152,8 @@ class QemuTarget(BaseTarget):
|
|||||||
|
|
||||||
self.target_dumper = TargetDumper(dump_target_cmds, dump_dir, self.runner)
|
self.target_dumper = TargetDumper(dump_target_cmds, dump_dir, self.runner)
|
||||||
self.monitor_dumper = MonitorDumper(dump_monitor_cmds, dump_dir, self.runner)
|
self.monitor_dumper = MonitorDumper(dump_monitor_cmds, dump_dir, self.runner)
|
||||||
|
if (self.monitor_dumper):
|
||||||
|
self.monitor_dumper.create_dir("qmp")
|
||||||
|
|
||||||
def deploy(self):
|
def deploy(self):
|
||||||
bb.utils.mkdirhier(self.testdir)
|
bb.utils.mkdirhier(self.testdir)
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class BaseDumper(object):
|
|||||||
# Some testing doesn't inherit testimage, so it is needed
|
# Some testing doesn't inherit testimage, so it is needed
|
||||||
# to set some defaults.
|
# to set some defaults.
|
||||||
self.parent_dir = parent_dir
|
self.parent_dir = parent_dir
|
||||||
|
self.dump_dir = parent_dir
|
||||||
dft_cmds = """ top -bn1
|
dft_cmds = """ top -bn1
|
||||||
iostat -x -z -N -d -p ALL 20 2
|
iostat -x -z -N -d -p ALL 20 2
|
||||||
ps -ef
|
ps -ef
|
||||||
@@ -47,7 +48,7 @@ class BaseDumper(object):
|
|||||||
raise err
|
raise err
|
||||||
self.dump_dir = dump_dir
|
self.dump_dir = dump_dir
|
||||||
|
|
||||||
def _write_dump(self, command, output):
|
def _construct_filename(self, command):
|
||||||
if isinstance(self, HostDumper):
|
if isinstance(self, HostDumper):
|
||||||
prefix = "host"
|
prefix = "host"
|
||||||
elif isinstance(self, TargetDumper):
|
elif isinstance(self, TargetDumper):
|
||||||
@@ -61,6 +62,10 @@ class BaseDumper(object):
|
|||||||
fullname = os.path.join(self.dump_dir, filename)
|
fullname = os.path.join(self.dump_dir, filename)
|
||||||
if not os.path.exists(fullname):
|
if not os.path.exists(fullname):
|
||||||
break
|
break
|
||||||
|
return fullname
|
||||||
|
|
||||||
|
def _write_dump(self, command, output):
|
||||||
|
fullname = self._construct_filename(command)
|
||||||
if isinstance(self, MonitorDumper):
|
if isinstance(self, MonitorDumper):
|
||||||
with open(fullname, 'w') as json_file:
|
with open(fullname, 'w') as json_file:
|
||||||
json.dump(output, json_file, indent=4)
|
json.dump(output, json_file, indent=4)
|
||||||
@@ -117,8 +122,16 @@ class MonitorDumper(BaseDumper):
|
|||||||
if dump_dir:
|
if dump_dir:
|
||||||
self.dump_dir = dump_dir
|
self.dump_dir = dump_dir
|
||||||
for cmd in self.cmds:
|
for cmd in self.cmds:
|
||||||
|
cmd_name = cmd.split()[0]
|
||||||
try:
|
try:
|
||||||
output = self.runner.run_monitor(cmd)
|
if len(cmd.split()) > 1:
|
||||||
self._write_dump(cmd, output)
|
cmd_args = cmd.split()[1]
|
||||||
except:
|
if "%s" in cmd_args:
|
||||||
print("Failed to dump QMP CMD: %s" % (cmd))
|
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))
|
||||||
|
|||||||
Reference in New Issue
Block a user