[Lldb-commits] [lldb] c114352 - [lldb/test] Put hardware breakpoint tests together, NFC

Tatyana Krasnukha via lldb-commits lldb-commits at lists.llvm.org
Wed Jul 29 11:20:17 PDT 2020


Author: Tatyana Krasnukha
Date: 2020-07-29T21:20:04+03:00
New Revision: c114352edfe0de69050bbf1cbbc478bcfb524622

URL: https://github.com/llvm/llvm-project/commit/c114352edfe0de69050bbf1cbbc478bcfb524622
DIFF: https://github.com/llvm/llvm-project/commit/c114352edfe0de69050bbf1cbbc478bcfb524622.diff

LOG: [lldb/test] Put hardware breakpoint tests together, NFC

Create a common base class for them to re-use supports_hw_breakpoints function in decorators.

Differential Revision: https://reviews.llvm.org/D84311

Added: 
    lldb/test/API/functionalities/breakpoint/hardware_breakpoints/base.py
    lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/Makefile
    lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
    lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/main.c

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

Removed: 
    lldb/test/API/functionalities/breakpoint/require_hw_breakpoints/Makefile
    lldb/test/API/functionalities/breakpoint/require_hw_breakpoints/TestRequireHWBreakpoints.py
    lldb/test/API/functionalities/breakpoint/require_hw_breakpoints/main.c


################################################################################
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
index 000000000000..9593a72b3d40
--- /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
index bca7b278631f..09db3ffd3ecd 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
@@ -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 @@ def test_hw_break_set_delete_multi_thread_linux(self):
     # 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 @@ def test_hw_break_set_disable_multi_thread_linux(self):
     # 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 @@ def test_hw_break_set_delete_multi_thread_macos(self):
     # 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
similarity index 100%
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
similarity index 89%
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
index 61e417113101..c97795f7ae67 100644
--- 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
similarity index 100%
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


        


More information about the lldb-commits mailing list