Skip to content

Commit ed0a63e

Browse files
authored
Merge pull request #486 from en-sc/en-sc/warning-repeat-read
change warning check in RepeatReadTest
2 parents fb7a4a7 + 4b18e07 commit ed0a63e

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

debug/gdbserver.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import time
1010
import os
1111
import re
12+
import itertools
1213

1314
import targets
1415
import testlib
@@ -904,6 +905,9 @@ class RepeatReadTest(DebugTest):
904905
def early_applicable(self):
905906
return self.target.supports_clint_mtime
906907

908+
warning_re = re.compile(r"\[(?P<target_name>[^\]]+)\] Re-reading memory "
909+
r"from addresses 0x(?P<addr>[\da-f]+) and 0x(?P=addr)\.")
910+
907911
def test(self):
908912
self.gdb.b("main:start")
909913
self.gdb.c()
@@ -912,8 +916,17 @@ def test(self):
912916
output = self.gdb.command(
913917
f"monitor riscv repeat_read {count} 0x{mtime_addr:x} 4")
914918
values = []
915-
for line in output.splitlines():
916-
# Ignore warnings
919+
def is_valid_warning(line):
920+
match = self.warning_re.match(line)
921+
if match is None:
922+
return False
923+
assertEqual(int(match["addr"], 16), mtime_addr,
924+
"The repeat read is reading from the wrong address")
925+
return True
926+
927+
for line in itertools.dropwhile(is_valid_warning, output.splitlines()):
928+
# This `if` is to be removed after
929+
# https://github.com/riscv/riscv-openocd/pull/871 is merged.
917930
if line.startswith("Batch memory"):
918931
continue
919932
for v in line.split():

0 commit comments

Comments
 (0)