-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[lldb] Add lldbutil.install_to_target() helper #91944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
It can be used in tests llvm#91918, llvm#91931 and such.
@llvm/pr-subscribers-lldb Author: Dmitry Vasilyev (slydiman) ChangesIt can be used in tests #91918, #91931 and such. Full diff: https://github.com/llvm/llvm-project/pull/91944.diff 1 Files Affected:
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")
|
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a bit... magical. Can we just have the caller specify a full path to the thing it wants to install? self.getBuildArtifact
is not that much extra typing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expected the following usage:
- Use filename (most common usage):
target_path = lldbutil.install_to_target(self, "a.out")
- Use path:
local_path = self.getBuildArtifact("some_file")
# write to local_path here
...
# avoid typing "some_file" constant twice, just extract the filename from the local_path
target_path = lldbutil.install_to_target(self, path=local_path)
- Use both:
# "temp" is the filename on the remote target
target_path = lldbutil.install_to_target(self, "temp", local_temp_path_outside_build_dir)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I kept only the full path parameter. Updated. Thanks.
@@ -1654,6 +1654,26 @@ def find_library_callable(test): | |||
) | |||
|
|||
|
|||
def target_install(test, filename=None, path=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is optional, but I think something like install_to_target
would be a better match for the naming style of the surrounding functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. Thanks.
It can be used in tests #91918, #91931 and such.