From ba831d02bdb4249ef744bd04da6c912680c7b66e Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Thu, 6 Jul 2023 14:41:02 -0700 Subject: debug: CeaseMultiTest -> UnavailableMultiTest Use the new spike mechanism to test OpenOCD behavior when a hart becomes unavailable while running. Create CommandException. --- debug/gdbserver.py | 19 +++++++++++++------ debug/testlib.py | 19 +++++++++++++++++-- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/debug/gdbserver.py b/debug/gdbserver.py index 04180c3..bf04f2e 100755 --- a/debug/gdbserver.py +++ b/debug/gdbserver.py @@ -19,7 +19,7 @@ from testlib import assertGreater, assertRegex, assertLess from testlib import GdbTest, GdbSingleHartTest, TestFailed from testlib import TestNotApplicable, CompileError from testlib import UnknownThread -from testlib import CouldNotReadRegisters +from testlib import CouldNotReadRegisters, CommandException MSTATUS_UIE = 0x00000001 MSTATUS_SIE = 0x00000002 @@ -1807,14 +1807,16 @@ class EbreakTest(GdbSingleHartTest): output = self.gdb.c() assertIn("_exit", output) -class CeaseMultiTest(GdbTest): - """Test that we work correctly when a hart ceases to respond (e.g. because +class UnavailableMultiTest(GdbTest): + """Test that we work correctly when a hart becomes unavailable (e.g. because it's powered down).""" compile_args = ("programs/counting_loop.c", "-DDEFINE_MALLOC", "-DDEFINE_FREE") def early_applicable(self): - return self.hart.support_cease and len(self.target.harts) > 1 + return (self.hart.support_cease or + self.target.support_unavailable_control) \ + and len(self.target.harts) > 1 def setup(self): ProgramTest.setup(self) @@ -1822,7 +1824,12 @@ class CeaseMultiTest(GdbTest): def test(self): # Run all the way to the infinite loop in exit - self.gdb.c(wait=False) + self.gdb.c_all(wait=False) + # Other hart should have become unavailable. + if self.target.support_unavailable_control: + self.server.wait_until_running(self.target.harts) + self.server.command( + f"riscv dmi_write 0x1f 0x{(1<