1919from testlib import GdbTest , GdbSingleHartTest , TestFailed
2020from testlib import TestNotApplicable , CompileError
2121from testlib import UnknownThread
22- from testlib import CouldNotReadRegisters
22+ from testlib import CouldNotReadRegisters , CommandException
2323
2424MSTATUS_UIE = 0x00000001
2525MSTATUS_SIE = 0x00000002
@@ -1807,22 +1807,29 @@ def test(self):
18071807 output = self .gdb .c ()
18081808 assertIn ("_exit" , output )
18091809
1810- class CeaseMultiTest (GdbTest ):
1811- """Test that we work correctly when a hart ceases to respond (e.g. because
1810+ class UnavailableMultiTest (GdbTest ):
1811+ """Test that we work correctly when a hart becomes unavailable (e.g. because
18121812 it's powered down)."""
18131813 compile_args = ("programs/counting_loop.c" , "-DDEFINE_MALLOC" ,
18141814 "-DDEFINE_FREE" )
18151815
18161816 def early_applicable (self ):
1817- return self .hart .support_cease and len (self .target .harts ) > 1
1817+ return (self .hart .support_cease or
1818+ self .target .support_unavailable_control ) \
1819+ and len (self .target .harts ) > 1
18181820
18191821 def setup (self ):
18201822 ProgramTest .setup (self )
18211823 self .parkOtherHarts ()
18221824
18231825 def test (self ):
18241826 # Run all the way to the infinite loop in exit
1825- self .gdb .c (wait = False )
1827+ self .gdb .c_all (wait = False )
1828+ # Other hart should have become unavailable.
1829+ if self .target .support_unavailable_control :
1830+ self .server .wait_until_running (self .target .harts )
1831+ self .server .command (
1832+ f"riscv dmi_write 0x1f 0x{ (1 << self .hart .id )& 0x3 :x} " )
18261833 self .gdb .expect (r"\S+ became unavailable." )
18271834 self .gdb .interrupt ()
18281835
@@ -1834,7 +1841,7 @@ def test(self):
18341841 self .gdb .p ("$misa" )
18351842 assert False , \
18361843 "Shouldn't be able to access unavailable hart."
1837- except UnknownThread :
1844+ except ( UnknownThread , CommandException ) :
18381845 pass
18391846
18401847 # Check that the main hart can still be debugged.
0 commit comments