]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/libcephfs: address windows issues
authorLucian Petrut <lpetrut@cloudbasesolutions.com>
Mon, 5 Sep 2022 13:13:46 +0000 (13:13 +0000)
committerLucian Petrut <lpetrut@cloudbasesolutions.com>
Thu, 10 Nov 2022 07:38:13 +0000 (09:38 +0200)
This commit addresses a few issues that prevent the libcephfs from running
on Windows:

* added missing definitions to fs_compat.h
* the "nobody" user is ignored on Windows, which is why we'll skip the tests
  that rely on it
* sys/mman.h and sys/resource.h are not available on Windows and will be skipped
* skip rlimit, not available on Windows
* fork is not available on Windows, for now we'll avoid compiling those tests
  when targetting Windows. For what is worth, those are skipped on other
  platforms anyway but currently fail at compile time when using mingw.
* use "strchr" instead of "index" or "strchrnul"

Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
src/client/Client.cc
src/include/win32/fs_compat.h
src/test/libcephfs/acl.cc
src/test/libcephfs/flock.cc
src/test/libcephfs/recordlock.cc
src/test/libcephfs/test.cc
src/test/libcephfs/vxattr.cc

index 4c180ef754da4065a308e458119b3b6c33431292..6a29f534f2046490046442d63262e364ee451362 100644 (file)
 
 #include "common/async/waiter.h"
 
-#if defined(__FreeBSD__) || defined(_WIN32)
+#if defined(__FreeBSD__)
 #define XATTR_CREATE    0x1
 #define XATTR_REPLACE   0x2
-#else
+#elif !defined(_WIN32)
 #include <sys/xattr.h>
 #endif
 
index c3405e670f95f38d126eed61d26212557eff8892..2fce1b72e856c86da4ac35a708067b2767c4b45e 100644 (file)
@@ -34,3 +34,9 @@
 #define AT_REMOVEDIR        0x200
 
 #define MAXSYMLINKS  65000
+
+#define O_DIRECTORY 0200000
+#define O_NOFOLLOW  0400000
+
+#define XATTR_CREATE  1
+#define XATTR_REPLACE 2
index 2827a9b4b788b613d69b4444cc3161cb204a1255..2e5989f49ea8196042ad905cd896f1967630ebc0 100644 (file)
@@ -147,7 +147,10 @@ TEST(ACL, SetACL) {
   ASSERT_EQ(ceph_fchown(cmount, fd, 65534, 65534), 0);
 
   ASSERT_EQ(0, ceph_conf_set(cmount, "client_permissions", "1"));
+  // "nobody" will be ignored on Windows
+  #ifndef _WIN32
   ASSERT_EQ(ceph_open(cmount, test_file, O_RDWR, 0), -EACCES);
+  #endif
   ASSERT_EQ(0, ceph_conf_set(cmount, "client_permissions", "0"));
 
   size_t acl_buf_size = acl_ea_size(5);
index a213fbb5cc9c2ed8b0197753aad731a8d38a9960..1c400f9dc1e4e54cdcfa23a57d5d22da54c6b26d 100644 (file)
 #include <stdlib.h>
 #include <semaphore.h>
 #include <time.h>
+
+#ifndef _WIN32
 #include <sys/mman.h>
+#endif
 
 #ifdef __linux__
 #include <limits.h>
@@ -432,6 +435,7 @@ static void process_ConcurrentLocking(str_ConcurrentLocking& s) {
   exit(EXIT_SUCCESS);
 }
 
+#ifndef _WIN32
 // Disabled because of fork() issues (http://tracker.ceph.com/issues/16556)
 TEST(LibCephFS, DISABLED_InterProcessLocking) {
   PROCESS_SLOW_MS();
@@ -531,7 +535,9 @@ TEST(LibCephFS, DISABLED_InterProcessLocking) {
   ASSERT_EQ(0, ceph_unlink(cmount, c_file));
   CLEANUP_CEPH();
 }
+#endif
 
+#ifndef _WIN32
 // Disabled because of fork() issues (http://tracker.ceph.com/issues/16556)
 TEST(LibCephFS, DISABLED_ThreesomeInterProcessLocking) {
   PROCESS_SLOW_MS();
@@ -644,3 +650,4 @@ TEST(LibCephFS, DISABLED_ThreesomeInterProcessLocking) {
   ASSERT_EQ(0, ceph_unlink(cmount, c_file));
   CLEANUP_CEPH();
 }
+#endif
index 9189038f89d9cb814d9255185b3e6fe33011555e..3c0679d7db39f06fc6f49b15dfabdcf49f7d9e6c 100644 (file)
 #include <stdlib.h>
 #include <semaphore.h>
 #include <time.h>
+
+#ifndef _WIN32
 #include <sys/mman.h>
+#endif
 
 #ifdef __linux__
 #include <limits.h>
@@ -763,6 +766,7 @@ static void process_ConcurrentRecordLocking(str_ConcurrentRecordLocking& s) {
 }
 
 // Disabled because of fork() issues (http://tracker.ceph.com/issues/16556)
+#ifndef _WIN32
 TEST(LibCephFS, DISABLED_InterProcessRecordLocking) {
   PROCESS_SLOW_MS();
   // Process synchronization
@@ -923,7 +927,9 @@ TEST(LibCephFS, DISABLED_InterProcessRecordLocking) {
   ASSERT_EQ(0, ceph_ll_unlink(cmount, root, c_file, perms));
   CLEANUP_CEPH();
 }
+#endif
 
+#ifndef _WIN32
 // Disabled because of fork() issues (http://tracker.ceph.com/issues/16556)
 TEST(LibCephFS, DISABLED_ThreesomeInterProcessRecordLocking) {
   PROCESS_SLOW_MS();
@@ -1095,3 +1101,4 @@ TEST(LibCephFS, DISABLED_ThreesomeInterProcessRecordLocking) {
   ASSERT_EQ(0, ceph_ll_unlink(cmount, root, c_file, perms));
   CLEANUP_CEPH();
 }
+#endif
index 998c86ec51aacc4a172947cf7fd42b508832120d..a94ab036e33934da23a61b330a7c13829834a915 100644 (file)
 #include <dirent.h>
 #include <sys/uio.h>
 #include <sys/time.h>
+
+#ifndef _WIN32
 #include <sys/resource.h>
+#endif
 
 #include "common/Clock.h"
 
@@ -595,7 +598,7 @@ TEST(LibCephFS, Xattrs) {
     sprintf(xattrv, "testxattr%c", i);
     ASSERT_TRUE(!strncmp(xattrv, gxattrv, alen));
 
-    n = index(p, '\0');
+    n = strchr(p, '\0');
     n++;
     len -= (n - p);
     p = n;
@@ -895,8 +898,11 @@ TEST(LibCephFS, Fchown) {
 
   ceph_close(cmount, fd);
 
+  // "nobody" will be ignored on Windows
+  #ifndef _WIN32
   fd = ceph_open(cmount, test_file, O_RDWR, 0);
   ASSERT_EQ(fd, -EACCES);
+  #endif
 
   ceph_shutdown(cmount);
 }
@@ -2167,6 +2173,8 @@ TEST(LibCephFS, OperationsOnRoot)
   ceph_shutdown(cmount);
 }
 
+// no rlimits on Windows
+#ifndef _WIN32
 static void shutdown_racer_func()
 {
   const int niter = 32;
@@ -2212,6 +2220,7 @@ TEST(LibCephFS, ShutdownRace)
    */
 //  ASSERT_EQ(setrlimit(RLIMIT_NOFILE, &rold), 0);
 }
+#endif
 
 static void get_current_time_utimbuf(struct utimbuf *utb)
 {
@@ -2442,7 +2451,8 @@ TEST(LibCephFS, SnapXattrs) {
   ASSERT_LT(0, alen);
   ASSERT_LT(alen, xbuflen);
   gxattrv[alen] = '\0';
-  char *s = strchrnul(gxattrv, '.');
+  char *s = strchr(gxattrv, '.');
+  ASSERT_NE(0, s);
   ASSERT_LT(s, gxattrv + alen);
   ASSERT_EQ('.', *s);
   *s = '\0';
@@ -2469,7 +2479,8 @@ TEST(LibCephFS, SnapXattrs) {
   ASSERT_LT(0, alen);
   ASSERT_LT(alen, xbuflen);
   gxattrv2[alen] = '\0';
-  s = strchrnul(gxattrv2, '.');
+  s = strchr(gxattrv2, '.');
+  ASSERT_NE(0, s);
   ASSERT_LT(s, gxattrv2 + alen);
   ASSERT_EQ('.', *s);
   *s = '\0';
@@ -3331,8 +3342,11 @@ TEST(LibCephFS, Chownat) {
   ASSERT_EQ(ceph_conf_set(cmount, "client_permissions", "1"), 0);
   ceph_close(cmount, fd);
 
+  // "nobody" will be ignored on Windows
+  #ifndef _WIN32
   fd = ceph_open(cmount, file_path, O_RDWR, 0);
   ASSERT_EQ(fd, -EACCES);
+  #endif
 
   ASSERT_EQ(ceph_conf_set(cmount, "client_permissions", "0"), 0);
   ASSERT_EQ(0, ceph_unlink(cmount, file_path));
@@ -3372,8 +3386,11 @@ TEST(LibCephFS, ChownatATFDCWD) {
   ASSERT_EQ(ceph_chownat(cmount, CEPHFS_AT_FDCWD, rel_file_path, 65534, 65534, 0), 0);
   ASSERT_EQ(ceph_conf_set(cmount, "client_permissions", "1"), 0);
 
+  // "nobody" will be ignored on Windows
+  #ifndef _WIN32
   fd = ceph_open(cmount, file_path, O_RDWR, 0);
   ASSERT_EQ(fd, -EACCES);
+  #endif
 
   ASSERT_EQ(ceph_conf_set(cmount, "client_permissions", "0"), 0);
   ASSERT_EQ(0, ceph_unlink(cmount, file_path));
index 2a5ad70e4a0263923b79de8496d62b4891eabc29..9af85a0c40edd3a51cddcf5ca762e37eb60dce20 100644 (file)
 #include <dirent.h>
 #include <sys/uio.h>
 #include <sys/time.h>
-#include <sys/resource.h>
 #include <string.h>
 
+#ifndef _WIN32
+#include <sys/resource.h>
+#endif
+
 #include "common/Clock.h"
 #include "common/ceph_json.h"