diff options
Diffstat (limited to 'meta/lib/oeqa/utils/dump.py')
-rw-r--r-- | meta/lib/oeqa/utils/dump.py | 23 |
1 files changed, 18 insertions, 5 deletions
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)) | ||