]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Add daemon_config, libceph_config, etc.
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Fri, 5 Aug 2011 18:20:24 +0000 (11:20 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Fri, 5 Aug 2011 18:20:24 +0000 (11:20 -0700)
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/Makefile.am
src/test/config.cc [deleted file]
src/test/daemon_config.cc [new file with mode: 0644]
src/test/libceph_config.cc [new file with mode: 0644]
src/test/librados_config.cc [new file with mode: 0644]

index 95c4e69bb3442872874ff874df424753d122f282..aa56950a0570b3dc5de1f10aebabf340ef1f3c70 100644 (file)
@@ -543,11 +543,23 @@ unittest_formatter_LDADD = ${UNITTEST_LDADD} $(LIBGLOBAL_LDA)
 unittest_formatter_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS}
 check_PROGRAMS += unittest_formatter
 
-unittest_config_SOURCES = test/config.cc
-unittest_config_LDFLAGS = -pthread ${AM_LDFLAGS}
-unittest_config_LDADD =  librados.la ${UNITTEST_LDADD}
-unittest_config_CXXFLAGS = ${CRYPTO_CFLAGS} ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS}
-check_PROGRAMS += unittest_config
+unittest_libceph_config_SOURCES = test/libceph_config.cc
+unittest_libceph_config_LDFLAGS = -pthread ${AM_LDFLAGS}
+unittest_libceph_config_LDADD =  libceph.la ${UNITTEST_LDADD}
+unittest_libceph_config_CXXFLAGS = ${CRYPTO_CFLAGS} ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS}
+check_PROGRAMS += unittest_libceph_config
+
+unittest_librados_config_SOURCES = test/librados_config.cc
+unittest_librados_config_LDFLAGS = -pthread ${AM_LDFLAGS}
+unittest_librados_config_LDADD =  librados.la ${UNITTEST_LDADD}
+unittest_librados_config_CXXFLAGS = ${CRYPTO_CFLAGS} ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS}
+check_PROGRAMS += unittest_librados_config
+
+unittest_daemon_config_SOURCES = test/daemon_config.cc
+unittest_daemon_config_LDFLAGS = -pthread ${AM_LDFLAGS}
+unittest_daemon_config_LDADD =  ${UNITTEST_LDADD} ${LIBGLOBAL_LDA}
+unittest_daemon_config_CXXFLAGS = ${CRYPTO_CFLAGS} ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS}
+check_PROGRAMS += unittest_daemon_config
 
 if WITH_RADOSGW
 unittest_librgw_SOURCES = test/librgw.cc
diff --git a/src/test/config.cc b/src/test/config.cc
deleted file mode 100644 (file)
index 210fcd0..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-// -*- 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/rados/librados.h"
-
-#include <sstream>
-#include <string>
-#include <string.h>
-
-using std::string;
-
-TEST(RadosConfig, SimpleSet) {
-  rados_t cl;
-  int ret = rados_create(&cl, NULL);
-  ASSERT_EQ(ret, 0);
-
-  ret = rados_conf_set(cl, "debug", "21");
-  ASSERT_EQ(ret, 0);
-
-  char buf[128];
-  memset(buf, 0, sizeof(buf));
-  ret = rados_conf_get(cl, "debug", buf, sizeof(buf));
-  ASSERT_EQ(ret, 0);
-  ASSERT_EQ(string("21"), string(buf));
-
-  rados_shutdown(cl);
-}
-
-TEST(RadosConfig, ArgV) {
-  rados_t cl;
-  int ret = rados_create(&cl, NULL);
-  ASSERT_EQ(ret, 0);
-
-  const char *argv[] = { "foo", "--debug", "2",
-                        "--keyfile", "/tmp/my-keyfile", NULL };
-  size_t argc = (sizeof(argv) / sizeof(argv[0])) - 1;
-  rados_conf_parse_argv(cl, argc, argv);
-
-  char buf[128];
-  memset(buf, 0, sizeof(buf));
-  ret = rados_conf_get(cl, "keyfile", buf, sizeof(buf));
-  ASSERT_EQ(ret, 0);
-  ASSERT_EQ(string("/tmp/my-keyfile"), string(buf));
-
-  memset(buf, 0, sizeof(buf));
-  ret = rados_conf_get(cl, "debug", buf, sizeof(buf));
-  ASSERT_EQ(ret, 0);
-  ASSERT_EQ(string("2"), string(buf));
-
-  rados_shutdown(cl);
-}
diff --git a/src/test/daemon_config.cc b/src/test/daemon_config.cc
new file mode 100644 (file)
index 0000000..caa5bbc
--- /dev/null
@@ -0,0 +1,61 @@
+// -*- 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 "common/ceph_argparse.h"
+#include "common/config.h"
+#include "include/ceph/libceph.h"
+#include "include/rados/librados.h"
+#include "test/unit.h"
+
+#include <sstream>
+#include <string>
+#include <string.h>
+
+using std::string;
+
+TEST(DaemonConfig, SimpleSet) {
+  int ret;
+  ret = g_ceph_context->_conf->set_val("debug", "21");
+  ASSERT_EQ(ret, 0);
+  g_ceph_context->_conf->apply_changes(NULL);
+  char buf[128];
+  memset(buf, 0, sizeof(buf));
+  char *tmp = buf;
+  ret = g_ceph_context->_conf->get_val("debug", &tmp, sizeof(buf));
+  ASSERT_EQ(ret, 0);
+  ASSERT_EQ(string("21"), string(buf));
+}
+
+TEST(DaemonConfig, ArgV) {
+  int ret;
+  const char *argv[] = { "foo", "--debug", "22",
+                        "--keyfile", "/tmp/my-keyfile", NULL };
+  size_t argc = (sizeof(argv) / sizeof(argv[0])) - 1;
+  vector<const char*> args;
+  argv_to_vec(argc, argv, args);
+  g_ceph_context->_conf->parse_argv(args);
+  g_ceph_context->_conf->apply_changes(NULL);
+
+  char buf[128];
+  char *tmp = buf;
+  memset(buf, 0, sizeof(buf));
+  ret = g_ceph_context->_conf->get_val("keyfile", &tmp, sizeof(buf));
+  ASSERT_EQ(ret, 0);
+  ASSERT_EQ(string("/tmp/my-keyfile"), string(buf));
+
+  memset(buf, 0, sizeof(buf));
+  ret = g_ceph_context->_conf->get_val("debug", &tmp, sizeof(buf));
+  ASSERT_EQ(ret, 0);
+  ASSERT_EQ(string("22"), string(buf));
+}
diff --git a/src/test/libceph_config.cc b/src/test/libceph_config.cc
new file mode 100644 (file)
index 0000000..aac7dab
--- /dev/null
@@ -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/ceph/libceph.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, "debug", "21");
+  ASSERT_EQ(ret, 0);
+
+  char buf[128];
+  memset(buf, 0, sizeof(buf));
+  ret = ceph_conf_get(cmount, "debug", 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", "--debug", "2",
+                        "--keyfile", "/tmp/my-keyfile", 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, "keyfile", buf, sizeof(buf));
+  ASSERT_EQ(ret, 0);
+  ASSERT_EQ(string("/tmp/my-keyfile"), string(buf));
+
+  memset(buf, 0, sizeof(buf));
+  ret = ceph_conf_get(cmount, "debug", buf, sizeof(buf));
+  ASSERT_EQ(ret, 0);
+  ASSERT_EQ(string("2"), string(buf));
+
+  ceph_shutdown(cmount);
+}
diff --git a/src/test/librados_config.cc b/src/test/librados_config.cc
new file mode 100644 (file)
index 0000000..afb5efc
--- /dev/null
@@ -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/rados/librados.h"
+
+#include <sstream>
+#include <string>
+#include <string.h>
+
+using std::string;
+
+TEST(LibRadosConfig, SimpleSet) {
+  rados_t cl;
+  int ret = rados_create(&cl, NULL);
+  ASSERT_EQ(ret, 0);
+
+  ret = rados_conf_set(cl, "debug", "21");
+  ASSERT_EQ(ret, 0);
+
+  char buf[128];
+  memset(buf, 0, sizeof(buf));
+  ret = rados_conf_get(cl, "debug", buf, sizeof(buf));
+  ASSERT_EQ(ret, 0);
+  ASSERT_EQ(string("21"), string(buf));
+
+  rados_shutdown(cl);
+}
+
+TEST(LibRadosConfig, ArgV) {
+  rados_t cl;
+  int ret = rados_create(&cl, NULL);
+  ASSERT_EQ(ret, 0);
+
+  const char *argv[] = { "foo", "--debug", "2",
+                        "--keyfile", "/tmp/my-keyfile", NULL };
+  size_t argc = (sizeof(argv) / sizeof(argv[0])) - 1;
+  rados_conf_parse_argv(cl, argc, argv);
+
+  char buf[128];
+  memset(buf, 0, sizeof(buf));
+  ret = rados_conf_get(cl, "keyfile", buf, sizeof(buf));
+  ASSERT_EQ(ret, 0);
+  ASSERT_EQ(string("/tmp/my-keyfile"), string(buf));
+
+  memset(buf, 0, sizeof(buf));
+  ret = rados_conf_get(cl, "debug", buf, sizeof(buf));
+  ASSERT_EQ(ret, 0);
+  ASSERT_EQ(string("2"), string(buf));
+
+  rados_shutdown(cl);
+}