diff options
author | cgsfv <cgsfv@users.noreply.github.com> | 2018-11-13 11:56:10 +0100 |
---|---|---|
committer | cgsfv <cgsfv@users.noreply.github.com> | 2018-11-13 11:56:10 +0100 |
commit | 94a29da063eecda0f37f9f6a97ffb39a47825b35 (patch) | |
tree | a36865653e79e439f0dd7addce1e64599b5263d6 /debug/gdbserver.py | |
parent | ee6c720e4db50b73dd8f45c70a6868b88cd4a8b1 (diff) | |
download | riscv-tests-94a29da063eecda0f37f9f6a97ffb39a47825b35.zip riscv-tests-94a29da063eecda0f37f9f6a97ffb39a47825b35.tar.gz riscv-tests-94a29da063eecda0f37f9f6a97ffb39a47825b35.tar.bz2 |
Added MemTestBlockReadInvalid verifying the corresponding OpenOCD fix
Diffstat (limited to 'debug/gdbserver.py')
-rwxr-xr-x | debug/gdbserver.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/debug/gdbserver.py b/debug/gdbserver.py index b6e7cf9..05a57cb 100755 --- a/debug/gdbserver.py +++ b/debug/gdbserver.py @@ -232,6 +232,58 @@ class MemTest64(SimpleMemoryTest): # assertEqual(e.address, 0xdeadbeef) # self.gdb.p("*((int*)0x%x)=6874742" % self.hart.ram) +class MemTestBlockReadInvalid(GdbTest): + zero_values = "00 00 00 00 00 00 00 00" + real_values = "EF BE AD DE 78 56 34 12" + + def early_applicable(self): + return self.target.uses_dtm_version_013 + + def test(self): + self.gdb.p("*((int*)0x%x) = 0xdeadbeef" % (self.hart.ram + 0)) + self.gdb.p("*((int*)0x%x) = 0x12345678" % (self.hart.ram + 4)) + + # read before start of memory + self.memory_test(self.hart.ram - 8, + self.hart.ram, + self.zero_values) + + # read across start of memory + self.memory_test(self.hart.ram - 8, + self.hart.ram + 8, + self.zero_values + " " + self.real_values) + + # read after start of memory + self.memory_test(self.hart.ram, + self.hart.ram + 8, + self.real_values) + + self.gdb.p("*((int*)0x%x) = 0xdeadbeef" % (self.hart.ram + self.hart.ram_size - 8)) + self.gdb.p("*((int*)0x%x) = 0x12345678" % (self.hart.ram + self.hart.ram_size - 4)) + + # read before end of memory + self.memory_test(self.hart.ram + self.hart.ram_size - 8, + self.hart.ram + self.hart.ram_size, + self.real_values) + + # read across end of memory + self.memory_test(self.hart.ram + self.hart.ram_size - 8, + self.hart.ram + self.hart.ram_size + 8, + self.real_values + " " + self.zero_values) + + # read after end of memory + self.memory_test(self.hart.ram + self.hart.ram_size, + self.hart.ram + self.hart.ram_size + 8, + self.zero_values) + + def memory_test(self, start_addr, end_addr, expected_values): + dump = tempfile.NamedTemporaryFile(suffix=".simdata") + self.gdb.command("dump verilog memory %s 0x%x 0x%x" % (dump.name, start_addr, end_addr)) + self.gdb.command("shell cat %s" % dump.name) + line = dump.readline() + line = dump.readline() + assertEqual(line.strip(' \t\n\r'), expected_values) + class MemTestBlock(GdbTest): length = 1024 line_length = 16 |