diff options
author | Tim Newsome <tim@sifive.com> | 2016-10-18 14:21:02 -0700 |
---|---|---|
committer | Tim Newsome <tim@sifive.com> | 2016-10-18 14:21:02 -0700 |
commit | 5cd2b39a28c2c77debce4b55c140917c55dc1189 (patch) | |
tree | 95a9e94668a02a9a284d24d03c5fb279c26139d7 /debug/openocd.py | |
parent | f59770c98f8f3a7762e8a1751cca922ba8afe870 (diff) | |
download | riscv-tests-5cd2b39a28c2c77debce4b55c140917c55dc1189.zip riscv-tests-5cd2b39a28c2c77debce4b55c140917c55dc1189.tar.gz riscv-tests-5cd2b39a28c2c77debce4b55c140917c55dc1189.tar.bz2 |
Add framework to test OpenOCD directly.
This took a lot of refactoring to make it look reasonable.
There isn't actually any functional OpenOCD test yet. But a dummy test
runs a command (and fails).
Diffstat (limited to 'debug/openocd.py')
-rwxr-xr-x | debug/openocd.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/debug/openocd.py b/debug/openocd.py new file mode 100755 index 0000000..0c7e7d2 --- /dev/null +++ b/debug/openocd.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python + +"""Test that OpenOCD can talk to a RISC-V target.""" + +import argparse +import sys + +import targets +import testlib +from testlib import assertGreater + +class OpenOcdTest(testlib.BaseTest): + def __init__(self, target): + testlib.BaseTest.__init__(self, target) + self.gdb = None + + def early_applicable(self): + return self.target.openocd_config + + def setup(self): + # pylint: disable=attribute-defined-outside-init + self.cli = testlib.OpenocdCli() + +class RegTest(OpenOcdTest): + def test(self): + output = self.cli.command("reg") + assertGreater(len(output), 1) + +def main(): + parser = argparse.ArgumentParser( + description="Test that OpenOCD can talk to a RISC-V target.") + targets.add_target_options(parser) + testlib.add_test_run_options(parser) + + parsed = parser.parse_args() + + target = parsed.target(parsed.cmd, parsed.run, parsed.isolate) + if parsed.xlen: + target.xlen = parsed.xlen + + module = sys.modules[__name__] + + return testlib.run_all_tests(module, target, parsed.test, parsed.fail_fast) + +if __name__ == '__main__': + sys.exit(main()) |