diff options
author | Tim Newsome <tim@sifive.com> | 2016-10-20 14:49:44 -0700 |
---|---|---|
committer | Tim Newsome <tim@sifive.com> | 2016-10-20 14:49:44 -0700 |
commit | 30d113085a08b0cde585c7e0d8b19e0cc6cbc046 (patch) | |
tree | 5cee22b799bef59fc44a8fdd26aebe994cfb34b4 /debug/testlib.py | |
parent | df47c4655a50983d03db186f524f50af0dc828c8 (diff) | |
download | riscv-tests-30d113085a08b0cde585c7e0d8b19e0cc6cbc046.zip riscv-tests-30d113085a08b0cde585c7e0d8b19e0cc6cbc046.tar.gz riscv-tests-30d113085a08b0cde585c7e0d8b19e0cc6cbc046.tar.bz2 |
Test OpenOCD step and resume.
Diffstat (limited to 'debug/testlib.py')
-rw-r--r-- | debug/testlib.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/debug/testlib.py b/debug/testlib.py index 100b124..a38b99b 100644 --- a/debug/testlib.py +++ b/debug/testlib.py @@ -173,9 +173,23 @@ class OpenocdCli(object): def command(self, cmd): self.child.sendline(cmd) + self.child.expect(cmd) self.child.expect("\n") self.child.expect("> ") - return self.child.before.strip() + return self.child.before.strip("\t\r\n \0") + + def reg(self, reg=''): + output = self.command("reg %s" % reg) + matches = re.findall(r"(\w+) \(/\d+\): (0x[0-9A-F]+)", output) + values = {r: int(v, 0) for r, v in matches} + if reg: + return values[reg] + return values + + def load_image(self, image): + output = self.command("load_image %s" % image) + if 'invalid ELF file, only 32bits files are supported' in output: + raise TestNotApplicable(output) class CannotAccess(Exception): def __init__(self, address): @@ -372,6 +386,8 @@ class BaseTest(object): try: self.setup() result = self.test() # pylint: disable=no-member + except TestNotApplicable: + result = "not_applicable" except Exception as e: # pylint: disable=broad-except if isinstance(e, TestFailed): result = "fail" @@ -403,6 +419,11 @@ class TestFailed(Exception): Exception.__init__(self) self.message = message +class TestNotApplicable(Exception): + def __init__(self, message): + Exception.__init__(self) + self.message = message + def assertEqual(a, b): if a != b: raise TestFailed("%r != %r" % (a, b)) |