summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils/dump.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/utils/dump.py')
-rw-r--r--meta/lib/oeqa/utils/dump.py32
1 files changed, 29 insertions, 3 deletions
diff --git a/meta/lib/oeqa/utils/dump.py b/meta/lib/oeqa/utils/dump.py
index 09a44329e0..843e19fe8a 100644
--- a/meta/lib/oeqa/utils/dump.py
+++ b/meta/lib/oeqa/utils/dump.py
@@ -4,6 +4,7 @@
4 4
5import os 5import os
6import sys 6import sys
7import json
7import errno 8import errno
8import datetime 9import datetime
9import itertools 10import itertools
@@ -51,6 +52,8 @@ class BaseDumper(object):
51 prefix = "host" 52 prefix = "host"
52 elif isinstance(self, TargetDumper): 53 elif isinstance(self, TargetDumper):
53 prefix = "target" 54 prefix = "target"
55 elif isinstance(self, MonitorDumper):
56 prefix = "qmp"
54 else: 57 else:
55 prefix = "unknown" 58 prefix = "unknown"
56 for i in itertools.count(): 59 for i in itertools.count():
@@ -58,9 +61,12 @@ class BaseDumper(object):
58 fullname = os.path.join(self.dump_dir, filename) 61 fullname = os.path.join(self.dump_dir, filename)
59 if not os.path.exists(fullname): 62 if not os.path.exists(fullname):
60 break 63 break
61 with open(fullname, 'w') as dump_file: 64 if isinstance(self, MonitorDumper):
62 dump_file.write(output) 65 with open(fullname, 'w') as json_file:
63 66 json.dump(output, json_file, indent=4)
67 else:
68 with open(fullname, 'w') as dump_file:
69 dump_file.write(output)
64 70
65class HostDumper(BaseDumper): 71class HostDumper(BaseDumper):
66 """ Class to get dumps from the host running the tests """ 72 """ Class to get dumps from the host running the tests """
@@ -96,3 +102,23 @@ class TargetDumper(BaseDumper):
96 except: 102 except:
97 print("Tried to dump info from target but " 103 print("Tried to dump info from target but "
98 "serial console failed") 104 "serial console failed")
105 print("Failed CMD: %s" % (cmd))
106
107class MonitorDumper(BaseDumper):
108 """ Class to get dumps via the Qemu Monitor, it only works with QemuRunner """
109
110 def __init__(self, cmds, parent_dir, runner):
111 super(MonitorDumper, self).__init__(cmds, parent_dir)
112 self.runner = runner
113
114 def dump_monitor(self, dump_dir=""):
115 if self.runner is None:
116 return
117 if dump_dir:
118 self.dump_dir = dump_dir
119 for cmd in self.cmds:
120 try:
121 output = self.runner.run_monitor(cmd)
122 self._write_dump(cmd, output)
123 except:
124 print("Failed to dump QMP CMD: %s" % (cmd))