aboutsummaryrefslogtreecommitdiff
path: root/debug/testlib.py
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2023-07-06 14:41:02 -0700
committerTim Newsome <tim@sifive.com>2023-07-17 09:35:00 -0700
commitba831d02bdb4249ef744bd04da6c912680c7b66e (patch)
tree751ba413a8eb563a06772facfc74f2d60fc39072 /debug/testlib.py
parente1cb5be2709f461459b07221a15587e388fa90be (diff)
downloadriscv-tests-ba831d02bdb4249ef744bd04da6c912680c7b66e.zip
riscv-tests-ba831d02bdb4249ef744bd04da6c912680c7b66e.tar.gz
riscv-tests-ba831d02bdb4249ef744bd04da6c912680c7b66e.tar.bz2
debug: CeaseMultiTest -> UnavailableMultiTest
Use the new spike mechanism to test OpenOCD behavior when a hart becomes unavailable while running. Create CommandException.
Diffstat (limited to 'debug/testlib.py')
-rw-r--r--debug/testlib.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/debug/testlib.py b/debug/testlib.py
index 5c09f0a..fd9882a 100644
--- a/debug/testlib.py
+++ b/debug/testlib.py
@@ -652,6 +652,15 @@ def parse_rhs(text):
raise TestLibError(f"Unexpected input: {tokens!r}")
return result
+class CommandException(Exception):
+ pass
+
+class CommandSendTimeout(CommandException):
+ pass
+
+class CommandCompleteTimeout(CommandException):
+ pass
+
class Gdb:
"""A single gdb class which can interact with one or more gdb instances."""
@@ -780,8 +789,14 @@ class Gdb:
reset_delays=None)
timeout = max(1, ops) * self.timeout
self.active_child.sendline(command)
- self.active_child.expect("\n", timeout=timeout)
- self.active_child.expect(r"\(gdb\)", timeout=timeout)
+ try:
+ self.active_child.expect("\n", timeout=timeout)
+ except pexpect.exceptions.TIMEOUT as exc:
+ raise CommandSendTimeout(command) from exc
+ try:
+ self.active_child.expect(r"\(gdb\)", timeout=timeout)
+ except pexpect.exceptions.TIMEOUT as exc:
+ raise CommandCompleteTimeout(command) from exc
output = self.active_child.before.decode("utf-8", errors="ignore")
ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
return ansi_escape.sub('', output).strip()