Skip to content

Commit 47d9ca8

Browse files
authored
[lldb] Fix and re-enable TestUseSourceCache.py (#111237)
The decorators caused the `test_set_use_source_cache_true()` test to be skipped in most scenarios. It was only run on a Windows host targeting a non-Windows remote platform. The source file is opened with the `FILE_SHARE_DELETE` sharing mode, which allows the file to be removed even though it is also memory-mapped; at least, this behavior is observed on Windows 11. The patch replaces the operation with an attempt to overwrite the file, which still fails for such files on Windows 11.
1 parent 709abac commit 47d9ca8

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ def test_set_use_source_cache_false(self):
1818
self.set_use_source_cache_and_test(False)
1919

2020
@skipIf(hostoslist=no_match(["windows"]))
21-
@skipIf(oslist=["windows"]) # Fails on windows 11
2221
def test_set_use_source_cache_true(self):
23-
"""Test that after 'set use-source-cache false', files are locked."""
22+
"""Test that after 'set use-source-cache true', files are locked."""
2423
self.set_use_source_cache_and_test(True)
2524

2625
def set_use_source_cache_and_test(self, is_cache_enabled):
@@ -46,23 +45,27 @@ def set_use_source_cache_and_test(self, is_cache_enabled):
4645
# Show the source file contents to make sure LLDB loads src file.
4746
self.runCmd("source list")
4847

49-
# Try deleting the source file.
50-
is_file_removed = self.removeFile(src)
48+
# Try overwriting the source file.
49+
is_file_overwritten = self.overwriteFile(src)
5150

5251
if is_cache_enabled:
5352
self.assertFalse(
54-
is_file_removed, "Source cache is enabled, but delete file succeeded"
53+
is_file_overwritten,
54+
"Source cache is enabled, but writing to file succeeded",
5555
)
5656

5757
if not is_cache_enabled:
5858
self.assertTrue(
59-
is_file_removed, "Source cache is disabled, but delete file failed"
59+
is_file_overwritten,
60+
"Source cache is disabled, but writing to file failed",
6061
)
6162

62-
def removeFile(self, src):
63-
"""Remove file and return true iff file was successfully removed."""
63+
def overwriteFile(self, src):
64+
"""Write to file and return true iff file was successfully written."""
6465
try:
65-
os.remove(src)
66+
f = open(src, "w")
67+
f.writelines(["// hello world\n"])
68+
f.close()
6669
return True
6770
except Exception:
6871
return False

0 commit comments

Comments
 (0)