Skip to content

[LLDB] Fix write permission error in TestGlobalModuleCache.py #76171

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 4 commits into from
Dec 21, 2023

Conversation

cmtice
Copy link
Contributor

@cmtice cmtice commented Dec 21, 2023

TestGlobalModuleCache.py, a recently added test, tries to update a source file in the build directory, but it assumes the file is writable. In our distributed build and test system, this is not always true, so the test often fails with a write permissions error.

This change fixes that by setting the permissions on the file to be writable before attempting to write to it.

TestGlobalModuleCache.py, a recently added test, tries to update
a source file in the build directory, but it assumes the file is
writable. In our distributed build and test system, this is not
always true, so the test often fails with a write permissions error.

This change fixes that by setting the permissions on the file to
be writable before attempting to write to it.
@cmtice cmtice requested a review from JDevlieghere as a code owner December 21, 2023 17:29
@llvmbot llvmbot added the lldb label Dec 21, 2023
@llvmbot
Copy link
Member

llvmbot commented Dec 21, 2023

@llvm/pr-subscribers-lldb

Author: None (cmtice)

Changes

TestGlobalModuleCache.py, a recently added test, tries to update a source file in the build directory, but it assumes the file is writable. In our distributed build and test system, this is not always true, so the test often fails with a write permissions error.

This change fixes that by setting the permissions on the file to be writable before attempting to write to it.


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

1 Files Affected:

  • (modified) lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py (+3)
diff --git a/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py
index 6bb22c46efb443..02b77310b0067b 100644
--- a/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py
+++ b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py
@@ -26,6 +26,9 @@ def copy_to_main(self, src, dst):
         # a previous build, so sleep a bit here to ensure that the touch is later.
         time.sleep(2)
         try:
+            # Make sure dst is writeable before trying to write to it.
+            subprocess.run(['chmod', '777', dst], stdin=None,
+                           capture_output=False, encoding='utf-8')
             shutil.copy(src, dst)
         except:
             self.fail(f"Could not copy {src} to {dst}")

Copy link

github-actions bot commented Dec 21, 2023

✅ With the latest revision this PR passed the Python code formatter.

@rupprecht
Copy link
Collaborator

IIUC, the issue is that even though we are working in the build directory, which is writeable, we are copying a file from the source tree, which may be readonly, and those readonly permission bits persist when they're copied to the build directory.

@cmtice cmtice merged commit 1830fad into llvm:main Dec 21, 2023
@cmtice cmtice deleted the fix-lldb-test branch December 11, 2024 21:48
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.

4 participants