]>
git.proxmox.com Git - ceph.git/blob - ceph/src/test/libcephfs/newops.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2021 Red Hat Inc.
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
15 #include "gmock/gmock.h"
16 #include "gtest/gtest.h"
17 #include "gtest/gtest-spi.h"
18 #include "gmock/gmock-matchers.h"
19 #include "gmock/gmock-more-matchers.h"
20 #include "include/compat.h"
21 #include "include/cephfs/libcephfs.h"
22 #include "include/fs_types.h"
23 #include "mds/mdstypes.h"
24 #include "include/stat.h"
32 #include <sys/xattr.h>
35 #include <fmt/format.h>
42 using ::testing::AnyOf
;
48 * Test this with different ceph versions
51 TEST(LibCephFS
, NewOPs
)
53 struct ceph_mount_info
*cmount
;
54 ASSERT_EQ(0, ceph_create(&cmount
, NULL
));
55 ASSERT_EQ(0, ceph_conf_read_file(cmount
, NULL
));
56 ASSERT_EQ(0, ceph_conf_parse_env(cmount
, NULL
));
57 ASSERT_EQ(0, ceph_mount(cmount
, "/"));
59 const char *test_path
= "test_newops_dir";
61 ASSERT_EQ(0, ceph_mkdirs(cmount
, test_path
, 0777));
64 char value
[1024] = "";
65 int r
= ceph_getxattr(cmount
, test_path
, "ceph.dir.pin.random", (void*)value
, sizeof(value
));
66 // Clients will return -CEPHFS_ENODATA if new getvxattr op not support yet.
67 EXPECT_THAT(r
, AnyOf(Gt(0), Eq(-CEPHFS_ENODATA
)));
71 double val
= (double)1.0/(double)128.0;
74 int r
= ceph_setxattr(cmount
, test_path
, "ceph.dir.pin.random", (void*)ss
.str().c_str(), strlen(ss
.str().c_str()), XATTR_CREATE
);
75 // Old cephs will return -CEPHFS_EINVAL if not support "ceph.dir.pin.random" yet.
76 EXPECT_THAT(r
, AnyOf(Eq(0), Eq(-CEPHFS_EINVAL
)));
78 char value
[1024] = "";
79 r
= ceph_getxattr(cmount
, test_path
, "ceph.dir.pin.random", (void*)value
, sizeof(value
));
80 // Clients will return -CEPHFS_ENODATA if new getvxattr op not support yet.
81 EXPECT_THAT(r
, AnyOf(Gt(0), Eq(-CEPHFS_ENODATA
)));
84 ASSERT_EQ(0, ceph_rmdir(cmount
, test_path
));
86 ceph_shutdown(cmount
);