[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
Mon Jun 17 00:52:38 PDT 2019


mgorny updated this revision to Diff 204995.
mgorny added a comment.

Updated as suggested above.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63380/new/

https://reviews.llvm.org/D63380

Files:
  lldb/packages/Python/lldbsuite/test/decorators.py
  lldb/packages/Python/lldbsuite/test/dotest.py


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -1181,6 +1181,30 @@
     print("libstdcxx tests will not be run because: " + reason)
     configuration.skipCategories.append("libstdcxx")
 
+def canRunWatchpointTests():
+    from lldbsuite.test import lldbplatformutil
+
+    platform = lldbplatformutil.getPlatform()
+    if platform == "netbsd":
+      try:
+        output = subprocess.check_output(["/sbin/sysctl", "-n",
+          "security.models.extensions.user_set_dbregs"]).decode().strip()
+        if output == "1":
+          return True, "security.models.extensions.user_set_dbregs enabled"
+      except subprocess.CalledProcessError:
+        pass
+      return False, "security.models.extensions.user_set_dbregs disabled"
+    return True, "dbregs always writable"
+
+def checkWatchpointSupport():
+    result, reason = canRunWatchpointTests()
+    if result:
+        return # watchpoints supported
+    if "watchpoint" in configuration.categoriesList:
+        return # watchpoint category explicitly requested, let it run.
+    print("watchpoint tests will not be run because: " + reason)
+    configuration.skipCategories.append("watchpoint")
+
 def checkDebugInfoSupport():
     import lldb
 
@@ -1305,6 +1329,7 @@
 
     checkLibcxxSupport()
     checkLibstdcxxSupport()
+    checkWatchpointSupport()
     checkDebugInfoSupport()
 
     # Don't do debugserver tests on anything except OS X.
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.204995.patch
Type: text/x-patch
Size: 2649 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190617/0e4ebb60/attachment.bin>


More information about the lldb-commits mailing list