[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.
diff --git a/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/base.py b/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/base.py
index 0ab5dd0..0ad903b 100644
--- a/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/base.py
+++ b/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/base.py
@@ -14,5 +14,15 @@
self.runCmd("breakpoint set -b main --hardware")
self.runCmd("run")
if "stopped" in self.res.GetOutput():
+ return True
+ return False
+
+ def hw_breakpoints_supported(self):
+ if self.supports_hw_breakpoints():
return "Hardware breakpoints are supported"
return None
+
+ def hw_breakpoints_unsupported(self):
+ if not self.supports_hw_breakpoints():
+ return "Hardware breakpoints are unsupported"
+ return None
diff --git a/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py b/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
index 1a0515a..4632c3b 100644
--- a/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
+++ b/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
@@ -12,16 +12,13 @@
class HardwareBreakpointMultiThreadTestCase(HardwareBreakpointTestBase):
- def does_not_support_hw_breakpoints(self):
- return not super().supports_hw_breakpoints()
-
- @skipTestIfFn(does_not_support_hw_breakpoints)
+ @skipTestIfFn(HardwareBreakpointTestBase.hw_breakpoints_unsupported)
def test_hw_break_set_delete_multi_thread_macos(self):
self.build()
self.setTearDownCleanup()
self.break_multi_thread("delete")
- @skipTestIfFn(does_not_support_hw_breakpoints)
+ @skipTestIfFn(HardwareBreakpointTestBase.hw_breakpoints_unsupported)
def test_hw_break_set_disable_multi_thread_macos(self):
self.build()
self.setTearDownCleanup()
diff --git a/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py b/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
index 89d5768..a8c9cde 100644
--- a/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
+++ b/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
@@ -26,7 +26,7 @@
breakpoint = target.BreakpointCreateByLocation("main.c", 1)
self.assertTrue(breakpoint.IsHardware())
- @skipTestIfFn(HardwareBreakpointTestBase.supports_hw_breakpoints)
+ @skipTestIfFn(HardwareBreakpointTestBase.hw_breakpoints_supported)
def test_step_range(self):
"""Test stepping when hardware breakpoints are required."""
self.build()
@@ -49,7 +49,7 @@
"Could not create hardware breakpoint for thread plan", error.GetCString()
)
- @skipTestIfFn(HardwareBreakpointTestBase.supports_hw_breakpoints)
+ @skipTestIfFn(HardwareBreakpointTestBase.hw_breakpoints_supported)
def test_step_out(self):
"""Test stepping out when hardware breakpoints are required."""
self.build()
@@ -71,7 +71,7 @@
"Could not create hardware breakpoint for thread plan", error.GetCString()
)
- @skipTestIfFn(HardwareBreakpointTestBase.supports_hw_breakpoints)
+ @skipTestIfFn(HardwareBreakpointTestBase.hw_breakpoints_supported)
def test_step_over(self):
"""Test stepping over when hardware breakpoints are required."""
self.build()
@@ -91,7 +91,7 @@
# Was reported to sometimes pass on certain hardware.
@skipIf(oslist=["linux"], archs=["arm$"])
- @skipTestIfFn(HardwareBreakpointTestBase.supports_hw_breakpoints)
+ @skipTestIfFn(HardwareBreakpointTestBase.hw_breakpoints_supported)
def test_step_until(self):
"""Test stepping until when hardware breakpoints are required."""
self.build()
diff --git a/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/write_memory_with_hw_breakpoint/TestWriteMemoryWithHWBreakpoint.py b/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/write_memory_with_hw_breakpoint/TestWriteMemoryWithHWBreakpoint.py
index e4e25ae..c82ae24 100644
--- a/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/write_memory_with_hw_breakpoint/TestWriteMemoryWithHWBreakpoint.py
+++ b/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/write_memory_with_hw_breakpoint/TestWriteMemoryWithHWBreakpoint.py
@@ -12,10 +12,9 @@
class WriteMemoryWithHWBreakpoint(HardwareBreakpointTestBase):
- def does_not_support_hw_breakpoints(self):
- return not super().supports_hw_breakpoints()
- @skipTestIfFn(does_not_support_hw_breakpoints)
+ @skipTestIfFn(HardwareBreakpointTestBase.supports_hw_breakpoints)
+ @skip
def test_copy_memory_with_hw_break(self):
self.build()
exe = self.getBuildArtifact("a.out")