From acc87e14d9a6e4e6c3f019e79cb5c047162228c1 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Fri, 5 Oct 2018 12:28:32 -0700 Subject: Make HwWatchpoint test fail on incorrect result. Also tiny cleanups, making pylint happy. --- debug/gdbserver.py | 13 ++++++++----- debug/programs/counting_loop.c | 2 +- debug/testlib.py | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/debug/gdbserver.py b/debug/gdbserver.py index eaf390f..e17cf8d 100755 --- a/debug/gdbserver.py +++ b/debug/gdbserver.py @@ -306,7 +306,8 @@ class InstantChangePc(GdbTest): class ProgramTest(GdbSingleHartTest): # Include malloc so that gdb can make function calls. I suspect this malloc # will silently blow through the memory set aside for it, so be careful. - compile_args = ("programs/counting_loop.c", "-DDEFINE_MALLOC", "-DDEFINE_FREE") + compile_args = ("programs/counting_loop.c", "-DDEFINE_MALLOC", + "-DDEFINE_FREE") def setup(self): self.gdb.load() @@ -325,10 +326,12 @@ class ProgramHwWatchpoint(ProgramTest): assertIn("Breakpoint", output) assertIn("main", output) self.gdb.watch("counter == 5") - # Currently the watchpoint is generating a trap at init and all updates - for _ in range(11): - output = self.gdb.c() - assertIn("Trace/breakpoint trap", output) + # Watchpoint hits when counter becomes 5. + output = self.gdb.c() + assertEqual(self.gdb.p("counter"), 5) + # Watchpoint hits when counter no longer is 5. + output = self.gdb.c() + assertEqual(self.gdb.p("counter"), 6) # The watchpoint is going out of scope output = self.gdb.c() assertIn("Watchpoint", output) diff --git a/debug/programs/counting_loop.c b/debug/programs/counting_loop.c index 2116e52..7c7d600 100644 --- a/debug/programs/counting_loop.c +++ b/debug/programs/counting_loop.c @@ -5,7 +5,7 @@ int main() { - int sum = 0; + int sum = 0; int counter = 0; while (counter < 10) { diff --git a/debug/testlib.py b/debug/testlib.py index 76f09f9..d278692 100644 --- a/debug/testlib.py +++ b/debug/testlib.py @@ -594,7 +594,7 @@ class Gdb(object): return output def swatch(self, expr): - hstate = self.command("show can-use-hw-watchpoints") + self.command("show can-use-hw-watchpoints") self.command("set can-use-hw-watchpoints 0") output = self.command("watch %s" % expr, ops=5) assert "not defined" not in output -- cgit v1.1