[Lldb-commits] [lldb] [lldb] Add lldbutil.target_install() helper (PR #91944)

Dmitry Vasilyev via lldb-commits lldb-commits at lists.llvm.org
Mon May 13 09:24:16 PDT 2024


https://github.com/slydiman updated https://github.com/llvm/llvm-project/pull/91944

>From de7135a8a4a40b5aa5ac1f44e58d62874c96448b Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev <dvassiliev at accesssoftek.com>
Date: Mon, 13 May 2024 14:45:33 +0400
Subject: [PATCH 1/4] [lldb] Add lldbutil.target_install() helper

It can be used in tests #91918, #91931 and such.
---
 lldb/packages/Python/lldbsuite/test/lldbutil.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index 58eb37fd742d7..e67b68b727b80 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -1654,6 +1654,22 @@ def find_library_callable(test):
     )
 
 
+def target_install(test, filename):
+    path = test.getBuildArtifact(filename)
+    if lldb.remote_platform:
+        remote_path = lldbutil.append_to_process_working_directory(test, filename)
+        err = lldb.remote_platform.Install(
+            lldb.SBFileSpec(path, True), lldb.SBFileSpec(remote_path, False)
+        )
+        if err.Fail():
+            raise Exception(
+                "remote_platform.Install('%s', '%s') failed: %s"
+                % (path, remote_path, err)
+            )
+        path = remote_path
+    return path
+
+
 def read_file_on_target(test, remote):
     if lldb.remote_platform:
         local = test.getBuildArtifact("file_from_target")

>From b4f5798258b29996b6805037bed70a819a671618 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev <dvassiliev at accesssoftek.com>
Date: Mon, 13 May 2024 15:51:36 +0400
Subject: [PATCH 2/4] Added the full local path as optional parameter.

---
 lldb/packages/Python/lldbsuite/test/lldbutil.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index e67b68b727b80..4290fe94590a1 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -1654,10 +1654,14 @@ def find_library_callable(test):
     )
 
 
-def target_install(test, filename):
-    path = test.getBuildArtifact(filename)
+def target_install(test, filename=None, path=None):
+    test.assertTrue(filename or path, "filename or path must be specified.")
+    if filename is None:
+        filename = os.path.basename(path)
+    if path is None:
+        path = test.getBuildArtifact(filename)
     if lldb.remote_platform:
-        remote_path = lldbutil.append_to_process_working_directory(test, filename)
+        remote_path = append_to_process_working_directory(test, filename)
         err = lldb.remote_platform.Install(
             lldb.SBFileSpec(path, True), lldb.SBFileSpec(remote_path, False)
         )

>From 79831a4c0e276caf4952b4d5748d5d7ba9e59365 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev <dvassiliev at accesssoftek.com>
Date: Mon, 13 May 2024 20:02:41 +0400
Subject: [PATCH 3/4] Renamed to `install_to_target`.

---
 lldb/packages/Python/lldbsuite/test/lldbutil.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index 4290fe94590a1..e1aa8d63b9b72 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -1654,7 +1654,7 @@ def find_library_callable(test):
     )
 
 
-def target_install(test, filename=None, path=None):
+def install_to_target(test, filename=None, path=None):
     test.assertTrue(filename or path, "filename or path must be specified.")
     if filename is None:
         filename = os.path.basename(path)

>From eb1d82b19891b0369aa80cc6202b4c7e5c2e66c3 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev <dvassiliev at accesssoftek.com>
Date: Mon, 13 May 2024 20:23:57 +0400
Subject: [PATCH 4/4] Simplified.

---
 lldb/packages/Python/lldbsuite/test/lldbutil.py | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index e1aa8d63b9b72..1ec036f885e7e 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -1654,13 +1654,9 @@ def find_library_callable(test):
     )
 
 
-def install_to_target(test, filename=None, path=None):
-    test.assertTrue(filename or path, "filename or path must be specified.")
-    if filename is None:
-        filename = os.path.basename(path)
-    if path is None:
-        path = test.getBuildArtifact(filename)
+def install_to_target(test, path):
     if lldb.remote_platform:
+        filename = os.path.basename(path)
         remote_path = append_to_process_working_directory(test, filename)
         err = lldb.remote_platform.Install(
             lldb.SBFileSpec(path, True), lldb.SBFileSpec(remote_path, False)



More information about the lldb-commits mailing list