[Lldb-commits] [lldb] [lldb] Fix and re-enable TestUseSourceCache.py (PR #111237)

Igor Kudrin via lldb-commits lldb-commits at lists.llvm.org
Tue Oct 8 22:36:22 PDT 2024


https://github.com/igorkudrin updated https://github.com/llvm/llvm-project/pull/111237

>From 6756842b1c78ac6f41fa467f112aa7632f260582 Mon Sep 17 00:00:00 2001
From: Igor Kudrin <ikudrin at accesssoftek.com>
Date: Fri, 4 Oct 2024 23:27:04 -0700
Subject: [PATCH] [lldb] Fix and re-enable TestUseSourceCache.py

The decorators caused the main test, i.e. `test_set_use_source_cache_true()`,
to be skipped in most scenarios. In fact, it was only run on a Windows host
targeting a non-Windows remote platform, and it failed in this case because
the source file is opened with the `FILE_SHARE_DELETE` share mode, which
allows the file to be removed, see `llvm::sys::fs::openNativeFileInternal()`
in `llvm/lib/Support/Windows/Path.inc`.

This patch changes the test to check that the content can still be displayed
even after deleting the file when caching is enabled. The updated test is
expected to work on any platform, so the decorators are removed.
---
 .../settings/use_source_cache/TestUseSourceCache.py   | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
index 421599080a9e51..421b13f253f05b 100644
--- a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
+++ b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
@@ -17,8 +17,6 @@ def test_set_use_source_cache_false(self):
         """Test that after 'set use-source-cache false', files are not locked."""
         self.set_use_source_cache_and_test(False)
 
-    @skipIf(hostoslist=no_match(["windows"]))
-    @skipIf(oslist=["windows"])  # Fails on windows 11
     def test_set_use_source_cache_true(self):
         """Test that after 'set use-source-cache false', files are locked."""
         self.set_use_source_cache_and_test(True)
@@ -43,16 +41,15 @@ def set_use_source_cache_and_test(self, is_cache_enabled):
             self, "calc"
         )
 
-        # Show the source file contents to make sure LLDB loads src file.
-        self.runCmd("source list")
+        # Ensure that the source file is loaded.
+        self.expect("step", patterns=["-> .+ int x4 ="])
 
         # Try deleting the source file.
         is_file_removed = self.removeFile(src)
 
         if is_cache_enabled:
-            self.assertFalse(
-                is_file_removed, "Source cache is enabled, but delete file succeeded"
-            )
+            # Regardless of whether the file is removed, its contents should be displayed.
+            self.expect("step", patterns=["-> .+ int x5 ="])
 
         if not is_cache_enabled:
             self.assertTrue(



More information about the lldb-commits mailing list