summaryrefslogtreecommitdiffstats
path: root/src/test/libcephfs_config.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/test/libcephfs_config.cc
parentInitial commit. (diff)
downloadceph-upstream.tar.xz
ceph-upstream.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/libcephfs_config.cc')
-rw-r--r--src/test/libcephfs_config.cc63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/test/libcephfs_config.cc b/src/test/libcephfs_config.cc
new file mode 100644
index 00000000..dd8acc83
--- /dev/null
+++ b/src/test/libcephfs_config.cc
@@ -0,0 +1,63 @@
+// -*- 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) 2011 New Dream Network
+ *
+ * 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 "gtest/gtest.h"
+#include "include/cephfs/libcephfs.h"
+
+#include <sstream>
+#include <string>
+#include <string.h>
+
+using std::string;
+
+TEST(LibCephConfig, SimpleSet) {
+ struct ceph_mount_info *cmount;
+ int ret = ceph_create(&cmount, NULL);
+ ASSERT_EQ(ret, 0);
+
+ ret = ceph_conf_set(cmount, "leveldb_max_open_files", "21");
+ ASSERT_EQ(ret, 0);
+
+ char buf[128];
+ memset(buf, 0, sizeof(buf));
+ ret = ceph_conf_get(cmount, "leveldb_max_open_files", buf, sizeof(buf));
+ ASSERT_EQ(ret, 0);
+ ASSERT_EQ(string("21"), string(buf));
+
+ ceph_shutdown(cmount);
+}
+
+TEST(LibCephConfig, ArgV) {
+ struct ceph_mount_info *cmount;
+ int ret = ceph_create(&cmount, NULL);
+ ASSERT_EQ(ret, 0);
+
+ const char *argv[] = { "foo", "--leveldb-max-open-files", "2",
+ "--key", "my-key", NULL };
+ size_t argc = (sizeof(argv) / sizeof(argv[0])) - 1;
+ ceph_conf_parse_argv(cmount, argc, argv);
+
+ char buf[128];
+ memset(buf, 0, sizeof(buf));
+ ret = ceph_conf_get(cmount, "key", buf, sizeof(buf));
+ ASSERT_EQ(ret, 0);
+ ASSERT_EQ(string("my-key"), string(buf));
+
+ memset(buf, 0, sizeof(buf));
+ ret = ceph_conf_get(cmount, "leveldb_max_open_files", buf, sizeof(buf));
+ ASSERT_EQ(ret, 0);
+ ASSERT_EQ(string("2"), string(buf));
+
+ ceph_shutdown(cmount);
+}