From 25f1bddc7278b2537e5c2a04b1a59609f0e411ec Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sun, 1 May 2022 19:47:18 +0100 Subject: [PATCH] [Minor] Improve test stability --- src/libutil/cxx/locked_file.cxx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/libutil/cxx/locked_file.cxx b/src/libutil/cxx/locked_file.cxx index ca5600c5f..f392d9b4a 100644 --- a/src/libutil/cxx/locked_file.cxx +++ b/src/libutil/cxx/locked_file.cxx @@ -249,16 +249,20 @@ TEST_CASE("create and delete file") { CHECK(::access(fname.c_str(), R_OK) == 0); } // File must be deleted after this call - CHECK(::access(fname.c_str(), R_OK) == -1); - CHECK(errno == ENOENT); + auto ret = ::access(fname.c_str(), R_OK); + auto serrno = errno; + CHECK(ret == -1); + CHECK(serrno == ENOENT); // Create one more time { auto raii_locked_file = raii_locked_file::create_temp(fname.c_str(), O_RDONLY, 00600); CHECK(raii_locked_file.has_value()); CHECK(::access(fname.c_str(), R_OK) == 0); } - CHECK(::access(fname.c_str(), R_OK) == -1); - CHECK(errno == ENOENT); + ret = ::access(fname.c_str(), R_OK); + serrno = errno; + CHECK(ret == -1); + CHECK(serrno == ENOENT); } TEST_CASE("check lock") { @@ -272,8 +276,10 @@ TEST_CASE("check lock") { CHECK(::access(fname.c_str(), R_OK) == 0); } // File must be deleted after this call - CHECK(::access(fname.c_str(), R_OK) == -1); - CHECK(errno == ENOENT); + auto ret = ::access(fname.c_str(), R_OK); + auto serrno = errno; + CHECK(ret == -1); + CHECK(serrno == ENOENT); } } // TEST_SUITE -- 2.39.5