[Lldb-commits] [PATCH] D63380: [lldb] [test] Skip watchpoint tests on NetBSD if userdbregs is disabled

Michał Górny via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Sat Jun 15 10:59:09 PDT 2019


mgorny created this revision.
mgorny added reviewers: labath, krytarowski.

Skip watchpoint tests if security.models.extensions.user_set_dbregs
is disabled.  This indicates that unprivileged processes are not allowed
to write to debug registers which is a prerequisite for using hardware
watchpoints.


https://reviews.llvm.org/D63380

Files:
  lldb/packages/Python/lldbsuite/test/decorators.py
  lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py
  lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py
  lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_disable/TestWatchpointDisable.py
  lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_events/TestWatchpointEvents.py
  lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py


Index: lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py
@@ -20,6 +20,7 @@
     @expectedFailureAll(
         oslist=["windows"],
         bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
+    @skipIfDbRegsReadOnly
     def test_value_of_vector_variable_using_watchpoint_set(self):
         """Test verify displayed value of vector variable."""
         exe = self.getBuildArtifact("a.out")
Index: lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_events/TestWatchpointEvents.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_events/TestWatchpointEvents.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_events/TestWatchpointEvents.py
@@ -29,6 +29,7 @@
     @expectedFailureAll(
         oslist=["windows"],
         bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
+    @skipIfDbRegsReadOnly
     def test_with_python_api(self):
         """Test that adding, deleting and modifying watchpoints sends the appropriate events."""
         self.build()
Index: lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_disable/TestWatchpointDisable.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_disable/TestWatchpointDisable.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_disable/TestWatchpointDisable.py
@@ -19,6 +19,7 @@
     @expectedFailureAll(
         oslist=["windows"],
         bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
+    @skipIfDbRegsReadOnly
     def test_disable_works (self):
         """Set a watchpoint, disable it, and make sure it doesn't get hit."""
         self.build()
Index: lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py
@@ -113,6 +113,7 @@
         bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
     # Read-write watchpoints not supported on SystemZ
     @expectedFailureAll(archs=['s390x'])
+    @skipIfDbRegsReadOnly
     def test_rw_watchpoint_delete(self):
         """Test delete watchpoint and expect not to stop for watchpoint."""
         self.build(dictionary=self.d)
Index: lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py
@@ -71,6 +71,7 @@
     @expectedFailureAll(
         oslist=["windows"],
         bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
+    @skipIfDbRegsReadOnly
     def test_watchpoint_multiple_threads_wp_set_and_then_delete(self):
         """Test that lldb watchpoint works for multiple threads, and after the watchpoint is deleted, the watchpoint event should no longer fires."""
         self.build()
Index: lldb/packages/Python/lldbsuite/test/decorators.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/decorators.py
+++ lldb/packages/Python/lldbsuite/test/decorators.py
@@ -826,3 +826,18 @@
         return (('DYLD_INSERT_LIBRARIES' in os.environ) and
                 'libclang_rt.asan' in os.environ['DYLD_INSERT_LIBRARIES'])
     return skipTestIfFn(is_sanitized)(func)
+
+def skipIfDbRegsReadOnly(func):
+    """Skip this test if platform does not permit writing to debug registers."""
+    def is_dbregs_rdonly():
+        if platform.system() != 'NetBSD':
+            return None
+        try:
+            output = subprocess.check_output(["/sbin/sysctl", "-n",
+                "security.models.extensions.user_set_dbregs"]).decode().strip()
+            if output == "1":
+                return None
+        except subprocess.CalledProcessError:
+            pass
+        return "security.models.extensions.user_set_dbregs is disabled"
+    return skipTestIfFn(is_dbregs_rdonly)(func)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63380.204933.patch
Type: text/x-patch
Size: 5037 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190615/a3b1ccce/attachment-0001.bin>


More information about the lldb-commits mailing list