[Lldb-commits] [lldb] [LLDB] Fix write permission error in TestGlobalModuleCache.py (PR #76171)

via lldb-commits lldb-commits at lists.llvm.org
Thu Dec 21 09:36:48 PST 2023


https://github.com/cmtice updated https://github.com/llvm/llvm-project/pull/76171

>From 74ac76e175917e0354d998b3b3fdc2b30bf9251b Mon Sep 17 00:00:00 2001
From: Caroline Tice <cmtice at google.com>
Date: Thu, 21 Dec 2023 09:10:35 -0800
Subject: [PATCH 1/2] [LLDB] Fix write permission error in
 TestGlobalModuleCache.py

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.
---
 .../python_api/global_module_cache/TestGlobalModuleCache.py    | 3 +++
 1 file changed, 3 insertions(+)

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}")

>From 1261639e6faae4e719d6e96c732ee56a1d3589bc Mon Sep 17 00:00:00 2001
From: Caroline Tice <cmtice at google.com>
Date: Thu, 21 Dec 2023 09:34:40 -0800
Subject: [PATCH 2/2] [LLDB] Fix write permission error in
 TestGlobalModuleCache.py

Fix python formatting.
---
 .../global_module_cache/TestGlobalModuleCache.py          | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

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 02b77310b0067b..3dea682dc6bdf6 100644
--- a/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py
+++ b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py
@@ -27,8 +27,12 @@ def copy_to_main(self, src, dst):
         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')
+            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}")



More information about the lldb-commits mailing list