labath created this revision.
labath added reviewers: JDevlieghere, jingham, clayborg.
Herald added a project: All.
labath requested review of this revision.
Herald added a project: LLDB.

The decision which categories are relevant for a particular test run
happen very early in the test setup process. They use the SBPlatform
object to determine which categories should be skipped. The platform
object created for this purpose transcends individual test runs.

This setup is not compatible with the direction discussed in
https://discourse.llvm.org/t/multiple-platforms-with-the-same-name/59594

- when platform objects are tied to a specific (SB)Debugger, they need

to be created alongside it, which currently happens in the test setUp
method.

This patch is the first step in that direction -- it rewrites the
category skipping logic to avoid depending on a global SBPlatform
object. Fortunately, the skipping logic is fairly simple (and I believe
it outght to stay that way) and mainly consists of comparing the
platform name against some hardcoded lists. This patch bases this
comparison on the platform name instead of the os part of the triple (as
reported by the platform).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121605

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

Index: lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -57,12 +57,7 @@
 
 
 def target_is_android():
-    if not hasattr(target_is_android, 'result'):
-        triple = lldb.selected_platform.GetTriple()
-        match = re.match(".*-.*-.*-android", triple)
-        target_is_android.result = match is not None
-    return target_is_android.result
-
+    return configuration.lldb_platform_name == "remote-android"
 
 def android_device_api():
     if not hasattr(android_device_api, 'result'):
@@ -139,18 +134,16 @@
             platform = 'ios'
         return platform
 
-    # Use the triple to determine the platform if set.
-    triple = lldb.selected_platform.GetTriple()
-    if triple:
-        platform = triple.split('-')[2]
-        if platform.startswith('freebsd'):
-            platform = 'freebsd'
-        elif platform.startswith('netbsd'):
-            platform = 'netbsd'
-        return platform
-
-    # It still might be an unconnected remote platform.
-    return ''
+    platform = configuration.lldb_platform_name
+    if platform is None:
+        platform = "host"
+    if platform == "qemu-user":
+        platform = "host"
+    if platform == "host":
+        return getHostPlatform()
+    if platform.startswith("remote-"):
+        return platform[7:]
+    return platform
 
 
 def platformIsDarwin():
Index: lldb/packages/Python/lldbsuite/test/dotest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -822,9 +822,9 @@
         configuration.skip_categories.append("objc")
 
 def checkDebugInfoSupport():
-    import lldb
+    from lldbsuite.test import lldbplatformutil
 
-    platform = lldb.selected_platform.GetTriple().split('-')[2]
+    platform = lldbplatformutil.getPlatform()
     compiler = configuration.compiler
     for cat in test_categories.debug_info_categories:
         if cat in configuration.categories_list:
@@ -840,14 +840,14 @@
     skip_msg = "Skipping %s tests, as they are not compatible with remote testing on this platform"
     if lldbplatformutil.platformIsDarwin():
         configuration.skip_categories.append("llgs")
-        if lldb.remote_platform:
+        if configuration.lldb_platform_name:
             # <rdar://problem/34539270>
             configuration.skip_categories.append("debugserver")
             if configuration.verbose:
                 print(skip_msg%"debugserver");
     else:
         configuration.skip_categories.append("debugserver")
-        if lldb.remote_platform and lldbplatformutil.getPlatform() == "windows":
+        if configuration.lldb_platform_name and lldbplatformutil.getPlatform() == "windows":
             configuration.skip_categories.append("llgs")
             if configuration.verbose:
                 print(skip_msg%"lldb-server");
@@ -881,7 +881,16 @@
     import lldb
     lldb.SBDebugger.Initialize()
 
+    checkLibcxxSupport()
+    checkLibstdcxxSupport()
+    checkWatchpointSupport()
+    checkDebugInfoSupport()
+    checkDebugServerSupport()
+    checkObjcSupport()
+    checkForkVForkSupport()
+
     # Use host platform by default.
+    lldb.remote_platform = None
     lldb.selected_platform = lldb.SBPlatform.GetHostPlatform()
 
     # Now we can also import lldbutil
@@ -892,6 +901,7 @@
               (configuration.lldb_platform_name))
         lldb.remote_platform = lldb.SBPlatform(
             configuration.lldb_platform_name)
+        lldb.selected_platform = lldb.remote_platform
         if not lldb.remote_platform.IsValid():
             print(
                 "error: unable to create the LLDB platform named '%s'." %
@@ -938,14 +948,6 @@
     # Note that it's not dotest's job to clean this directory.
     lldbutil.mkdir_p(configuration.test_build_dir)
 
-    checkLibcxxSupport()
-    checkLibstdcxxSupport()
-    checkWatchpointSupport()
-    checkDebugInfoSupport()
-    checkDebugServerSupport()
-    checkObjcSupport()
-    checkForkVForkSupport()
-
     print("Skipping the following test categories: {}".format(configuration.skip_categories))
 
     for testdir in configuration.testdirs:
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to