diff --git a/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/base.py b/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/base.py new file mode 100644 --- /dev/null +++ b/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/base.py @@ -0,0 +1,19 @@ +""" +Base class for hardware breakpoints tests. +""" + +from lldbsuite.test.lldbtest import * + +class HardwareBreakpointTestBase(TestBase): + NO_DEBUG_INFO_TESTCASE = True + + + def supports_hw_breakpoints(self): + self.build() + self.runCmd("file " + self.getBuildArtifact("a.out"), + CURRENT_EXECUTABLE_SET) + self.runCmd("breakpoint set -b main --hardware") + self.runCmd("run") + if 'stopped' in self.res.GetOutput(): + return 'Hardware breakpoints are supported' + 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 --- 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 @@ -9,15 +9,18 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -class HardwareBreakpointMultiThreadTestCase(TestBase): - NO_DEBUG_INFO_TESTCASE = True +from functionalities.breakpoint.hardware_breakpoints.base import * +class HardwareBreakpointMultiThreadTestCase(HardwareBreakpointTestBase): mydir = TestBase.compute_mydir(__file__) + def does_not_support_hw_breakpoints(self): + return not super().supports_hw_breakpoints() + # LLDB on linux supports hardware breakpoints for arm and aarch64 # architectures. @skipUnlessPlatform(oslist=['linux']) - @skipIf(archs=no_match(['arm', 'aarch64'])) + @skipTestIfFn(does_not_support_hw_breakpoints) def test_hw_break_set_delete_multi_thread_linux(self): self.build() self.setTearDownCleanup() @@ -26,7 +29,7 @@ # LLDB on linux supports hardware breakpoints for arm and aarch64 # architectures. @skipUnlessPlatform(oslist=['linux']) - @skipIf(archs=no_match(['arm', 'aarch64'])) + @skipTestIfFn(does_not_support_hw_breakpoints) def test_hw_break_set_disable_multi_thread_linux(self): self.build() self.setTearDownCleanup() @@ -36,7 +39,7 @@ # architectures. @skipUnlessDarwin @skipIfOutOfTreeDebugserver - @expectedFailureAll(archs=["arm64"]) + @skipTestIfFn(does_not_support_hw_breakpoints) def test_hw_break_set_delete_multi_thread_macos(self): self.build() self.setTearDownCleanup() @@ -46,7 +49,7 @@ # architectures. @skipUnlessDarwin @skipIfOutOfTreeDebugserver - @expectedFailureAll(archs=["arm64"]) + @skipTestIfFn(does_not_support_hw_breakpoints) def test_hw_break_set_disable_multi_thread_macos(self): self.build() self.setTearDownCleanup() diff --git a/lldb/test/API/functionalities/breakpoint/require_hw_breakpoints/Makefile b/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/Makefile rename from lldb/test/API/functionalities/breakpoint/require_hw_breakpoints/Makefile rename to lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/Makefile diff --git a/lldb/test/API/functionalities/breakpoint/require_hw_breakpoints/TestRequireHWBreakpoints.py b/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py rename from lldb/test/API/functionalities/breakpoint/require_hw_breakpoints/TestRequireHWBreakpoints.py rename to lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py --- a/lldb/test/API/functionalities/breakpoint/require_hw_breakpoints/TestRequireHWBreakpoints.py +++ b/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py @@ -8,20 +8,13 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +from functionalities.breakpoint.hardware_breakpoints.base import * -class BreakpointLocationsTestCase(TestBase): - NO_DEBUG_INFO_TESTCASE = True +class BreakpointLocationsTestCase(HardwareBreakpointTestBase): mydir = TestBase.compute_mydir(__file__) def supports_hw_breakpoints(self): - self.build() - self.runCmd("file " + self.getBuildArtifact("a.out"), - CURRENT_EXECUTABLE_SET) - self.runCmd("breakpoint set -b main --hardware") - self.runCmd("run") - if 'stopped' in self.res.GetOutput(): - return 'Hardware breakpoints are supported' - return None + return super().supports_hw_breakpoints() def test_breakpoint(self): """Test regular breakpoints when hardware breakpoints are required.""" diff --git a/lldb/test/API/functionalities/breakpoint/require_hw_breakpoints/main.c b/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/main.c rename from lldb/test/API/functionalities/breakpoint/require_hw_breakpoints/main.c rename to lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/main.c