aboutsummaryrefslogtreecommitdiff
path: root/debug/gdbserver.py
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2019-03-11 08:43:14 -0700
committerGitHub <noreply@github.com>2019-03-11 08:43:14 -0700
commit4f784ca9b8d3536c16061518c1c2b66e3118cc5c (patch)
tree6d801e89c8836a84ab41646267b8c7170c3326eb /debug/gdbserver.py
parent26d821d126fd0e36bf286420452f5628c946e7cb (diff)
downloadriscv-tests-4f784ca9b8d3536c16061518c1c2b66e3118cc5c.zip
riscv-tests-4f784ca9b8d3536c16061518c1c2b66e3118cc5c.tar.gz
riscv-tests-4f784ca9b8d3536c16061518c1c2b66e3118cc5c.tar.bz2
Add SmpSimultaneousRunHalt test. (#181)
This test confirms that in SMP configurations OpenOCD halts the harts near-simulatenously. (It'll also check for resume, but that's not implemented yet so commented out for now.)
Diffstat (limited to 'debug/gdbserver.py')
-rwxr-xr-xdebug/gdbserver.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/debug/gdbserver.py b/debug/gdbserver.py
index adcb6b2..e7f0701 100755
--- a/debug/gdbserver.py
+++ b/debug/gdbserver.py
@@ -842,6 +842,55 @@ class MulticoreRtosSwitchActiveHartTest(GdbTest):
assertIn("set_trap_handler", output)
assertNotIn("received signal SIGTRAP", output)
+class SmpSimultaneousRunHalt(GdbTest):
+ compile_args = ("programs/run_halt_timing.c", "-DMULTICORE")
+
+ def early_applicable(self):
+ return len(self.target.harts) > 1
+
+ def setup(self):
+ self.gdb.select_hart(self.target.harts[0])
+ self.gdb.load()
+ for hart in self.target.harts:
+ self.gdb.select_hart(hart)
+ self.gdb.p("$pc=_start")
+
+ def test(self):
+ if self.gdb.one_hart_per_gdb() or not self.server.smp():
+ return 'not_applicable'
+
+ old_mtime = set()
+ for _ in range(5):
+ self.gdb.c_all(wait=False)
+ time.sleep(2)
+ self.gdb.interrupt_all()
+
+ mtime_value = []
+ counter = []
+ for hart in self.target.harts:
+ self.gdb.select_hart(hart)
+ mv = self.gdb.p("mtime_value")
+ assertNotIn(mv, old_mtime,
+ "mtime doesn't appear to be changing at all")
+ mtime_value.append(mv)
+ c = self.gdb.p("counter")
+ assertNotEqual(c, 0,
+ "counter didn't increment; code didn't run?")
+ counter.append(c)
+ self.gdb.p("counter=0")
+
+ old_mtime.update(mtime_value)
+
+ mtime_spread = max(mtime_value) - min(mtime_value)
+ print "mtime_spread:", mtime_spread
+ counter_spread = max(counter) - min(counter)
+ print "counter_spread:", counter_spread
+
+ assertLess(mtime_spread, 100 * len(self.target.harts),
+ "Harts don't halt around the same time.")
+#TODO assertLess(counter_spread, 100 * len(self.target.harts),
+#TODO "Harts don't resume around the same time.")
+
class StepTest(GdbSingleHartTest):
compile_args = ("programs/step.S", )