diff options
author | Tim Newsome <tim@sifive.com> | 2020-05-26 12:37:09 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-26 12:37:09 -0700 |
commit | fbe74f48e16be28a2b360e8a9e845b01d9e4b167 (patch) | |
tree | 869b79d740a4c5f405f35eb0cab9275ea7da47e0 /debug/gdbserver.py | |
parent | bc4c1d2866b896f6234d19111993fae4a9f47d74 (diff) | |
download | riscv-tests-fbe74f48e16be28a2b360e8a9e845b01d9e4b167.zip riscv-tests-fbe74f48e16be28a2b360e8a9e845b01d9e4b167.tar.gz riscv-tests-fbe74f48e16be28a2b360e8a9e845b01d9e4b167.tar.bz2 |
Test semihosting calls (#280)
* Add a basic semihosting test.
* Need to configure semihosting on each target.
* WIP
* Parse "cannot insert breakpoint" message.
Also use sys.exit instead of exit, per new pylint's suggestion.
Diffstat (limited to 'debug/gdbserver.py')
-rwxr-xr-x | debug/gdbserver.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/debug/gdbserver.py b/debug/gdbserver.py index ca5855a..dd9e129 100755 --- a/debug/gdbserver.py +++ b/debug/gdbserver.py @@ -672,6 +672,38 @@ class UserInterrupt(DebugTest): self.gdb.p("i=0") self.exit() +class Semihosting(GdbSingleHartTest): + # Include malloc so that gdb can assign a string. + compile_args = ("programs/semihosting.c", "programs/tiny-malloc.c", + "-DDEFINE_MALLOC", "-DDEFINE_FREE") + + def early_applicable(self): + return self.target.test_semihosting + + def setup(self): + self.gdb.load() + self.parkOtherHarts() + self.gdb.b("_exit") + + def exit(self, expected_result=0): + output = self.gdb.c() + assertIn("Breakpoint", output) + assertIn("_exit", output) + assertEqual(self.gdb.p("status"), expected_result) + + def test(self): + """Sending gdb ^C while the program is running should cause it to + halt.""" + temp = tempfile.NamedTemporaryFile(suffix=".data") + + self.gdb.b("main:begin") + self.gdb.c() + self.gdb.p('filename="%s"' % temp.name) + self.exit() + + contents = open(temp.name, "r").readlines() + assertIn("Hello, world!\n", contents) + class InterruptTest(GdbSingleHartTest): compile_args = ("programs/interrupt.c",) |