0c7e7d2a277a5c71d1cf1f067aa5ca4efcdffc7c
[riscv-tests.git] / debug / openocd.py
1 #!/usr/bin/env python
2
3 """Test that OpenOCD can talk to a RISC-V target."""
4
5 import argparse
6 import sys
7
8 import targets
9 import testlib
10 from testlib import assertGreater
11
12 class OpenOcdTest(testlib.BaseTest):
13 def __init__(self, target):
14 testlib.BaseTest.__init__(self, target)
15 self.gdb = None
16
17 def early_applicable(self):
18 return self.target.openocd_config
19
20 def setup(self):
21 # pylint: disable=attribute-defined-outside-init
22 self.cli = testlib.OpenocdCli()
23
24 class RegTest(OpenOcdTest):
25 def test(self):
26 output = self.cli.command("reg")
27 assertGreater(len(output), 1)
28
29 def main():
30 parser = argparse.ArgumentParser(
31 description="Test that OpenOCD can talk to a RISC-V target.")
32 targets.add_target_options(parser)
33 testlib.add_test_run_options(parser)
34
35 parsed = parser.parse_args()
36
37 target = parsed.target(parsed.cmd, parsed.run, parsed.isolate)
38 if parsed.xlen:
39 target.xlen = parsed.xlen
40
41 module = sys.modules[__name__]
42
43 return testlib.run_all_tests(module, target, parsed.test, parsed.fail_fast)
44
45 if __name__ == '__main__':
46 sys.exit(main())