aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2020-12-18 12:56:13 -0800
committerGitHub <noreply@github.com>2020-12-18 12:56:13 -0800
commitf7e9ef1008cbdf1c04ad9eb0ccf14e09ed53f3b2 (patch)
tree9b9a9e014b6858f15a06bade5425fe2377404267
parentb0b3d24db5e85fd07a608f179de1714cef2ae944 (diff)
downloadriscv-tests-f7e9ef1008cbdf1c04ad9eb0ccf14e09ed53f3b2.zip
riscv-tests-f7e9ef1008cbdf1c04ad9eb0ccf14e09ed53f3b2.tar.gz
riscv-tests-f7e9ef1008cbdf1c04ad9eb0ccf14e09ed53f3b2.tar.bz2
Revive and expand invalid read test. (#309)
This test would have found https://github.com/riscv/riscv-openocd/issues/559.
-rwxr-xr-xdebug/gdbserver.py31
1 files changed, 19 insertions, 12 deletions
diff --git a/debug/gdbserver.py b/debug/gdbserver.py
index 3ccaf2f..7aec49a 100755
--- a/debug/gdbserver.py
+++ b/debug/gdbserver.py
@@ -238,18 +238,25 @@ class MemTest64(SimpleMemoryTest):
def test(self):
self.access_test(8, 'long long')
-# FIXME: I'm not passing back invalid addresses correctly in read/write memory.
-#class MemTestReadInvalid(SimpleMemoryTest):
-# def test(self):
-# # This test relies on 'gdb_report_data_abort enable' being executed in
-# # the openocd.cfg file.
-# try:
-# self.gdb.p("*((int*)0xdeadbeef)")
-# assert False, "Read should have failed."
-# except testlib.CannotAccess as e:
-# assertEqual(e.address, 0xdeadbeef)
-# self.gdb.p("*((int*)0x%x)" % self.hart.ram)
-#
+class MemTestReadInvalid(SimpleMemoryTest):
+ def test(self):
+ bad_address = self.hart.ram - 8
+ good_address = self.hart.ram + 0x80
+
+ self.write_nop_program(2)
+ self.gdb.p("$s0=0x12345678")
+ self.gdb.p("*((int*)0x%x)=0xabcdef" % good_address)
+ # This test relies on 'gdb_report_data_abort enable' being executed in
+ # the openocd.cfg file.
+ try:
+ self.gdb.p("*((int*)0x%x)" % bad_address)
+ assert False, "Read should have failed."
+ except testlib.CannotAccess as e:
+ assertEqual(e.address, bad_address)
+ self.gdb.stepi() # Don't let gdb cache register read
+ assertEqual(self.gdb.p("*((int*)0x%x)" % good_address), 0xabcdef)
+ assertEqual(self.gdb.p("$s0"), 0x12345678)
+
#class MemTestWriteInvalid(SimpleMemoryTest):
# def test(self):
# # This test relies on 'gdb_report_data_abort enable' being executed in