Skip to content

Commit a87b27f

Browse files
authored
[lldb] Fix the hardware breakpoint decorator (#146609)
A decorator to skip or XFAIL a test takes effect when the function that's passed in returns a reason string. The wrappers around hw_breakpoints_supported were doing that incorrectly by inverting (calling `not`) on the result, turning it into a boolean, which means the test is always skipped.
1 parent 7502af8 commit a87b27f

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

lldb/test/API/functionalities/breakpoint/hardware_breakpoints/base.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,15 @@ def supports_hw_breakpoints(self):
1414
self.runCmd("breakpoint set -b main --hardware")
1515
self.runCmd("run")
1616
if "stopped" in self.res.GetOutput():
17+
return True
18+
return False
19+
20+
def hw_breakpoints_supported(self):
21+
if self.supports_hw_breakpoints():
1722
return "Hardware breakpoints are supported"
1823
return None
24+
25+
def hw_breakpoints_unsupported(self):
26+
if not self.supports_hw_breakpoints():
27+
return "Hardware breakpoints are unsupported"
28+
return None

lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,13 @@
1212

1313

1414
class HardwareBreakpointMultiThreadTestCase(HardwareBreakpointTestBase):
15-
def does_not_support_hw_breakpoints(self):
16-
return not super().supports_hw_breakpoints()
17-
18-
@skipTestIfFn(does_not_support_hw_breakpoints)
15+
@skipTestIfFn(HardwareBreakpointTestBase.hw_breakpoints_unsupported)
1916
def test_hw_break_set_delete_multi_thread_macos(self):
2017
self.build()
2118
self.setTearDownCleanup()
2219
self.break_multi_thread("delete")
2320

24-
@skipTestIfFn(does_not_support_hw_breakpoints)
21+
@skipTestIfFn(HardwareBreakpointTestBase.hw_breakpoints_unsupported)
2522
def test_hw_break_set_disable_multi_thread_macos(self):
2623
self.build()
2724
self.setTearDownCleanup()

lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_breakpoint(self):
2626
breakpoint = target.BreakpointCreateByLocation("main.c", 1)
2727
self.assertTrue(breakpoint.IsHardware())
2828

29-
@skipTestIfFn(HardwareBreakpointTestBase.supports_hw_breakpoints)
29+
@skipTestIfFn(HardwareBreakpointTestBase.hw_breakpoints_supported)
3030
def test_step_range(self):
3131
"""Test stepping when hardware breakpoints are required."""
3232
self.build()
@@ -49,7 +49,7 @@ def test_step_range(self):
4949
"Could not create hardware breakpoint for thread plan", error.GetCString()
5050
)
5151

52-
@skipTestIfFn(HardwareBreakpointTestBase.supports_hw_breakpoints)
52+
@skipTestIfFn(HardwareBreakpointTestBase.hw_breakpoints_supported)
5353
def test_step_out(self):
5454
"""Test stepping out when hardware breakpoints are required."""
5555
self.build()
@@ -71,7 +71,7 @@ def test_step_out(self):
7171
"Could not create hardware breakpoint for thread plan", error.GetCString()
7272
)
7373

74-
@skipTestIfFn(HardwareBreakpointTestBase.supports_hw_breakpoints)
74+
@skipTestIfFn(HardwareBreakpointTestBase.hw_breakpoints_supported)
7575
def test_step_over(self):
7676
"""Test stepping over when hardware breakpoints are required."""
7777
self.build()
@@ -91,7 +91,7 @@ def test_step_over(self):
9191

9292
# Was reported to sometimes pass on certain hardware.
9393
@skipIf(oslist=["linux"], archs=["arm$"])
94-
@skipTestIfFn(HardwareBreakpointTestBase.supports_hw_breakpoints)
94+
@skipTestIfFn(HardwareBreakpointTestBase.hw_breakpoints_supported)
9595
def test_step_until(self):
9696
"""Test stepping until when hardware breakpoints are required."""
9797
self.build()

lldb/test/API/functionalities/breakpoint/hardware_breakpoints/write_memory_with_hw_breakpoint/TestWriteMemoryWithHWBreakpoint.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212

1313

1414
class WriteMemoryWithHWBreakpoint(HardwareBreakpointTestBase):
15-
def does_not_support_hw_breakpoints(self):
16-
return not super().supports_hw_breakpoints()
1715

18-
@skipTestIfFn(does_not_support_hw_breakpoints)
16+
@skipTestIfFn(HardwareBreakpointTestBase.supports_hw_breakpoints)
17+
@skip
1918
def test_copy_memory_with_hw_break(self):
2019
self.build()
2120
exe = self.getBuildArtifact("a.out")

0 commit comments

Comments
 (0)