From a5d8386eb08cd47df56bf8170bcaf9e1f9b92c13 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Mon, 31 Aug 2020 13:23:18 -0700 Subject: Add test for `riscv repeat_read`. (#293) --- debug/gdbserver.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'debug') diff --git a/debug/gdbserver.py b/debug/gdbserver.py index bd3d2d6..5a0c378 100755 --- a/debug/gdbserver.py +++ b/debug/gdbserver.py @@ -764,6 +764,40 @@ class UserInterrupt(DebugTest): self.gdb.p("i=0") self.exit() +class RepeatReadTest(DebugTest): + def early_applicable(self): + return self.target.supports_clint_mtime + + def test(self): + self.gdb.b("main:start") + self.gdb.c() + mtime_addr = 0x02000000 + 0xbff8 + count = 1024 + output = self.gdb.command("monitor riscv repeat_read %d 0x%x 4" % + (count, mtime_addr)) + values = [] + for line in output.splitlines(): + # Ignore warnings + if line.startswith("Batch memory"): + continue + for v in line.split(): + values.append(int(v, 16)) + + assertEqual(len(values), count) + # mtime should only ever increase, unless it wraps + slop = 0x100000 + for i in range(1, len(values)): + if values[i] < values[i-1]: + # wrapped + assertLess(values[i], slop) + else: + assertGreater(values[i], values[i-1]) + assertLess(values[i], values[i-1] + slop) + + output = self.gdb.command("monitor riscv repeat_read 0 0x%x 4" % + mtime_addr) + assertEqual(output, "") + class Semihosting(GdbSingleHartTest): # Include malloc so that gdb can assign a string. compile_args = ("programs/semihosting.c", "programs/tiny-malloc.c", -- cgit v1.1