]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test: fix Windows ::_creat 53291/head
authorLucian Petrut <lpetrut@cloudbasesolutions.com>
Mon, 6 Nov 2023 14:58:08 +0000 (14:58 +0000)
committerLucian Petrut <lpetrut@cloudbasesolutions.com>
Wed, 22 Nov 2023 09:15:00 +0000 (09:15 +0000)
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 <lpetrut@cloudbasesolutions.com>
src/global/signal_handler.cc
src/test/admin_socket.cc

index 055763eee4691eccfaa05559f63c4b1a75eb874b..d33872678719cea2935ae1d97c83449a5f749ded 100644 (file)
@@ -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
     }
   }
 }
index a8236271652c2bb15647d9b45d79a072b59625c3..03bbb72b2a9a5934cb776a0993b82ce5cf0b8557 100644 (file)
@@ -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.