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`
Test the caching mechanism of the source manager.
"""
+import os
+import stat
+
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
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)