From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/test/libcephfs/newops.cc | 86 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 src/test/libcephfs/newops.cc (limited to 'src/test/libcephfs/newops.cc') diff --git a/src/test/libcephfs/newops.cc b/src/test/libcephfs/newops.cc new file mode 100644 index 000000000..9897cb8c6 --- /dev/null +++ b/src/test/libcephfs/newops.cc @@ -0,0 +1,86 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2021 Red Hat Inc. + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include "gtest/gtest-spi.h" +#include "gmock/gmock-matchers.h" +#include "gmock/gmock-more-matchers.h" +#include "include/compat.h" +#include "include/cephfs/libcephfs.h" +#include "mds/mdstypes.h" +#include "include/stat.h" +#include +#include +#include +#include + +#ifdef __linux__ +#include +#include +#endif + +#include +#include +#include +#include +#include +#include + +using ::testing::AnyOf; +using ::testing::Gt; +using ::testing::Eq; +using namespace std; + +/* + * Test this with different ceph versions + */ + +TEST(LibCephFS, NewOPs) +{ + struct ceph_mount_info *cmount; + ASSERT_EQ(0, ceph_create(&cmount, NULL)); + ASSERT_EQ(0, ceph_conf_read_file(cmount, NULL)); + ASSERT_EQ(0, ceph_conf_parse_env(cmount, NULL)); + ASSERT_EQ(0, ceph_mount(cmount, "/")); + + const char *test_path = "test_newops_dir"; + + ASSERT_EQ(0, ceph_mkdirs(cmount, test_path, 0777)); + + { + char value[1024] = ""; + int r = ceph_getxattr(cmount, test_path, "ceph.dir.pin.random", (void*)value, sizeof(value)); + // Clients will return -ENODATA if new getvxattr op not support yet. + EXPECT_THAT(r, AnyOf(Gt(0), Eq(-ENODATA))); + } + + { + double val = (double)1.0/(double)128.0; + std::stringstream ss; + ss << val; + int r = ceph_setxattr(cmount, test_path, "ceph.dir.pin.random", (void*)ss.str().c_str(), strlen(ss.str().c_str()), XATTR_CREATE); + // Old cephs will return -EINVAL if not support "ceph.dir.pin.random" yet. + EXPECT_THAT(r, AnyOf(Eq(0), Eq(-EINVAL))); + + char value[1024] = ""; + r = ceph_getxattr(cmount, test_path, "ceph.dir.pin.random", (void*)value, sizeof(value)); + // Clients will return -ENODATA if new getvxattr op not support yet. + EXPECT_THAT(r, AnyOf(Gt(0), Eq(-ENODATA))); + } + + ASSERT_EQ(0, ceph_rmdir(cmount, test_path)); + + ceph_shutdown(cmount); +} -- cgit v1.2.3