[Lldb-commits] [lldb] [lldb/Plugins] Introduce Scripted Platform Plugin (PR #99814)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Mon Aug 5 04:37:05 PDT 2024


================
@@ -0,0 +1,108 @@
+"""
+Test python scripted platform in lldb
+"""
+
+import os, shutil
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test import lldbtest
+
+
+class ScriptedPlatformTestCase(TestBase):
+    NO_DEBUG_INFO_TESTCASE = True
+
+    @skipUnlessDarwin
+    def test_python_plugin_package(self):
+        """Test that the lldb python module has a `plugins.scripted_platform`
+        package."""
+        self.expect(
+            "script import lldb.plugins",
+            substrs=["ModuleNotFoundError"],
+            matching=False,
+        )
+
+        self.expect("script dir(lldb.plugins)", substrs=["scripted_platform"])
+
+        self.expect(
+            "script import lldb.plugins.scripted_platform",
+            substrs=["ModuleNotFoundError"],
+            matching=False,
+        )
+
+        self.expect(
+            "script dir(lldb.plugins.scripted_platform)", substrs=["ScriptedPlatform"]
+        )
+
+        self.expect(
+            "script from lldb.plugins.scripted_platform import ScriptedPlatform",
+            substrs=["ImportError"],
+            matching=False,
+        )
+
+        self.expect(
+            "script dir(ScriptedPlatform)",
+            substrs=[
+                "attach_to_process",
+                "kill_process",
+                "launch_process",
+                "list_processes",
+            ],
+        )
+
+    @skipUnlessDarwin
+    def test_list_processes(self):
+        """Test that we can load and select an lldb scripted platform using the
+        SBAPI, check its process ID, parent, name & triple.
+        """
+        os.environ["SKIP_SCRIPTED_PLATFORM_SELECT"] = "1"
+
+        def cleanup():
+            del os.environ["SKIP_SCRIPTED_PLATFORM_SELECT"]
+
+        self.addTearDownHook(cleanup)
----------------
labath wrote:

Sounds good. (you could also do it before hand, as I think this patch is going to take a couple more iterations).

https://github.com/llvm/llvm-project/pull/99814


More information about the lldb-commits mailing list