From: Lucian Petrut Date: Mon, 6 Nov 2023 14:58:08 +0000 (+0000) Subject: test: fix Windows ::_creat X-Git-Tag: v19.0.0~55^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=2cef5b3ce4bc988ac93ff128218f4b0dddb0f074;p=ceph.git test: fix Windows ::_creat The Windows Universal C Runtime (ucrt) "_creat" function is no longer POSIX compatible and requires Windows specific mode flags. We got admin socket test failures after switching from msvcrt to uscrt. We'll address the issue with some platform checks. Signed-off-by: Lucian Petrut --- diff --git a/src/global/signal_handler.cc b/src/global/signal_handler.cc index 055763eee4691..d33872678719c 100644 --- a/src/global/signal_handler.cc +++ b/src/global/signal_handler.cc @@ -276,7 +276,11 @@ void generate_crash_dump(char *base, ::close(fd); } snprintf(fn, sizeof(fn)-1, "%s/done", base); + #ifdef _WIN32 + ::creat(fn, _S_IREAD); + #else ::creat(fn, 0444); + #endif } } } diff --git a/src/test/admin_socket.cc b/src/test/admin_socket.cc index a8236271652c2..03bbb72b2a9a5 100644 --- a/src/test/admin_socket.cc +++ b/src/test/admin_socket.cc @@ -239,7 +239,11 @@ TEST(AdminSocketClient, Ping) { ASSERT_FALSE(ok); } // file exists but does not allow connections (no process, wrong type...) + #ifdef _WIN32 + int fd = ::creat(path.c_str(), _S_IREAD | _S_IWRITE); + #else int fd = ::creat(path.c_str(), 0777); + #endif ASSERT_TRUE(fd); // On Windows, we won't be able to remove the file unless we close it // first. @@ -307,7 +311,11 @@ TEST(AdminSocket, bind_and_listen) { { int fd = 0; string message; + #ifdef _WIN32 + int fd2 = ::creat(path.c_str(), _S_IREAD | _S_IWRITE); + #else int fd2 = ::creat(path.c_str(), 0777); + #endif ASSERT_TRUE(fd2); // On Windows, we won't be able to remove the file unless we close it // first.