+ def threads(self):
+ output = self.command("info threads")
+ threads = []
+ for line in output.splitlines():
+ m = re.match(
+ r"[\s\*]*(\d+)\s*"
+ r"(Remote target|Thread (\d+)\s*\(Name: ([^\)]+))"
+ r"\s*(.*)", line)
+ if m:
+ threads.append(Thread(*m.groups()))
+ assert threads
+ #>>>if not threads:
+ #>>> threads.append(Thread('1', '1', 'Default', '???'))
+ return threads
+
+ def thread(self, thread):
+ return self.command("thread %s" % thread.id)
+
+ def where(self):
+ return self.command("where 1")
+
+class PrivateState(object):
+ def __init__(self, gdb):
+ self.gdb = gdb
+
+ def __enter__(self):
+ self.gdb.push_state()
+
+ def __exit__(self, _type, _value, _traceback):
+ self.gdb.pop_state()
+
+def run_all_tests(module, target, parsed):
+ if not os.path.exists(parsed.logs):
+ os.makedirs(parsed.logs)
+
+ overall_start = time.time()
+
+ global gdb_cmd # pylint: disable=global-statement
+ gdb_cmd = parsed.gdb
+
+ todo = []
+ examine_added = False
+ for hart in target.harts:
+ if parsed.misaval:
+ hart.misa = int(parsed.misaval, 16)
+ print "Using $misa from command line: 0x%x" % hart.misa
+ elif hart.misa:
+ print "Using $misa from hart definition: 0x%x" % hart.misa
+ elif not examine_added:
+ todo.append(("ExamineTarget", ExamineTarget, None))
+ examine_added = True
+
+ for name in dir(module):
+ definition = getattr(module, name)
+ if isinstance(definition, type) and hasattr(definition, 'test') and \
+ (not parsed.test or any(test in name for test in parsed.test)):
+ todo.append((name, definition, None))
+
+ results, count = run_tests(parsed, target, todo)