[Lldb-commits] [lldb] 71b2ff7 - [test] Fix TestSourceManager when the source file is readonly.

Jordan Rupprecht via lldb-commits lldb-commits at lists.llvm.org
Mon Nov 21 11:56:09 PST 2022


Author: Jordan Rupprecht
Date: 2022-11-21T11:56:02-08:00
New Revision: 71b2ff79043aea637335b28299e978b678fd83bd

URL: https://github.com/llvm/llvm-project/commit/71b2ff79043aea637335b28299e978b678fd83bd
DIFF: https://github.com/llvm/llvm-project/commit/71b2ff79043aea637335b28299e978b678fd83bd.diff

LOG: [test] Fix TestSourceManager when the source file is readonly.

This test copies main.c to main-copy.c and modifies main-copy.c while debugging, but main.c may have come from a readonly location, which means writing to main-copy.c will fail because permissions are preserved. Run the equivalent of "chmod u+w" before attempting to modify it.

This effect can be seen by attempting to run this test after running `chmod u-w lldb/test/API/source-manager/main.c`

Added: 
    

Modified: 
    lldb/test/API/source-manager/TestSourceManager.py

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/source-manager/TestSourceManager.py b/lldb/test/API/source-manager/TestSourceManager.py
index 439366c989875..9f087b91a7f6c 100644
--- a/lldb/test/API/source-manager/TestSourceManager.py
+++ b/lldb/test/API/source-manager/TestSourceManager.py
@@ -9,6 +9,9 @@
   Test the caching mechanism of the source manager.
 """
 
+import os
+import stat
+
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
@@ -220,6 +223,11 @@ def test_modify_source_file_while_debugging(self):
         new_content = original_content.replace('Hello world', 'Hello lldb', 1)
 
         # Modify the source code file.
+        # If the source was read only, the copy will also be read only.
+        # Run "chmod u+w" on it first so we can modify it.
+        statinfo = os.stat(self.file)
+        os.chmod(self.file, statinfo.st_mode | stat.S_IWUSR)
+
         with io.open(self.file, 'w', newline='\n') as f:
             time.sleep(1)
             f.write(new_content)


        


More information about the lldb-commits mailing list