[llvm] [FileSystem] Allow exclusive file lock (PR #114098)
Ben Langmuir via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 15 10:03:13 PDT 2025
================
@@ -583,10 +583,14 @@ TEST_F(ProgramEnvTest, TestLockFileExclusive) {
int FD2;
ASSERT_NO_ERROR(fs::openFileForReadWrite(LockedFile, FD2,
fs::CD_OpenExisting, fs::OF_None));
+ // File should be non-exclusive locked. Try acquire exclusive lock will fail
+ // but non-exclusive will succeed.
+ EXPECT_TRUE(
+ fs::tryLockFile(FD2, std::chrono::seconds(0), /*Exclusive=*/true));
+
+ EXPECT_FALSE(
+ fs::tryLockFile(FD2, std::chrono::seconds(0), /*Exclusive=*/false));
----------------
benlangmuir wrote:
These API use `std::error_code`, not `Error`, consistent with other filesystem APIs. For `std::error_code`, I see several tests contain a copy of an `ASSERT_NO_ERROR` macro; maybe that should get put in a header and generalized with an `EXPECT_NO_ERROR` version as well?
https://github.com/llvm/llvm-project/pull/114098
More information about the llvm-commits
mailing list