Skip to content

[lldb] Fix TestGdbRemoteForkNonStop.py test #131293

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

Merged
merged 2 commits into from
Mar 24, 2025

Conversation

sga-sc
Copy link
Contributor

@sga-sc sga-sc commented Mar 14, 2025

During lldb testing on remote targets TestGdbRemoteForkNonStop.py freezes because in this test we try to create file on remote machine using absolute file path from local machine. This patch fixes this error

@sga-sc sga-sc requested a review from JDevlieghere as a code owner March 14, 2025 07:52
@llvmbot llvmbot added the lldb label Mar 14, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 14, 2025

@llvm/pr-subscribers-lldb

Author: Georgiy Samoylov (sga-sc)

Changes

During lldb testing on remote targets TestGdbRemoteForkNonStop.py freezes because in this test we try to create file on remote machine using absolute file path from local machine. This patch fixes this error


Full diff: https://github.com/llvm/llvm-project/pull/131293.diff

1 Files Affected:

  • (modified) lldb/test/API/tools/lldb-server/main.cpp (+4-2)
diff --git a/lldb/test/API/tools/lldb-server/main.cpp b/lldb/test/API/tools/lldb-server/main.cpp
index c661f5b4e82c4..fc3776832d6b6 100644
--- a/lldb/test/API/tools/lldb-server/main.cpp
+++ b/lldb/test/API/tools/lldb-server/main.cpp
@@ -344,8 +344,10 @@ int main(int argc, char **argv) {
     } else if (consume_front(arg, "process:sync:")) {
       // this is only valid after fork
       const char *filenames[] = {"parent", "child"};
-      std::string my_file = arg + "." + filenames[is_child];
-      std::string other_file = arg + "." + filenames[!is_child];
+      size_t pos = arg.find_last_of("/\\");
+      std::string file_name = arg.substr(pos + 1);
+      std::string my_file = file_name + "." + filenames[is_child];
+      std::string other_file = file_name + "." + filenames[!is_child];
 
       // indicate that we're ready
       FILE *f = fopen(my_file.c_str(), "w");

Copy link
Collaborator

@labath labath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should make the test (python code) pass the correct path instead. We have self.get_process_working_directory() for that.

@sga-sc sga-sc force-pushed the users/sga-sc/fix_fork_non_stop branch from 8c8e714 to cb1c55b Compare March 17, 2025 16:28
@sga-sc
Copy link
Contributor Author

sga-sc commented Mar 17, 2025

@labath Addressed

"""Get the working directory that should be used when launching processes for local or remote processes."""
if lldb.remote_platform:
# Remote tests set the platform working directory up in
# TestBase.setUp()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# TestBase.setUp()
# Base.setUp()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed

Comment on lines 756 to 758
def getWorkingDirArtifact(self, name="a.out"):
"""Return absolute path to an artifact in the test's working directory."""
return os.path.join(self.get_process_working_directory(), name)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for this we have lldbutil.append_to_process_working_directory.

I actually like your api more, so I wouldn't be opposed to using this instead. However I don't think we should have two methods for the same thing, so if you want to go down that path, you should also port the other usages of append_to_process_working_directory to this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed

@sga-sc sga-sc force-pushed the users/sga-sc/fix_fork_non_stop branch from 47f1555 to 77f2717 Compare March 19, 2025 13:00
Copy link
Collaborator

@labath labath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@sga-sc
Copy link
Contributor Author

sga-sc commented Mar 21, 2025

I don’t have merge rights, so could you merge it, please?

@labath labath merged commit ec9546d into llvm:main Mar 24, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants