summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ceph_fuse.cc6
-rw-r--r--src/ceph_mds.cc7
-rw-r--r--src/ceph_mgr.cc5
-rw-r--r--src/ceph_mon.cc6
-rw-r--r--src/ceph_osd.cc6
-rw-r--r--src/ceph_syn.cc3
-rw-r--r--src/global/global_init.cc23
-rw-r--r--src/global/global_init.h9
-rw-r--r--src/librados-config.cc5
-rw-r--r--src/os/bluestore/bluefs_tool.cc3
-rw-r--r--src/rbd_replay/rbd-replay.cc3
-rw-r--r--src/rgw/librgw.cc10
-rw-r--r--src/rgw/rgw_admin.cc3
-rw-r--r--src/rgw/rgw_lib.h2
-rw-r--r--src/rgw/rgw_main.cc12
-rw-r--r--src/rgw/rgw_object_expirer.cc5
-rw-r--r--src/rgw/rgw_token.cc3
-rw-r--r--src/test/ObjectMap/test_keyvaluedb_iterators.cc2
-rw-r--r--src/test/ObjectMap/test_object_map.cc3
-rw-r--r--src/test/TestSignalHandlers.cc3
-rw-r--r--src/test/TestTimers.cc3
-rw-r--r--src/test/admin_socket.cc16
-rw-r--r--src/test/bench/small_io_bench_dumb.cc2
-rw-r--r--src/test/bench/small_io_bench_fs.cc2
-rw-r--r--src/test/bench/tp_bench.cc2
-rw-r--r--src/test/bench_log.cc3
-rw-r--r--src/test/common/Throttle.cc14
-rw-r--r--src/test/common/get_command_descriptions.cc3
-rw-r--r--src/test/common/test_async_compressor.cc2
-rw-r--r--src/test/common/test_shared_cache.cc14
-rw-r--r--src/test/common/test_sharedptr_registry.cc14
-rw-r--r--src/test/compressor/test_compression.cc20
-rw-r--r--src/test/crush/CrushWrapper.cc3
-rw-r--r--src/test/crush/crush.cc17
-rw-r--r--src/test/crypto_init.cc5
-rw-r--r--src/test/erasure-code/TestErasureCode.cc19
-rw-r--r--src/test/erasure-code/TestErasureCodeExample.cc17
-rw-r--r--src/test/erasure-code/TestErasureCodeIsa.cc18
-rw-r--r--src/test/erasure-code/TestErasureCodeJerasure.cc20
-rw-r--r--src/test/erasure-code/TestErasureCodeLrc.cc20
-rw-r--r--src/test/erasure-code/TestErasureCodePlugin.cc19
-rw-r--r--src/test/erasure-code/TestErasureCodePluginIsa.cc17
-rw-r--r--src/test/erasure-code/TestErasureCodePluginJerasure.cc21
-rw-r--r--src/test/erasure-code/TestErasureCodePluginLrc.cc20
-rw-r--r--src/test/erasure-code/TestErasureCodePluginShec.cc20
-rw-r--r--src/test/erasure-code/TestErasureCodeShec.cc17
-rw-r--r--src/test/erasure-code/TestErasureCodeShec_all.cc3
-rw-r--r--src/test/erasure-code/TestErasureCodeShec_arguments.cc3
-rw-r--r--src/test/erasure-code/TestErasureCodeShec_thread.cc19
-rw-r--r--src/test/erasure-code/ceph_erasure_code.cc2
-rw-r--r--src/test/erasure-code/ceph_erasure_code_benchmark.cc2
-rw-r--r--src/test/erasure-code/ceph_erasure_code_non_regression.cc8
-rw-r--r--src/test/filestore/TestFileStore.cc3
-rw-r--r--src/test/fio/fio_ceph_objectstore.cc12
-rw-r--r--src/test/journal/test_main.cc4
-rw-r--r--src/test/librados/list.cc19
-rw-r--r--src/test/librados/misc.cc17
-rwxr-xr-xsrc/test/librados/tier.cc18
-rw-r--r--src/test/mds/TestMDSAuthCaps.cc18
-rw-r--r--src/test/mds/TestSessionFilter.cc15
-rw-r--r--src/test/messenger/simple_client.cc5
-rw-r--r--src/test/messenger/simple_server.cc5
-rw-r--r--src/test/messenger/xio_client.cc5
-rw-r--r--src/test/mon/PGMap.cc16
-rw-r--r--src/test/mon/test-mon-msg.cc7
-rw-r--r--src/test/mon/test_mon_workloadgen.cc6
-rw-r--r--src/test/msgr/perf_msgr_client.cc3
-rw-r--r--src/test/msgr/perf_msgr_server.cc3
-rw-r--r--src/test/msgr/test_async_driver.cc13
-rw-r--r--src/test/msgr/test_async_networkstack.cc15
-rw-r--r--src/test/msgr/test_msgr.cc2
-rw-r--r--src/test/msgr/test_userspace_event.cc16
-rw-r--r--src/test/objectstore/Allocator_test.cc26
-rw-r--r--src/test/objectstore/BitAllocator_test.cc18
-rw-r--r--src/test/objectstore/ObjectStoreTransactionBenchmark.cc3
-rw-r--r--src/test/objectstore/TestRocksdbOptionParse.cc14
-rw-r--r--src/test/objectstore/chain_xattr.cc3
-rw-r--r--src/test/objectstore/store_test.cc7
-rw-r--r--src/test/objectstore/test_bluefs.cc5
-rw-r--r--src/test/objectstore/test_bluestore_types.cc7
-rw-r--r--src/test/objectstore/test_idempotent.cc3
-rw-r--r--src/test/objectstore/test_idempotent_sequence.cc6
-rw-r--r--src/test/objectstore/test_kv.cc3
-rw-r--r--src/test/objectstore/test_memstore_clone.cc11
-rw-r--r--src/test/objectstore/workload_generator.cc6
-rw-r--r--src/test/objectstore_bench.cc3
-rw-r--r--src/test/os/TestLFNIndex.cc3
-rw-r--r--src/test/osd/TestOSDMap.cc6
-rw-r--r--src/test/osd/TestOSDScrub.cc15
-rw-r--r--src/test/osd/TestPGLog.cc15
-rw-r--r--src/test/osdc/object_cacher_stress.cc3
-rw-r--r--src/test/perf_counters.cc5
-rw-r--r--src/test/perf_local.cc3
-rw-r--r--src/test/rbd_mirror/random_write.cc17
-rw-r--r--src/test/rgw/test_http_manager.cc3
-rw-r--r--src/test/rgw/test_rgw_compression.cc17
-rw-r--r--src/test/rgw/test_rgw_period_history.cc3
-rw-r--r--src/test/test_arch.cc16
-rw-r--r--src/test/test_cors.cc3
-rw-r--r--src/test/test_filejournal.cc3
-rw-r--r--src/test/test_mempool.cc3
-rw-r--r--src/test/test_mutate.cc3
-rw-r--r--src/test/test_rgw_admin_log.cc3
-rw-r--r--src/test/test_rgw_admin_meta.cc3
-rw-r--r--src/test/test_rgw_admin_opstate.cc3
-rw-r--r--src/test/test_snap_mapper.cc16
-rw-r--r--src/test/test_striper.cc19
-rw-r--r--src/test/test_trans.cc3
-rw-r--r--src/test/test_workqueue.cc18
-rw-r--r--src/test/testkeys.cc3
-rw-r--r--src/test/testmsgr.cc3
-rw-r--r--src/test/unit.h17
-rw-r--r--src/test/xattr_bench.cc3
-rw-r--r--src/tools/ceph-client-debug.cc5
-rw-r--r--src/tools/ceph_authtool.cc5
-rw-r--r--src/tools/ceph_conf.cc6
-rw-r--r--src/tools/ceph_kvstore_tool.cc2
-rw-r--r--src/tools/ceph_monstore_tool.cc2
-rw-r--r--src/tools/ceph_objectstore_tool.cc63
-rw-r--r--src/tools/ceph_osdomap_tool.cc2
-rw-r--r--src/tools/cephfs/cephfs-data-scan.cc3
-rw-r--r--src/tools/cephfs/cephfs-journal-tool.cc3
-rw-r--r--src/tools/cephfs/cephfs-table-tool.cc3
-rw-r--r--src/tools/crushtool.cc5
-rw-r--r--src/tools/monmaptool.cc5
-rw-r--r--src/tools/osdmaptool.cc5
-rw-r--r--src/tools/rados/rados.cc3
-rw-r--r--src/tools/rbd/rbd.cc3
-rw-r--r--src/tools/rbd_mirror/main.cc7
-rw-r--r--src/tools/rbd_nbd/rbd-nbd.cc5
130 files changed, 333 insertions, 804 deletions
diff --git a/src/ceph_fuse.cc b/src/ceph_fuse.cc
index f5d04daeef9..b18264efbc9 100644
--- a/src/ceph_fuse.cc
+++ b/src/ceph_fuse.cc
@@ -77,8 +77,9 @@ int main(int argc, const char **argv, const char *envp[]) {
}
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_DAEMON,
- CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_DAEMON,
+ CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS);
for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
if (ceph_argparse_double_dash(args, i)) {
break;
@@ -287,7 +288,6 @@ int main(int argc, const char **argv, const char *envp[]) {
foo += ::write(fd[1], &r, sizeof(r));
}
- g_ceph_context->put();
free(newargv);
delete mc;
diff --git a/src/ceph_mds.cc b/src/ceph_mds.cc
index 458116bccc3..5f8173e724e 100644
--- a/src/ceph_mds.cc
+++ b/src/ceph_mds.cc
@@ -91,8 +91,9 @@ int main(int argc, const char **argv)
argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_MDS, CODE_ENVIRONMENT_DAEMON,
- 0, "mds_data");
+ auto cct = global_init(NULL, args,
+ CEPH_ENTITY_TYPE_MDS, CODE_ENVIRONMENT_DAEMON,
+ 0, "mds_data");
ceph_heap_profiler_init();
std::string val, action;
@@ -228,8 +229,6 @@ int main(int argc, const char **argv)
delete msgr;
}
- g_ceph_context->put();
-
// cd on exit, so that gmon.out (if any) goes into a separate directory for each node.
char s[20];
snprintf(s, sizeof(s), "gmon/%d", getpid());
diff --git a/src/ceph_mgr.cc b/src/ceph_mgr.cc
index 9365fb83fd1..acdddec194e 100644
--- a/src/ceph_mgr.cc
+++ b/src/ceph_mgr.cc
@@ -35,8 +35,9 @@ int main(int argc, const char **argv)
argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_MGR, CODE_ENVIRONMENT_DAEMON, 0,
- "mgr_data");
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_MGR,
+ CODE_ENVIRONMENT_DAEMON, 0,
+ "mgr_data");
// For consumption by KeyRing::from_ceph_context in MonClient
g_conf->set_val("keyring", "$mgr_data/keyring", false);
diff --git a/src/ceph_mon.cc b/src/ceph_mon.cc
index 3b15e56cc34..d592b680412 100644
--- a/src/ceph_mon.cc
+++ b/src/ceph_mon.cc
@@ -236,8 +236,9 @@ int main(int argc, const char **argv)
}
}
- global_init(&def_args, args,
- CEPH_ENTITY_TYPE_MON, CODE_ENVIRONMENT_DAEMON, flags, "mon_data");
+ auto cct = global_init(&def_args, args,
+ CEPH_ENTITY_TYPE_MON, CODE_ENVIRONMENT_DAEMON,
+ flags, "mon_data");
ceph_heap_profiler_init();
uuid_d fsid;
@@ -759,7 +760,6 @@ int main(int argc, const char **argv)
delete msgr;
delete client_throttler;
delete daemon_throttler;
- g_ceph_context->put();
// cd on exit, so that gmon.out (if any) goes into a separate directory for each node.
char s[20];
diff --git a/src/ceph_osd.cc b/src/ceph_osd.cc
index 33cb705a0d6..b7724e8eb49 100644
--- a/src/ceph_osd.cc
+++ b/src/ceph_osd.cc
@@ -101,8 +101,9 @@ int main(int argc, const char **argv)
// option, therefore we will pass it as a default argument to global_init().
def_args.push_back("--leveldb-log=");
- global_init(&def_args, args, CEPH_ENTITY_TYPE_OSD, CODE_ENVIRONMENT_DAEMON,
- 0, "osd_data");
+ auto cct = global_init(&def_args, args, CEPH_ENTITY_TYPE_OSD,
+ CODE_ENVIRONMENT_DAEMON,
+ 0, "osd_data");
ceph_heap_profiler_init();
// osd specific args
@@ -636,7 +637,6 @@ int main(int argc, const char **argv)
client_byte_throttler.reset();
client_msg_throttler.reset();
- g_ceph_context->put();
// cd on exit, so that gmon.out (if any) goes into a separate directory for each node.
char s[20];
diff --git a/src/ceph_syn.cc b/src/ceph_syn.cc
index b872b821568..d3ed16a1295 100644
--- a/src/ceph_syn.cc
+++ b/src/ceph_syn.cc
@@ -42,7 +42,8 @@ int main(int argc, const char **argv, char *envp[])
vector<const char*> args;
argv_to_vec(argc, argv, args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
parse_syn_options(args); // for SyntheticClient
diff --git a/src/global/global_init.cc b/src/global/global_init.cc
index c2b64ad5222..03669e914f3 100644
--- a/src/global/global_init.cc
+++ b/src/global/global_init.cc
@@ -130,11 +130,12 @@ void global_pre_init(std::vector < const char * > *alt_def_args,
g_conf->complain_about_parse_errors(g_ceph_context);
}
-void global_init(std::vector < const char * > *alt_def_args,
- std::vector < const char* >& args,
- uint32_t module_type, code_environment_t code_env,
- int flags,
- const char *data_dir_option, bool run_pre_init)
+boost::intrusive_ptr<CephContext>
+global_init(std::vector < const char * > *alt_def_args,
+ std::vector < const char* >& args,
+ uint32_t module_type, code_environment_t code_env,
+ int flags,
+ const char *data_dir_option, bool run_pre_init)
{
// Ensure we're not calling the global init functions multiple times.
static bool first_run = true;
@@ -325,6 +326,18 @@ void global_init(std::vector < const char * > *alt_def_args,
output_ceph_version();
g_ceph_context->crush_location.init_on_startup();
+
+ return boost::intrusive_ptr<CephContext>{g_ceph_context, false};
+}
+
+void intrusive_ptr_add_ref(CephContext* cct)
+{
+ cct->get();
+}
+
+void intrusive_ptr_release(CephContext* cct)
+{
+ cct->put();
}
void global_print_banner(void)
diff --git a/src/global/global_init.h b/src/global/global_init.h
index 1fe877d9cf4..ba74deb1f2d 100644
--- a/src/global/global_init.h
+++ b/src/global/global_init.h
@@ -17,7 +17,8 @@
#include <stdint.h>
#include <vector>
-
+#include <boost/intrusive_ptr.hpp>
+#include "include/assert.h"
#include "common/code_environment.h"
#include "common/common_init.h"
@@ -28,7 +29,8 @@ class CephContext;
* daemons and utility programs need to call. It takes care of a lot of
* initialization, including setting up g_ceph_context.
*/
-void global_init(std::vector < const char * > *alt_def_args,
+boost::intrusive_ptr<CephContext>
+ global_init(std::vector < const char * > *alt_def_args,
std::vector < const char* >& args,
uint32_t module_type,
code_environment_t code_env,
@@ -36,6 +38,9 @@ void global_init(std::vector < const char * > *alt_def_args,
const char *data_dir_option = 0,
bool run_pre_init = true);
+void intrusive_ptr_add_ref(CephContext* cct);
+void intrusive_ptr_release(CephContext* cct);
+
// just the first half; enough to get config parsed but doesn't start up the
// cct or log.
void global_pre_init(std::vector < const char * > *alt_def_args,
diff --git a/src/librados-config.cc b/src/librados-config.cc
index 83f9704524f..ba4799a412d 100644
--- a/src/librados-config.cc
+++ b/src/librados-config.cc
@@ -42,8 +42,9 @@ int main(int argc, const char **argv)
bool opt_version = false;
bool opt_vernum = false;
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
- CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY,
+ CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
common_init_finish(g_ceph_context);
for (std::vector<const char*>::iterator i = args.begin();
i != args.end(); ) {
diff --git a/src/os/bluestore/bluefs_tool.cc b/src/os/bluestore/bluefs_tool.cc
index 37385659176..150b16826be 100644
--- a/src/os/bluestore/bluefs_tool.cc
+++ b/src/os/bluestore/bluefs_tool.cc
@@ -25,7 +25,8 @@ int main(int argc, char **argv)
argv_to_vec(argc, (const char **)argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
g_ceph_context->_conf->set_val(
"enable_experimental_unrecoverable_data_corrupting_features",
diff --git a/src/rbd_replay/rbd-replay.cc b/src/rbd_replay/rbd-replay.cc
index b00c1310c90..3ec490ecb3b 100644
--- a/src/rbd_replay/rbd-replay.cc
+++ b/src/rbd_replay/rbd-replay.cc
@@ -60,7 +60,8 @@ int main(int argc, const char **argv) {
argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
std::vector<const char*>::iterator i;
string pool_name = "rbd";
diff --git a/src/rgw/librgw.cc b/src/rgw/librgw.cc
index a31408e7a08..8b5f24c7dba 100644
--- a/src/rgw/librgw.cc
+++ b/src/rgw/librgw.cc
@@ -447,10 +447,10 @@ namespace rgw {
def_args.push_back("--keyring=$rgw_data/keyring");
def_args.push_back("--log-file=/var/log/radosgw/$cluster-$name.log");
- global_init(&def_args, args,
- CEPH_ENTITY_TYPE_CLIENT,
- CODE_ENVIRONMENT_DAEMON,
- CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS);
+ cct = global_init(&def_args, args,
+ CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_DAEMON,
+ CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS);
Mutex mutex("main");
SafeTimer init_timer(g_ceph_context, mutex);
@@ -558,7 +558,7 @@ namespace rgw {
rgw_perf_stop(g_ceph_context);
dout(1) << "final shutdown" << dendl;
- g_ceph_context->put();
+ cct.reset();
ceph::crypto::shutdown();
diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc
index ab0b94d805b..ca0113eb1fc 100644
--- a/src/rgw/rgw_admin.cc
+++ b/src/rgw/rgw_admin.cc
@@ -2190,7 +2190,8 @@ int main(int argc, char **argv)
argv_to_vec(argc, (const char **)argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
rgw_user user_id;
diff --git a/src/rgw/rgw_lib.h b/src/rgw/rgw_lib.h
index 2493260d138..0a473ed4b1a 100644
--- a/src/rgw/rgw_lib.h
+++ b/src/rgw/rgw_lib.h
@@ -5,6 +5,7 @@
#include <mutex>
#include "include/unordered_map.h"
+#include "global/global_init.h"
#include "rgw_common.h"
#include "rgw_client_io.h"
#include "rgw_rest.h"
@@ -29,6 +30,7 @@ namespace rgw {
rgw::LDAPHelper* ldh;
RGWREST rest; // XXX needed for RGWProcessEnv
RGWRados* store;
+ boost::intrusive_ptr<CephContext> cct;
public:
RGWLib() : fec(nullptr), fe(nullptr), olog(nullptr), store(nullptr)
diff --git a/src/rgw/rgw_main.cc b/src/rgw/rgw_main.cc
index 52952ae1d7b..09e650e1dbd 100644
--- a/src/rgw/rgw_main.cc
+++ b/src/rgw/rgw_main.cc
@@ -175,9 +175,6 @@ static RGWRESTMgr *set_logging(RGWRESTMgr *mgr)
return mgr;
}
-void intrusive_ptr_add_ref(CephContext* cct) { cct->get(); }
-void intrusive_ptr_release(CephContext* cct) { cct->put(); }
-
RGWRealmReloader *preloader = NULL;
static void reloader_handler(int signum)
@@ -261,8 +258,10 @@ int main(int argc, const char **argv)
// Now that we've determined which frontend(s) to use, continue with global
// initialization. Passing false as the final argument ensures that
// global_pre_init() is not invoked twice.
- global_init(&def_args, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_DAEMON,
- flags, "rgw_data", false);
+ // claim the reference and release it after subsequent destructors have fired
+ auto cct = global_init(&def_args, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_DAEMON,
+ flags, "rgw_data", false);
for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ++i) {
if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
@@ -302,9 +301,6 @@ int main(int argc, const char **argv)
common_init_finish(g_ceph_context);
- // claim the reference and release it after subsequent destructors have fired
- boost::intrusive_ptr<CephContext> cct(g_ceph_context, false);
-
int r = rgw_tools_init(g_ceph_context);
if (r < 0) {
derr << "ERROR: unable to initialize rgw tools" << dendl;
diff --git a/src/rgw/rgw_object_expirer.cc b/src/rgw/rgw_object_expirer.cc
index 97a17bd3e28..1d44a8797cc 100644
--- a/src/rgw/rgw_object_expirer.cc
+++ b/src/rgw/rgw_object_expirer.cc
@@ -60,8 +60,9 @@ int main(const int argc, const char **argv)
argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_DAEMON,
- CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS, "rgw_data");
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_DAEMON,
+ CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS, "rgw_data");
for (std::vector<const char *>::iterator i = args.begin(); i != args.end(); ) {
if (ceph_argparse_double_dash(args, i)) {
diff --git a/src/rgw/rgw_token.cc b/src/rgw/rgw_token.cc
index c4ae0f0cdfd..04ef1fa7b47 100644
--- a/src/rgw/rgw_token.cc
+++ b/src/rgw/rgw_token.cc
@@ -64,7 +64,8 @@ int main(int argc, char **argv)
argv_to_vec(argc, (const char **)argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
char *v{nullptr};
diff --git a/src/test/ObjectMap/test_keyvaluedb_iterators.cc b/src/test/ObjectMap/test_keyvaluedb_iterators.cc
index 63e032b477b..454719c40fe 100644
--- a/src/test/ObjectMap/test_keyvaluedb_iterators.cc
+++ b/src/test/ObjectMap/test_keyvaluedb_iterators.cc
@@ -1743,7 +1743,7 @@ int main(int argc, char *argv[])
vector<const char*> args;
argv_to_vec(argc, (const char **) argv, args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
::testing::InitGoogleTest(&argc, argv);
diff --git a/src/test/ObjectMap/test_object_map.cc b/src/test/ObjectMap/test_object_map.cc
index 0d504df576a..a99e9200830 100644
--- a/src/test/ObjectMap/test_object_map.cc
+++ b/src/test/ObjectMap/test_object_map.cc
@@ -551,7 +551,8 @@ int main(int argc, char **argv) {
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
diff --git a/src/test/TestSignalHandlers.cc b/src/test/TestSignalHandlers.cc
index 60c1592970f..029d257dc84 100644
--- a/src/test/TestSignalHandlers.cc
+++ b/src/test/TestSignalHandlers.cc
@@ -79,7 +79,8 @@ int main(int argc, const char **argv)
argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
test_fn_t fn = NULL;
diff --git a/src/test/TestTimers.cc b/src/test/TestTimers.cc
index 5e2b6b97395..19f67f7b515 100644
--- a/src/test/TestTimers.cc
+++ b/src/test/TestTimers.cc
@@ -255,7 +255,8 @@ int main(int argc, const char **argv)
argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
int ret;
diff --git a/src/test/admin_socket.cc b/src/test/admin_socket.cc
index 212d754f379..b6777de9dd1 100644
--- a/src/test/admin_socket.cc
+++ b/src/test/admin_socket.cc
@@ -12,15 +12,12 @@
*
*/
-#include <gtest/gtest.h>
-
#include "common/Mutex.h"
#include "common/Cond.h"
#include "common/admin_socket.h"
#include "common/admin_socket_client.h"
#include "common/ceph_argparse.h"
-#include "global/global_init.h"
-#include "global/global_context.h"
+#include "test/unit.h"
#include <stdint.h>
#include <string.h>
@@ -293,17 +290,6 @@ TEST(AdminSocket, bind_and_listen) {
}
}
-int main(int argc, char **argv) {
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
-
- vector<const char*> def_args;
- global_init(&def_args, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
/*
* Local Variables:
* compile-command: "cd .. ;
diff --git a/src/test/bench/small_io_bench_dumb.cc b/src/test/bench/small_io_bench_dumb.cc
index f118880942a..a9df077c10c 100644
--- a/src/test/bench/small_io_bench_dumb.cc
+++ b/src/test/bench/small_io_bench_dumb.cc
@@ -95,7 +95,7 @@ int main(int argc, char **argv)
ceph_options.push_back(i->c_str());
}
- global_init(
+ auto cct = global_init(
&def_args, ceph_options, CEPH_ENTITY_TYPE_CLIENT,
CODE_ENVIRONMENT_UTILITY,
CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
diff --git a/src/test/bench/small_io_bench_fs.cc b/src/test/bench/small_io_bench_fs.cc
index 9466bd4d87a..7569b332d96 100644
--- a/src/test/bench/small_io_bench_fs.cc
+++ b/src/test/bench/small_io_bench_fs.cc
@@ -106,7 +106,7 @@ int main(int argc, char **argv)
ceph_options.push_back(i->c_str());
}
- global_init(
+ auto cct = global_init(
&def_args, ceph_options, CEPH_ENTITY_TYPE_CLIENT,
CODE_ENVIRONMENT_UTILITY,
CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
diff --git a/src/test/bench/tp_bench.cc b/src/test/bench/tp_bench.cc
index 6a50b6e0855..40267179d11 100644
--- a/src/test/bench/tp_bench.cc
+++ b/src/test/bench/tp_bench.cc
@@ -142,7 +142,7 @@ int main(int argc, char **argv)
ceph_options.push_back(i->c_str());
}
- global_init(
+ auto cct = global_init(
&def_args, ceph_options, CEPH_ENTITY_TYPE_CLIENT,
CODE_ENVIRONMENT_UTILITY,
CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
diff --git a/src/test/bench_log.cc b/src/test/bench_log.cc
index 39e8813ae75..9f5892f1e23 100644
--- a/src/test/bench_log.cc
+++ b/src/test/bench_log.cc
@@ -39,7 +39,8 @@ int main(int argc, const char **argv)
argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_OSD, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_OSD,
+ CODE_ENVIRONMENT_UTILITY, 0);
utime_t start = ceph_clock_now(NULL);
diff --git a/src/test/common/Throttle.cc b/src/test/common/Throttle.cc
index d75d450a8e0..eda25a91f36 100644
--- a/src/test/common/Throttle.cc
+++ b/src/test/common/Throttle.cc
@@ -25,8 +25,7 @@
#include "common/Thread.h"
#include "common/Throttle.h"
#include "common/ceph_argparse.h"
-#include "global/global_init.h"
-#include <gtest/gtest.h>
+#include "test/unit.h"
#include <thread>
#include <atomic>
@@ -424,17 +423,6 @@ TEST(BackoffThrottle, oversaturated)
ASSERT_GT(results.second.count(), 0.0005);
}
-int main(int argc, char **argv) {
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
/*
* Local Variables:
* compile-command: "cd ../.. ;
diff --git a/src/test/common/get_command_descriptions.cc b/src/test/common/get_command_descriptions.cc
index eb4c0f9db91..1b4da3f8959 100644
--- a/src/test/common/get_command_descriptions.cc
+++ b/src/test/common/get_command_descriptions.cc
@@ -87,7 +87,8 @@ int main(int argc, char **argv) {
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
if (args.empty()) {
diff --git a/src/test/common/test_async_compressor.cc b/src/test/common/test_async_compressor.cc
index 6d30a8e81a0..6e77306fdc0 100644
--- a/src/test/common/test_async_compressor.cc
+++ b/src/test/common/test_async_compressor.cc
@@ -207,7 +207,7 @@ int main(int argc, char **argv) {
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
const char* env = getenv("CEPH_LIB");
diff --git a/src/test/common/test_shared_cache.cc b/src/test/common/test_shared_cache.cc
index cd921f52707..1d12800c85f 100644
--- a/src/test/common/test_shared_cache.cc
+++ b/src/test/common/test_shared_cache.cc
@@ -25,8 +25,7 @@
#include "common/Thread.h"
#include "common/shared_cache.hpp"
#include "common/ceph_argparse.h"
-#include "global/global_init.h"
-#include <gtest/gtest.h>
+#include "test/unit.h"
class SharedLRUTest : public SharedLRU<unsigned int, int> {
public:
@@ -393,17 +392,6 @@ TEST(SharedCache_all, lru) {
ASSERT_TRUE(cache.lookup(0).get());
}
-int main(int argc, char **argv) {
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
// Local Variables:
// compile-command: "cd ../.. ; make unittest_shared_cache && ./unittest_shared_cache # --gtest_filter=*.* --log-to-stderr=true"
// End:
diff --git a/src/test/common/test_sharedptr_registry.cc b/src/test/common/test_sharedptr_registry.cc
index 98379c856aa..88486251a33 100644
--- a/src/test/common/test_sharedptr_registry.cc
+++ b/src/test/common/test_sharedptr_registry.cc
@@ -24,8 +24,7 @@
#include "common/Thread.h"
#include "common/sharedptr_registry.hpp"
#include "common/ceph_argparse.h"
-#include "global/global_init.h"
-#include <gtest/gtest.h>
+#include "test/unit.h"
class SharedPtrRegistryTest : public SharedPtrRegistry<unsigned int, int> {
public:
@@ -324,17 +323,6 @@ TEST_F(SharedPtrRegistry_destructor, destructor) {
EXPECT_FALSE(registry.lookup(key));
}
-int main(int argc, char **argv) {
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
// Local Variables:
// compile-command: "cd ../.. ; make unittest_sharedptr_registry && ./unittest_sharedptr_registry # --gtest_filter=*.* --log-to-stderr=true"
// End:
diff --git a/src/test/compressor/test_compression.cc b/src/test/compressor/test_compression.cc
index d7c24d5a827..6dbdfacd1cd 100644
--- a/src/test/compressor/test_compression.cc
+++ b/src/test/compressor/test_compression.cc
@@ -17,13 +17,12 @@
#include <errno.h>
#include <signal.h>
#include <stdlib.h>
-#include <gtest/gtest.h>
-#include "global/global_init.h"
#include "compressor/Compressor.h"
#include "common/ceph_argparse.h"
#include "global/global_context.h"
#include "common/config.h"
#include "compressor/CompressionPlugin.h"
+#include "test/unit.h"
class CompressorTest : public ::testing::Test,
public ::testing::WithParamInterface<const char*> {
@@ -453,20 +452,3 @@ TEST(ZlibCompressor, isal_compress_zlib_decompress_walk)
EXPECT_TRUE(exp.contents_equal(after));
}
}
-
-
-int main(int argc, char **argv) {
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
- env_to_vec(args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- const char* env = getenv("CEPH_LIB");
- if (env)
- g_conf->set_val("plugin_dir", env, false, false);
-
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/src/test/crush/CrushWrapper.cc b/src/test/crush/CrushWrapper.cc
index 035be924c3d..3d7e152b27e 100644
--- a/src/test/crush/CrushWrapper.cc
+++ b/src/test/crush/CrushWrapper.cc
@@ -948,7 +948,8 @@ int main(int argc, char **argv) {
vector<const char*> def_args;
def_args.push_back("--debug-crush=0");
- global_init(&def_args, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(&def_args, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
diff --git a/src/test/crush/crush.cc b/src/test/crush/crush.cc
index 6d659ae19b1..778323b4736 100644
--- a/src/test/crush/crush.cc
+++ b/src/test/crush/crush.cc
@@ -12,12 +12,10 @@
#include <gtest/gtest.h>
#include "include/stringify.h"
-#include "common/ceph_argparse.h"
-#include "global/global_init.h"
-#include "global/global_context.h"
#include "crush/CrushWrapper.h"
#include "osd/osd_types.h"
+#include "test/unit.h"
#include <set>
@@ -645,16 +643,3 @@ TEST(CRUSH, straw2_reweight) {
cout << " vs " << estddev << std::endl;
}
}
-
-
-
-int main(int argc, char **argv) {
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/src/test/crypto_init.cc b/src/test/crypto_init.cc
index d4b256217b4..781175ebd18 100644
--- a/src/test/crypto_init.cc
+++ b/src/test/crypto_init.cc
@@ -23,8 +23,9 @@ void *init_crypto(void *p) {
// multiple times simultaneously from different threads.
TEST(CRYPTO_INIT, NSS_RACE) {
std::vector<const char*> args;
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
- CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY,
+ CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
// Most reliably reproduced with more threads than cores.
long n_thread = sysconf(_SC_NPROCESSORS_ONLN) * 2;
pthread_t *ts = (pthread_t*)malloc(n_thread * sizeof(pthread_t));
diff --git a/src/test/erasure-code/TestErasureCode.cc b/src/test/erasure-code/TestErasureCode.cc
index 47b7fa2a87a..add9c671ce7 100644
--- a/src/test/erasure-code/TestErasureCode.cc
+++ b/src/test/erasure-code/TestErasureCode.cc
@@ -17,12 +17,11 @@
#include <errno.h>
#include <stdlib.h>
-#include "global/global_init.h"
#include "erasure-code/ErasureCode.h"
-#include "common/ceph_argparse.h"
#include "global/global_context.h"
#include "common/config.h"
#include "gtest/gtest.h"
+#include "test/unit.h"
class ErasureCodeTest : public ErasureCode {
public:
@@ -153,22 +152,6 @@ TEST(ErasureCodeTest, encode_misaligned_non_contiguous)
}
}
-int main(int argc, char **argv)
-{
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- const char* env = getenv("CEPH_LIB");
- string directory(env ? env : ".libs");
- g_conf->set_val("erasure_code_dir", directory, false, false);
-
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
/*
* Local Variables:
* compile-command: "cd ../.. ;
diff --git a/src/test/erasure-code/TestErasureCodeExample.cc b/src/test/erasure-code/TestErasureCodeExample.cc
index ed34e07ee98..cabf0765380 100644
--- a/src/test/erasure-code/TestErasureCodeExample.cc
+++ b/src/test/erasure-code/TestErasureCodeExample.cc
@@ -16,11 +16,11 @@
#include <stdlib.h>
#include "include/stringify.h"
-#include "global/global_init.h"
#include "ErasureCodeExample.h"
#include "common/ceph_argparse.h"
#include "global/global_context.h"
#include "gtest/gtest.h"
+#include "test/unit.h"
TEST(ErasureCodeExample, chunk_size)
{
@@ -234,21 +234,6 @@ TEST(ErasureCodeExample, create_ruleset)
EXPECT_EQ(0, example.create_ruleset("myrule", *c, &ss));
}
-int main(int argc, char **argv) {
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- const char* env = getenv("CEPH_LIB");
- string directory(env ? env : ".libs");
- g_conf->set_val("erasure_code_dir", directory, false, false);
-
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
/*
* Local Variables:
* compile-command: "cd ../.. ;
diff --git a/src/test/erasure-code/TestErasureCodeIsa.cc b/src/test/erasure-code/TestErasureCodeIsa.cc
index 382d789a360..03fb3e9077b 100644
--- a/src/test/erasure-code/TestErasureCodeIsa.cc
+++ b/src/test/erasure-code/TestErasureCodeIsa.cc
@@ -20,13 +20,13 @@
#include "crush/CrushWrapper.h"
#include "include/stringify.h"
-#include "global/global_init.h"
#include "erasure-code/isa/ErasureCodeIsa.h"
#include "erasure-code/isa/xor_op.h"
#include "common/ceph_argparse.h"
#include "global/global_context.h"
#include "common/config.h"
#include "gtest/gtest.h"
+#include "test/unit.h"
ErasureCodeIsaTableCache tcache;
@@ -957,22 +957,6 @@ TEST_F(IsaErasureCodeTest, create_ruleset)
}
}
-int main(int argc, char **argv)
-{
- vector<const char*> args;
- argv_to_vec(argc, (const char **) argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- const char* env = getenv("CEPH_LIB");
- string directory(env ? env : ".libs");
- g_conf->set_val("erasure_code_dir", directory, false, false);
-
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
/*
* Local Variables:
* compile-command: "cd ../.. ; make -j4 unittest_erasure_code_isa &&
diff --git a/src/test/erasure-code/TestErasureCodeJerasure.cc b/src/test/erasure-code/TestErasureCodeJerasure.cc
index 01c27d95439..180466e3524 100644
--- a/src/test/erasure-code/TestErasureCodeJerasure.cc
+++ b/src/test/erasure-code/TestErasureCodeJerasure.cc
@@ -20,12 +20,12 @@
#include "crush/CrushWrapper.h"
#include "include/stringify.h"
-#include "global/global_init.h"
#include "erasure-code/jerasure/ErasureCodeJerasure.h"
-#include "common/ceph_argparse.h"
#include "global/global_context.h"
#include "common/config.h"
#include "gtest/gtest.h"
+#include "test/unit.h"
+
template <typename T>
class ErasureCodeTest : public ::testing::Test {
@@ -359,22 +359,6 @@ TEST(ErasureCodeTest, create_ruleset)
}
}
-int main(int argc, char **argv)
-{
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- const char* env = getenv("CEPH_LIB");
- string directory(env ? env : ".libs");
- g_conf->set_val("erasure_code_dir", directory, false, false);
-
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
/*
* Local Variables:
* compile-command: "cd ../.. ;
diff --git a/src/test/erasure-code/TestErasureCodeLrc.cc b/src/test/erasure-code/TestErasureCodeLrc.cc
index 5d03467805c..2d4d74f3c1e 100644
--- a/src/test/erasure-code/TestErasureCodeLrc.cc
+++ b/src/test/erasure-code/TestErasureCodeLrc.cc
@@ -21,12 +21,12 @@
#include "crush/CrushWrapper.h"
#include "common/config.h"
#include "include/stringify.h"
-#include "global/global_init.h"
#include "erasure-code/lrc/ErasureCodeLrc.h"
-#include "common/ceph_argparse.h"
#include "global/global_context.h"
#include "common/config.h"
#include "gtest/gtest.h"
+#include "test/unit.h"
+
TEST(ErasureCodeLrc, parse_ruleset)
{
@@ -910,22 +910,6 @@ TEST(ErasureCodeLrc, encode_decode_2)
}
}
-int main(int argc, char **argv)
-{
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- const char* env = getenv("CEPH_LIB");
- string directory(env ? env : ".libs");
- g_conf->set_val("erasure_code_dir", directory, false, false);
-
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
/*
* Local Variables:
* compile-command: "cd ../.. ;
diff --git a/src/test/erasure-code/TestErasureCodePlugin.cc b/src/test/erasure-code/TestErasureCodePlugin.cc
index 42cf13d0fcd..947d9f11889 100644
--- a/src/test/erasure-code/TestErasureCodePlugin.cc
+++ b/src/test/erasure-code/TestErasureCodePlugin.cc
@@ -19,12 +19,12 @@
#include <signal.h>
#include <stdlib.h>
#include "common/Thread.h"
-#include "global/global_init.h"
#include "erasure-code/ErasureCodePlugin.h"
-#include "common/ceph_argparse.h"
#include "global/global_context.h"
#include "common/config.h"
#include "gtest/gtest.h"
+#include "test/unit.h"
+
class ErasureCodePluginRegistryTest : public ::testing::Test {
protected:
@@ -126,21 +126,6 @@ TEST_F(ErasureCodePluginRegistryTest, all)
}
}
-int main(int argc, char **argv) {
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- const char* env = getenv("CEPH_LIB");
- string directory(env ? env : ".libs");
- g_conf->set_val("erasure_code_dir", directory, false, false);
-
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
/*
* Local Variables:
* compile-command: "cd ../.. ; make -j4 &&
diff --git a/src/test/erasure-code/TestErasureCodePluginIsa.cc b/src/test/erasure-code/TestErasureCodePluginIsa.cc
index e7f3e0821a4..b469596abc9 100644
--- a/src/test/erasure-code/TestErasureCodePluginIsa.cc
+++ b/src/test/erasure-code/TestErasureCodePluginIsa.cc
@@ -22,6 +22,7 @@
#include "global/global_context.h"
#include "common/config.h"
#include "gtest/gtest.h"
+#include "test/unit.h"
TEST(ErasureCodePlugin, factory)
{
@@ -52,22 +53,6 @@ TEST(ErasureCodePlugin, factory)
}
}
-int main(int argc, char **argv)
-{
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- const char* env = getenv("CEPH_LIB");
- string directory(env ? env : ".libs");
- g_conf->set_val("erasure_code_dir", directory, false, false);
-
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
/*
* Local Variables:
* compile-command: "cd ../.. ; make -j4 &&
diff --git a/src/test/erasure-code/TestErasureCodePluginJerasure.cc b/src/test/erasure-code/TestErasureCodePluginJerasure.cc
index ff90c8e35ae..148f348d679 100644
--- a/src/test/erasure-code/TestErasureCodePluginJerasure.cc
+++ b/src/test/erasure-code/TestErasureCodePluginJerasure.cc
@@ -17,13 +17,12 @@
#include <errno.h>
#include <stdlib.h>
-#include "global/global_init.h"
#include "erasure-code/ErasureCodePlugin.h"
-#include "common/ceph_argparse.h"
#include "log/Log.h"
#include "global/global_context.h"
#include "common/config.h"
#include "gtest/gtest.h"
+#include "test/unit.h"
TEST(ErasureCodePlugin, factory)
{
@@ -61,24 +60,6 @@ TEST(ErasureCodePlugin, factory)
}
}
-int main(int argc, char **argv)
-{
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- const char* env = getenv("CEPH_LIB");
- string directory(env ? env : ".libs");
- g_conf->set_val("erasure_code_dir", directory, false, false);
-
- ::testing::InitGoogleTest(&argc, argv);
- int status = RUN_ALL_TESTS();
- g_ceph_context->_log->stop();
- return status;
-}
-
/*
* Local Variables:
* compile-command: "cd ../.. ; make -j4 &&
diff --git a/src/test/erasure-code/TestErasureCodePluginLrc.cc b/src/test/erasure-code/TestErasureCodePluginLrc.cc
index a90e4cb8f55..5c2e618372b 100644
--- a/src/test/erasure-code/TestErasureCodePluginLrc.cc
+++ b/src/test/erasure-code/TestErasureCodePluginLrc.cc
@@ -19,12 +19,12 @@
#include <stdlib.h>
#include "arch/probe.h"
#include "arch/intel.h"
-#include "global/global_init.h"
#include "erasure-code/ErasureCodePlugin.h"
-#include "common/ceph_argparse.h"
#include "global/global_context.h"
#include "common/config.h"
#include "gtest/gtest.h"
+#include "test/unit.h"
+
TEST(ErasureCodePlugin, factory)
{
@@ -40,22 +40,6 @@ TEST(ErasureCodePlugin, factory)
EXPECT_TRUE(erasure_code.get());
}
-int main(int argc, char **argv)
-{
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- const char* env = getenv("CEPH_LIB");
- string directory(env ? env : ".libs");
- g_conf->set_val("erasure_code_dir", directory, false, false);
-
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
/*
* Local Variables:
* compile-command: "cd ../.. ; make -j4 &&
diff --git a/src/test/erasure-code/TestErasureCodePluginShec.cc b/src/test/erasure-code/TestErasureCodePluginShec.cc
index a6d95205e4d..fc4b1ac128b 100644
--- a/src/test/erasure-code/TestErasureCodePluginShec.cc
+++ b/src/test/erasure-code/TestErasureCodePluginShec.cc
@@ -18,12 +18,10 @@
#include <errno.h>
#include <stdlib.h>
-#include "global/global_init.h"
#include "erasure-code/ErasureCodePlugin.h"
-#include "common/ceph_argparse.h"
#include "global/global_context.h"
#include "common/config.h"
-#include "gtest/gtest.h"
+#include "test/unit.h"
TEST(ErasureCodePlugin, factory)
{
@@ -55,22 +53,6 @@ TEST(ErasureCodePlugin, factory)
}
}
-int main(int argc, char **argv)
-{
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- const char* env = getenv("CEPH_LIB");
- string directory(env ? env : ".libs");
- g_conf->set_val("erasure_code_dir", directory, false, false);
-
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
/*
* Local Variables:
* compile-command: "cd ../.. ; make -j4 &&
diff --git a/src/test/erasure-code/TestErasureCodeShec.cc b/src/test/erasure-code/TestErasureCodeShec.cc
index a2ab31e8fd1..b48fe2a82a5 100644
--- a/src/test/erasure-code/TestErasureCodeShec.cc
+++ b/src/test/erasure-code/TestErasureCodeShec.cc
@@ -31,6 +31,7 @@
#include "common/ceph_argparse.h"
#include "global/global_context.h"
#include "gtest/gtest.h"
+#include "test/unit.h"
void* thread1(void* pParam);
void* thread2(void* pParam);
@@ -2667,22 +2668,6 @@ TEST(ErasureCodeShec, get_chunk_size_1_2)
delete profile;
}
-int main(int argc, char **argv)
-{
- vector<const char*> args;
- argv_to_vec(argc, (const char **) argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- const char* env = getenv("CEPH_LIB");
- string directory(env ? env : ".libs");
- g_conf->set_val("erasure_code_dir", directory, false, false);
-
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
void* thread1(void* pParam)
{
ErasureCodeShec* shec = (ErasureCodeShec*) pParam;
diff --git a/src/test/erasure-code/TestErasureCodeShec_all.cc b/src/test/erasure-code/TestErasureCodeShec_all.cc
index 14d904ddeb3..23bf82e1c9f 100644
--- a/src/test/erasure-code/TestErasureCodeShec_all.cc
+++ b/src/test/erasure-code/TestErasureCodeShec_all.cc
@@ -294,7 +294,8 @@ int main(int argc, char **argv)
vector<const char*> args;
argv_to_vec(argc, (const char **) argv, args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
const char* env = getenv("CEPH_LIB");
diff --git a/src/test/erasure-code/TestErasureCodeShec_arguments.cc b/src/test/erasure-code/TestErasureCodeShec_arguments.cc
index 597c479fa7e..2959d7c3a4a 100644
--- a/src/test/erasure-code/TestErasureCodeShec_arguments.cc
+++ b/src/test/erasure-code/TestErasureCodeShec_arguments.cc
@@ -393,7 +393,8 @@ int main(int argc, char **argv)
vector<const char*> args;
argv_to_vec(argc, (const char **) argv, args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
const char* env = getenv("CEPH_LIB");
diff --git a/src/test/erasure-code/TestErasureCodeShec_thread.cc b/src/test/erasure-code/TestErasureCodeShec_thread.cc
index 0dc1b82c2b3..6060fb7c24a 100644
--- a/src/test/erasure-code/TestErasureCodeShec_thread.cc
+++ b/src/test/erasure-code/TestErasureCodeShec_thread.cc
@@ -25,12 +25,11 @@
#include "crush/CrushWrapper.h"
#include "osd/osd_types.h"
#include "include/stringify.h"
-#include "global/global_init.h"
#include "erasure-code/shec/ErasureCodeShec.h"
#include "erasure-code/ErasureCodePlugin.h"
-#include "common/ceph_argparse.h"
#include "global/global_context.h"
#include "gtest/gtest.h"
+#include "test/unit.h"
void* thread1(void* pParam);
@@ -86,22 +85,6 @@ TEST(ErasureCodeShec, thread)
pthread_join(tid5, NULL);
}
-int main(int argc, char **argv)
-{
- vector<const char*> args;
- argv_to_vec(argc, (const char **) argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- const char* env = getenv("CEPH_LIB");
- std::string directory(env ? env : ".libs");
- g_conf->set_val("erasure_code_dir", directory, false, false);
-
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
void* thread1(void* pParam)
{
TestParam* param = static_cast<TestParam*>(pParam);
diff --git a/src/test/erasure-code/ceph_erasure_code.cc b/src/test/erasure-code/ceph_erasure_code.cc
index e3c3030bf4e..f39900b88f0 100644
--- a/src/test/erasure-code/ceph_erasure_code.cc
+++ b/src/test/erasure-code/ceph_erasure_code.cc
@@ -82,7 +82,7 @@ int ErasureCodeCommand::setup(int argc, char** argv) {
ceph_options.push_back(i->c_str());
}
- global_init(
+ auto cct = global_init(
&def_args, ceph_options, CEPH_ENTITY_TYPE_CLIENT,
CODE_ENVIRONMENT_UTILITY,
CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
diff --git a/src/test/erasure-code/ceph_erasure_code_benchmark.cc b/src/test/erasure-code/ceph_erasure_code_benchmark.cc
index 31a73d45a9f..01250cc774b 100644
--- a/src/test/erasure-code/ceph_erasure_code_benchmark.cc
+++ b/src/test/erasure-code/ceph_erasure_code_benchmark.cc
@@ -81,7 +81,7 @@ int ErasureCodeBench::setup(int argc, char** argv) {
ceph_options.push_back(i->c_str());
}
- global_init(
+ auto cct = global_init(
&def_args, ceph_options, CEPH_ENTITY_TYPE_CLIENT,
CODE_ENVIRONMENT_UTILITY,
CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
diff --git a/src/test/erasure-code/ceph_erasure_code_non_regression.cc b/src/test/erasure-code/ceph_erasure_code_non_regression.cc
index 5414cfba4de..dd38626d677 100644
--- a/src/test/erasure-code/ceph_erasure_code_non_regression.cc
+++ b/src/test/erasure-code/ceph_erasure_code_non_regression.cc
@@ -43,6 +43,7 @@ class ErasureCodeNonRegression {
string base;
string directory;
ErasureCodeProfile profile;
+ boost::intrusive_ptr<CephContext> cct;
public:
int setup(int argc, char** argv);
int run();
@@ -90,10 +91,9 @@ int ErasureCodeNonRegression::setup(int argc, char** argv) {
ceph_options.push_back(i->c_str());
}
- global_init(
- &def_args, ceph_options, CEPH_ENTITY_TYPE_CLIENT,
- CODE_ENVIRONMENT_UTILITY,
- CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
+ cct = global_init(&def_args, ceph_options, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY,
+ CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
common_init_finish(g_ceph_context);
g_ceph_context->_conf->apply_changes(NULL);
const char* env = getenv("CEPH_LIB");
diff --git a/src/test/filestore/TestFileStore.cc b/src/test/filestore/TestFileStore.cc
index a100a5f3a69..6d857be4116 100644
--- a/src/test/filestore/TestFileStore.cc
+++ b/src/test/filestore/TestFileStore.cc
@@ -68,7 +68,8 @@ int main(int argc, char **argv) {
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
g_ceph_context->_conf->set_val("osd_journal_size", "100");
g_ceph_context->_conf->apply_changes(NULL);
diff --git a/src/test/fio/fio_ceph_objectstore.cc b/src/test/fio/fio_ceph_objectstore.cc
index 2929374a04c..719db93275f 100644
--- a/src/test/fio/fio_ceph_objectstore.cc
+++ b/src/test/fio/fio_ceph_objectstore.cc
@@ -23,11 +23,6 @@
#include "include/assert.h" // fio.h clobbers our assert.h
-
-// enable boost::intrusive_ptr<CephContext>
-void intrusive_ptr_add_ref(CephContext* cct) { cct->get(); }
-void intrusive_ptr_release(CephContext* cct) { cct->put(); }
-
namespace {
/// fio configuration options read from the job file
@@ -107,11 +102,10 @@ Engine::Engine(const thread_data* td) : ref_count(0)
args.emplace_back(td->o.directory);
}
- global_init(nullptr, args, CEPH_ENTITY_TYPE_OSD, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
// claim the g_ceph_context reference and release it on destruction
- cct = boost::intrusive_ptr<CephContext>(g_ceph_context, false);
+ auto cct = global_init(nullptr, args, CEPH_ENTITY_TYPE_OSD,
+ CODE_ENVIRONMENT_UTILITY, 0);
+ common_init_finish(g_ceph_context);
// create the ObjectStore
os.reset(ObjectStore::create(g_ceph_context,
diff --git a/src/test/journal/test_main.cc b/src/test/journal/test_main.cc
index f8c7d3eea1b..66163e5f921 100644
--- a/src/test/journal/test_main.cc
+++ b/src/test/journal/test_main.cc
@@ -16,11 +16,11 @@ int main(int argc, char **argv)
std::vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
g_conf->set_val("lockdep", "true");
common_init_finish(g_ceph_context);
int r = RUN_ALL_TESTS();
- g_ceph_context->put();
return r;
}
diff --git a/src/test/librados/list.cc b/src/test/librados/list.cc
index 60b97b52ea4..b1d09a36a6e 100644
--- a/src/test/librados/list.cc
+++ b/src/test/librados/list.cc
@@ -6,9 +6,7 @@
#include "test/librados/test.h"
#include "test/librados/TestCase.h"
#include "global/global_context.h"
-#include "global/global_init.h"
-#include "common/ceph_argparse.h"
-#include "common/common_init.h"
+#include "test/unit.h"
#include "include/types.h"
#include "common/hobject.h"
@@ -960,18 +958,3 @@ TEST_F(LibRadosListPP, EnumerateObjectsFilterPP) {
#pragma GCC diagnostic pop
#pragma GCC diagnostic warning "-Wpragmas"
-
-int main(int argc, char **argv)
-{
- ::testing::InitGoogleTest(&argc, argv);
-
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
- env_to_vec(args);
- cout << args << std::endl;
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- return RUN_ALL_TESTS();
-}
diff --git a/src/test/librados/misc.cc b/src/test/librados/misc.cc
index 85408757003..d3ae2719a7b 100644
--- a/src/test/librados/misc.cc
+++ b/src/test/librados/misc.cc
@@ -9,8 +9,6 @@
#include "include/rados/librados.hpp"
#include "include/stringify.h"
#include "global/global_context.h"
-#include "global/global_init.h"
-#include "common/ceph_argparse.h"
#include "common/common_init.h"
#include "test/librados/test.h"
#include "test/librados/TestCase.h"
@@ -19,6 +17,8 @@
#include <map>
#include <sstream>
#include <string>
+#include "test/unit.h"
+
using namespace librados;
using std::map;
@@ -1015,16 +1015,3 @@ TEST_F(LibRadosMisc, WriteSame) {
/* write_len = data_len, i.e. same as rados_write() */
ASSERT_EQ(0, rados_writesame(ioctx, "ws", buf, sizeof(buf), sizeof(buf), 0));
}
-
-int main(int argc, char **argv)
-{
- ::testing::InitGoogleTest(&argc, argv);
-
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- return RUN_ALL_TESTS();
-}
diff --git a/src/test/librados/tier.cc b/src/test/librados/tier.cc
index fb8e2b70987..82067f38445 100755
--- a/src/test/librados/tier.cc
+++ b/src/test/librados/tier.cc
@@ -10,13 +10,11 @@
#include "include/stringify.h"
#include "include/types.h"
#include "global/global_context.h"
-#include "global/global_init.h"
-#include "common/ceph_argparse.h"
-#include "common/common_init.h"
#include "common/Cond.h"
#include "test/librados/test.h"
#include "test/librados/TestCase.h"
#include "json_spirit/json_spirit.h"
+#include "test/unit.h"
#include "osd/HitSet.h"
@@ -5351,17 +5349,3 @@ TEST_F(LibRadosTwoPoolsECPP, CachePin) {
// wait for maps to settle before next test
cluster.wait_for_latest_osdmap();
}
-
-int main(int argc, char **argv)
-{
- ::testing::InitGoogleTest(&argc, argv);
-
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
- env_to_vec(args),
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- return RUN_ALL_TESTS();
-}
diff --git a/src/test/mds/TestMDSAuthCaps.cc b/src/test/mds/TestMDSAuthCaps.cc
index eb2cb43bd7c..09317fd9436 100644
--- a/src/test/mds/TestMDSAuthCaps.cc
+++ b/src/test/mds/TestMDSAuthCaps.cc
@@ -16,9 +16,7 @@
#include "include/stringify.h"
#include "mds/MDSAuthCaps.h"
-#include "common/ceph_argparse.h"
-#include "common/common_init.h"
-#include "global/global_init.h"
+#include "test/unit.h"
#include "gtest/gtest.h"
@@ -257,17 +255,3 @@ TEST(MDSAuthCaps, OutputParsed) {
ASSERT_EQ(test_values[i].output, stringify(cap));
}
}
-
-int main(int argc, char **argv)
-{
- ::testing::InitGoogleTest(&argc, argv);
-
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
- env_to_vec(args, NULL);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- return RUN_ALL_TESTS();
-}
diff --git a/src/test/mds/TestSessionFilter.cc b/src/test/mds/TestSessionFilter.cc
index 2d058da41a0..5682281259e 100644
--- a/src/test/mds/TestSessionFilter.cc
+++ b/src/test/mds/TestSessionFilter.cc
@@ -16,9 +16,7 @@
#include "include/stringify.h"
#include "mds/SessionMap.h"
-#include "common/ceph_argparse.h"
-#include "common/common_init.h"
-#include "global/global_init.h"
+#include "test/unit.h"
#include "gtest/gtest.h"
@@ -149,14 +147,3 @@ TEST(MDSSessionFilter, ReconnectingEquality)
ASSERT_FALSE(filter.match(*a, [](client_t c) -> bool {return false;}));
a->put();
}
-
-int main(int argc, char **argv) {
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/src/test/messenger/simple_client.cc b/src/test/messenger/simple_client.cc
index b1a33bc6411..6fb01e9a9eb 100644
--- a/src/test/messenger/simple_client.cc
+++ b/src/test/messenger/simple_client.cc
@@ -69,8 +69,9 @@ int main(int argc, const char **argv)
argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_ANY, CODE_ENVIRONMENT_UTILITY,
- 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_ANY,
+ CODE_ENVIRONMENT_UTILITY,
+ 0);
for (arg_iter = args.begin(); arg_iter != args.end();) {
if (ceph_argparse_witharg(args, arg_iter, &val, "--addr",
diff --git a/src/test/messenger/simple_server.cc b/src/test/messenger/simple_server.cc
index 57115ea7fd9..df94701e535 100644
--- a/src/test/messenger/simple_server.cc
+++ b/src/test/messenger/simple_server.cc
@@ -52,8 +52,9 @@ int main(int argc, const char **argv)
argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_ANY, CODE_ENVIRONMENT_DAEMON,
- 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_ANY,
+ CODE_ENVIRONMENT_DAEMON,
+ 0);
for (arg_iter = args.begin(); arg_iter != args.end();) {
if (ceph_argparse_witharg(args, arg_iter, &val, "--addr",
diff --git a/src/test/messenger/xio_client.cc b/src/test/messenger/xio_client.cc
index f1082466b47..da132060dc8 100644
--- a/src/test/messenger/xio_client.cc
+++ b/src/test/messenger/xio_client.cc
@@ -75,8 +75,9 @@ int main(int argc, const char **argv)
argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(NULL, args,
- CEPH_ENTITY_TYPE_ANY, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args,
+ CEPH_ENTITY_TYPE_ANY,
+ CODE_ENVIRONMENT_UTILITY, 0);
for (arg_iter = args.begin(); arg_iter != args.end();) {
if (ceph_argparse_witharg(args, arg_iter, &val, "--addr",
diff --git a/src/test/mon/PGMap.cc b/src/test/mon/PGMap.cc
index 5cc3c89ee75..0ec16202b43 100644
--- a/src/test/mon/PGMap.cc
+++ b/src/test/mon/PGMap.cc
@@ -14,10 +14,8 @@
#include "mon/PGMap.h"
#include "gtest/gtest.h"
-#include "common/ceph_argparse.h"
-#include "global/global_init.h"
-#include "global/global_context.h"
#include "include/stringify.h"
+#include "test/unit.h"
TEST(pgmap, min_last_epoch_clean)
{
@@ -245,15 +243,3 @@ TEST(pgmap, dump_object_stat_sum_2)
ASSERT_EQ(stringify(si_t(avail)), tbl.get(0, col++));
ASSERT_EQ(stringify(0), tbl.get(0, col++));
}
-
-int main(int argc, char **argv) {
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
- env_to_vec(args);
-
- vector<const char*> def_args;
- global_init(&def_args, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/src/test/mon/test-mon-msg.cc b/src/test/mon/test-mon-msg.cc
index ee50c02626f..33ec9d0d1f6 100644
--- a/src/test/mon/test-mon-msg.cc
+++ b/src/test/mon/test-mon-msg.cc
@@ -322,13 +322,12 @@ TEST_F(MonMsgTest, MMonJoin)
int main(int argc, char *argv[])
{
- vector<const char*> def_args;
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
- global_init(&def_args, args,
- CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
- 0);
+ auto cct = global_init(nullptr, args,
+ CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
+ 0);
common_init_finish(g_ceph_context);
g_ceph_context->_conf->apply_changes(NULL);
::testing::InitGoogleTest(&argc, argv);
diff --git a/src/test/mon/test_mon_workloadgen.cc b/src/test/mon/test_mon_workloadgen.cc
index 73fbac06482..c1b26efa557 100644
--- a/src/test/mon/test_mon_workloadgen.cc
+++ b/src/test/mon/test_mon_workloadgen.cc
@@ -1003,9 +1003,9 @@ int main(int argc, const char *argv[])
our_name = argv[0];
argv_to_vec(argc, argv, args);
- global_init(&def_args, args,
- CEPH_ENTITY_TYPE_OSD, CODE_ENVIRONMENT_UTILITY,
- 0);
+ auto cct = global_init(&def_args, args,
+ CEPH_ENTITY_TYPE_OSD, CODE_ENVIRONMENT_UTILITY,
+ 0);
common_init_finish(g_ceph_context);
g_ceph_context->_conf->apply_changes(NULL);
diff --git a/src/test/msgr/perf_msgr_client.cc b/src/test/msgr/perf_msgr_client.cc
index b567743df84..9ab0af267ac 100644
--- a/src/test/msgr/perf_msgr_client.cc
+++ b/src/test/msgr/perf_msgr_client.cc
@@ -173,7 +173,8 @@ int main(int argc, char **argv)
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
g_ceph_context->_conf->apply_changes(NULL);
diff --git a/src/test/msgr/perf_msgr_server.cc b/src/test/msgr/perf_msgr_server.cc
index 381cd52812b..4db724741f5 100644
--- a/src/test/msgr/perf_msgr_server.cc
+++ b/src/test/msgr/perf_msgr_server.cc
@@ -145,7 +145,8 @@ int main(int argc, char **argv)
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
g_ceph_context->_conf->apply_changes(NULL);
diff --git a/src/test/msgr/test_async_driver.cc b/src/test/msgr/test_async_driver.cc
index 8f4e5c4e263..22662af8fc4 100644
--- a/src/test/msgr/test_async_driver.cc
+++ b/src/test/msgr/test_async_driver.cc
@@ -54,9 +54,11 @@
#include "msg/async/EventKqueue.h"
#endif
#include "msg/async/EventSelect.h"
+#include "test/unit.h"
#include <gtest/gtest.h>
+
#if GTEST_HAS_PARAM_TEST
class EventDriverTest : public ::testing::TestWithParam<const char*> {
@@ -354,17 +356,6 @@ TEST(DummyTest, ValueParameterizedTestsAreNotSupportedOnThisPlatform) {}
#endif
-int main(int argc, char **argv) {
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
/*
* Local Variables:
* compile-command: "cd ../.. ; make ceph_test_async_driver &&
diff --git a/src/test/msgr/test_async_networkstack.cc b/src/test/msgr/test_async_networkstack.cc
index f9bc5a2c7a4..4756fef7b77 100644
--- a/src/test/msgr/test_async_networkstack.cc
+++ b/src/test/msgr/test_async_networkstack.cc
@@ -25,11 +25,11 @@
#include "acconfig.h"
#include "include/Context.h"
-#include "common/ceph_argparse.h"
-#include "global/global_init.h"
#include "msg/async/Event.h"
#include "msg/async/Stack.h"
+#include "test/unit.h"
+
#if GTEST_HAS_PARAM_TEST
@@ -1059,17 +1059,6 @@ TEST(DummyTest, ValueParameterizedTestsAreNotSupportedOnThisPlatform) {}
#endif
-int main(int argc, char **argv) {
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
/*
* Local Variables:
* compile-command: "cd ../.. ; make ceph_test_async_networkstack &&
diff --git a/src/test/msgr/test_msgr.cc b/src/test/msgr/test_msgr.cc
index 6ea65ebb118..5bef050e94e 100644
--- a/src/test/msgr/test_msgr.cc
+++ b/src/test/msgr/test_msgr.cc
@@ -1521,7 +1521,7 @@ int main(int argc, char **argv) {
argv_to_vec(argc, (const char **)argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
g_ceph_context->_conf->set_val("auth_cluster_required", "none");
g_ceph_context->_conf->set_val("auth_service_required", "none");
g_ceph_context->_conf->set_val("auth_client_required", "none");
diff --git a/src/test/msgr/test_userspace_event.cc b/src/test/msgr/test_userspace_event.cc
index c523807a0aa..4b040597624 100644
--- a/src/test/msgr/test_userspace_event.cc
+++ b/src/test/msgr/test_userspace_event.cc
@@ -18,11 +18,9 @@
#include <random>
#include <gtest/gtest.h>
-#include "common/ceph_argparse.h"
-#include "common/common_init.h"
#include "msg/async/dpdk/UserspaceEvent.h"
#include "global/global_context.h"
-#include "global/global_init.h"
+#include "test/unit.h"
class UserspaceManagerTest : public ::testing::Test {
public:
@@ -168,18 +166,6 @@ TEST_F(UserspaceManagerTest, StressTest) {
}
}
-int main(int argc, char **argv)
-{
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
/*
* Local Variables:
* compile-command: "cd ../.. ; make ceph_test_userspace_event &&
diff --git a/src/test/objectstore/Allocator_test.cc b/src/test/objectstore/Allocator_test.cc
index 6b854f3f3a3..53d1d9d7f24 100644
--- a/src/test/objectstore/Allocator_test.cc
+++ b/src/test/objectstore/Allocator_test.cc
@@ -4,18 +4,18 @@
* In memory space allocator test cases.
* Author: Ramesh Chander, Ramesh.Chander@sandisk.com
*/
-#include "os/bluestore/Allocator.h"
-#include "global/global_init.h"
#include <iostream>
-#include "include/Context.h"
-#include "common/ceph_argparse.h"
-#include "global/global_init.h"
+#include <gtest/gtest.h>
+
#include "common/Mutex.h"
#include "common/Cond.h"
#include "common/errno.h"
#include "include/stringify.h"
-#include <gtest/gtest.h>
-#include <os/bluestore/BitAllocator.h>
+#include "include/Context.h"
+#include "os/bluestore/Allocator.h"
+#include "os/bluestore/BitAllocator.h"
+#include "test/unit.h"
+
#if GTEST_HAS_PARAM_TEST
@@ -239,15 +239,3 @@ INSTANTIATE_TEST_CASE_P(
TEST(DummyTest, ValueParameterizedTestsAreNotSupportedOnThisPlatform) {}
#endif
-
-int main(int argc, char **argv)
-{
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
- env_to_vec(args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
-
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/src/test/objectstore/BitAllocator_test.cc b/src/test/objectstore/BitAllocator_test.cc
index a9944ccced9..ff946afffab 100644
--- a/src/test/objectstore/BitAllocator_test.cc
+++ b/src/test/objectstore/BitAllocator_test.cc
@@ -7,14 +7,15 @@
#include "include/Context.h"
#include "common/ceph_argparse.h"
-#include "global/global_init.h"
#include "os/bluestore/BitAllocator.h"
+#include "test/unit.h"
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <sstream>
#include <gtest/gtest.h>
+
#define bmap_test_assert(x) ASSERT_EQ(true, (x))
#define NUM_THREADS 16
#define MAX_BLOCKS (1024 * 1024 * 1)
@@ -730,18 +731,3 @@ TEST(BitAllocator, test_bmap_alloc_concurrent)
}
}
-
-int main(int argc, char **argv)
-{
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
- env_to_vec(args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- ::testing::InitGoogleTest(&argc, argv);
- int r = RUN_ALL_TESTS();
- g_ceph_context->put();
- return r;
-}
diff --git a/src/test/objectstore/ObjectStoreTransactionBenchmark.cc b/src/test/objectstore/ObjectStoreTransactionBenchmark.cc
index 46fd25dcebb..279b10b9969 100644
--- a/src/test/objectstore/ObjectStoreTransactionBenchmark.cc
+++ b/src/test/objectstore/ObjectStoreTransactionBenchmark.cc
@@ -246,7 +246,8 @@ int main(int argc, char **argv)
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
g_ceph_context->_conf->apply_changes(NULL);
Cycles::init();
diff --git a/src/test/objectstore/TestRocksdbOptionParse.cc b/src/test/objectstore/TestRocksdbOptionParse.cc
index b42d60dd154..d58f42c3925 100644
--- a/src/test/objectstore/TestRocksdbOptionParse.cc
+++ b/src/test/objectstore/TestRocksdbOptionParse.cc
@@ -1,12 +1,12 @@
#include <gtest/gtest.h>
#include "include/Context.h"
-#include "common/ceph_argparse.h"
-#include "global/global_init.h"
#include "rocksdb/db.h"
#include "rocksdb/env.h"
#include "rocksdb/thread_status.h"
#include "kv/RocksDBStore.h"
+#include "test/unit.h"
#include <iostream>
+
using namespace std;
const string dir("rocksdb.test_temp_dir");
@@ -73,13 +73,3 @@ TEST(RocksDBOption, interpret) {
//high pri threads is flusher_threads
ASSERT_EQ(5, num_high_pri_threads);
}
-
-int main(int argc, char **argv) {
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
- env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/src/test/objectstore/chain_xattr.cc b/src/test/objectstore/chain_xattr.cc
index a05e8755dd1..34654295d77 100644
--- a/src/test/objectstore/chain_xattr.cc
+++ b/src/test/objectstore/chain_xattr.cc
@@ -432,7 +432,8 @@ int main(int argc, char **argv) {
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
g_ceph_context->_conf->set_val("err_to_stderr", "false");
g_ceph_context->_conf->set_val("log_to_stderr", "false");
diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc
index 877f5a31371..b96eb021311 100644
--- a/src/test/objectstore/store_test.cc
+++ b/src/test/objectstore/store_test.cc
@@ -5563,7 +5563,8 @@ int main(int argc, char **argv) {
argv_to_vec(argc, (const char **)argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
g_ceph_context->_conf->set_val("osd_journal_size", "400");
@@ -5599,9 +5600,7 @@ int main(int argc, char **argv) {
g_ceph_context->_conf->apply_changes(NULL);
::testing::InitGoogleTest(&argc, argv);
- int r = RUN_ALL_TESTS();
- g_ceph_context->put();
- return r;
+ return RUN_ALL_TESTS();
}
/*
diff --git a/src/test/objectstore/test_bluefs.cc b/src/test/objectstore/test_bluefs.cc
index d189eeac712..01763fec35c 100644
--- a/src/test/objectstore/test_bluefs.cc
+++ b/src/test/objectstore/test_bluefs.cc
@@ -577,8 +577,9 @@ int main(int argc, char **argv) {
def_args.push_back("--debug-bluefs=1/20");
def_args.push_back("--debug-bdev=1/20");
- global_init(&def_args, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
- 0);
+ auto cct = global_init(&def_args, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY,
+ 0);
common_init_finish(g_ceph_context);
g_ceph_context->_conf->set_val(
"enable_experimental_unrecoverable_data_corrupting_features",
diff --git a/src/test/objectstore/test_bluestore_types.cc b/src/test/objectstore/test_bluestore_types.cc
index ea6613c5e84..d68beba7c79 100644
--- a/src/test/objectstore/test_bluestore_types.cc
+++ b/src/test/objectstore/test_bluestore_types.cc
@@ -1011,10 +1011,9 @@ int main(int argc, char **argv) {
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
::testing::InitGoogleTest(&argc, argv);
- int r = RUN_ALL_TESTS();
- g_ceph_context->put();
- return r;
+ return RUN_ALL_TESTS();
}
diff --git a/src/test/objectstore/test_idempotent.cc b/src/test/objectstore/test_idempotent.cc
index edb8e9b3bfc..6b465b12f27 100644
--- a/src/test/objectstore/test_idempotent.cc
+++ b/src/test/objectstore/test_idempotent.cc
@@ -45,7 +45,8 @@ int main(int argc, char **argv) {
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
g_ceph_context->_conf->apply_changes(NULL);
diff --git a/src/test/objectstore/test_idempotent_sequence.cc b/src/test/objectstore/test_idempotent_sequence.cc
index 75ebc3377d3..0216b78f334 100644
--- a/src/test/objectstore/test_idempotent_sequence.cc
+++ b/src/test/objectstore/test_idempotent_sequence.cc
@@ -203,9 +203,9 @@ int main(int argc, const char *argv[])
our_name = argv[0];
argv_to_vec(argc, argv, args);
- global_init(&def_args, args,
- CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
- CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
+ auto cct = global_init(&def_args, args,
+ CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
+ CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
common_init_finish(g_ceph_context);
g_ceph_context->_conf->apply_changes(NULL);
diff --git a/src/test/objectstore/test_kv.cc b/src/test/objectstore/test_kv.cc
index 8aed8ade72a..d55841c9434 100644
--- a/src/test/objectstore/test_kv.cc
+++ b/src/test/objectstore/test_kv.cc
@@ -278,7 +278,8 @@ int main(int argc, char **argv) {
argv_to_vec(argc, (const char **)argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
g_ceph_context->_conf->set_val(
"enable_experimental_unrecoverable_data_corrupting_features",
diff --git a/src/test/objectstore/test_memstore_clone.cc b/src/test/objectstore/test_memstore_clone.cc
index 090c6f4bc1f..6607530f032 100644
--- a/src/test/objectstore/test_memstore_clone.cc
+++ b/src/test/objectstore/test_memstore_clone.cc
@@ -173,10 +173,6 @@ TEST_F(MemStoreClone, CloneRangeHoleEnd)
ASSERT_EQ(expected, result);
}
-// enable boost::intrusive_ptr<CephContext>
-void intrusive_ptr_add_ref(CephContext *cct) { cct->get(); }
-void intrusive_ptr_release(CephContext *cct) { cct->put(); }
-
int main(int argc, char** argv)
{
// default to memstore
@@ -189,13 +185,10 @@ int main(int argc, char** argv)
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
- global_init(&defaults, args, CEPH_ENTITY_TYPE_CLIENT,
- CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(&defaults, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
- // release g_ceph_context on exit
- boost::intrusive_ptr<CephContext> cct{g_ceph_context, false};
-
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
diff --git a/src/test/objectstore/workload_generator.cc b/src/test/objectstore/workload_generator.cc
index bbe3c74675e..2c55fb27bc0 100644
--- a/src/test/objectstore/workload_generator.cc
+++ b/src/test/objectstore/workload_generator.cc
@@ -568,9 +568,9 @@ int main(int argc, const char *argv[])
// def_args.push_back("workload_gen_dir/journal");
argv_to_vec(argc, argv, args);
- global_init(&def_args, args,
- CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
- CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
+ auto cct = global_init(&def_args, args,
+ CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
+ CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
common_init_finish(g_ceph_context);
g_ceph_context->_conf->apply_changes(NULL);
diff --git a/src/test/objectstore_bench.cc b/src/test/objectstore_bench.cc
index 5ec8503fe30..72c43a48ca3 100644
--- a/src/test/objectstore_bench.cc
+++ b/src/test/objectstore_bench.cc
@@ -155,7 +155,8 @@ int main(int argc, const char *argv[])
argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(nullptr, args, CEPH_ENTITY_TYPE_OSD, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(nullptr, args, CEPH_ENTITY_TYPE_OSD,
+ CODE_ENVIRONMENT_UTILITY, 0);
std::string val;
vector<const char*>::iterator i = args.begin();
diff --git a/src/test/os/TestLFNIndex.cc b/src/test/os/TestLFNIndex.cc
index 1ff2e4d8bd2..c377fe482a6 100644
--- a/src/test/os/TestLFNIndex.cc
+++ b/src/test/os/TestLFNIndex.cc
@@ -450,7 +450,8 @@ int main(int argc, char **argv) {
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
::testing::InitGoogleTest(&argc, argv);
diff --git a/src/test/osd/TestOSDMap.cc b/src/test/osd/TestOSDMap.cc
index 3410fe7ccbd..6c660e8f9f3 100644
--- a/src/test/osd/TestOSDMap.cc
+++ b/src/test/osd/TestOSDMap.cc
@@ -11,10 +11,10 @@
using namespace std;
int main(int argc, char **argv) {
- std::vector<const char *> preargs;
std::vector<const char*> args(argv, argv+argc);
- global_init(&preargs, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
- CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
+ auto cct = global_init(nullptr, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY,
+ CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
common_init_finish(g_ceph_context);
// make sure we have 3 copies, or some tests won't work
g_ceph_context->_conf->set_val("osd_pool_default_size", "3", false);
diff --git a/src/test/osd/TestOSDScrub.cc b/src/test/osd/TestOSDScrub.cc
index fbd82a64165..3cff0007f94 100644
--- a/src/test/osd/TestOSDScrub.cc
+++ b/src/test/osd/TestOSDScrub.cc
@@ -21,13 +21,13 @@
#include <stdio.h>
#include <signal.h>
+#include <gtest/gtest.h>
#include "osd/OSD.h"
#include "os/ObjectStore.h"
#include "mon/MonClient.h"
#include "common/ceph_argparse.h"
-#include "global/global_init.h"
-#include <gtest/gtest.h>
#include "msg/Messenger.h"
+#include "test/unit.h"
class TestOSDScrub: public OSD {
@@ -141,17 +141,6 @@ TEST(TestOSDScrub, scrub_time_permit) {
}
-int main(int argc, char **argv) {
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
// Local Variables:
// compile-command: "cd ../.. ; make unittest_osdscrub ; ./unittest_osdscrub --log-to-stderr=true --debug-osd=20 # --gtest_filter=*.* "
// End:
diff --git a/src/test/osd/TestPGLog.cc b/src/test/osd/TestPGLog.cc
index 4c2bb06793a..d2b4657c5e1 100644
--- a/src/test/osd/TestPGLog.cc
+++ b/src/test/osd/TestPGLog.cc
@@ -23,9 +23,7 @@
#include <signal.h>
#include "osd/PGLog.h"
#include "osd/OSDMap.h"
-#include "common/ceph_argparse.h"
-#include "global/global_init.h"
-#include <gtest/gtest.h>
+#include "test/unit.h"
class PGLogTest : public ::testing::Test, protected PGLog {
public:
@@ -2158,17 +2156,6 @@ TEST_F(PGLogTest, ErrorNotIndexedByObject) {
EXPECT_EQ(del.reqid, entry->reqid);
}
-int main(int argc, char **argv) {
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
// Local Variables:
// compile-command: "cd ../.. ; make unittest_pglog ; ./unittest_pglog --log-to-stderr=true --debug-osd=20 # --gtest_filter=*.* "
// End:
diff --git a/src/test/osdc/object_cacher_stress.cc b/src/test/osdc/object_cacher_stress.cc
index a753295e212..a002ee5c8dc 100644
--- a/src/test/osdc/object_cacher_stress.cc
+++ b/src/test/osdc/object_cacher_stress.cc
@@ -355,7 +355,8 @@ int main(int argc, const char **argv)
std::vector<const char*> args;
argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
long long delay_ns = 0;
long long num_ops = 1000;
diff --git a/src/test/perf_counters.cc b/src/test/perf_counters.cc
index 5b74c35132c..bb451ea1f1d 100644
--- a/src/test/perf_counters.cc
+++ b/src/test/perf_counters.cc
@@ -50,8 +50,9 @@ int main(int argc, char **argv) {
preargs.push_back("--admin-socket");
preargs.push_back(get_rand_socket_path());
std::vector<const char*> args;
- global_init(&preargs, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
- CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
+ auto cct = global_init(&preargs, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY,
+ CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
common_init_finish(g_ceph_context);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
diff --git a/src/test/perf_local.cc b/src/test/perf_local.cc
index a8646f37de8..b77e03f3eca 100644
--- a/src/test/perf_local.cc
+++ b/src/test/perf_local.cc
@@ -1018,7 +1018,8 @@ int main(int argc, char *argv[])
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
Cycles::init();
diff --git a/src/test/rbd_mirror/random_write.cc b/src/test/rbd_mirror/random_write.cc
index 61c463b1bd4..9ad4cd01899 100644
--- a/src/test/rbd_mirror/random_write.cc
+++ b/src/test/rbd_mirror/random_write.cc
@@ -155,7 +155,8 @@ int main(int argc, const char **argv)
argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
for (auto i = args.begin(); i != args.end(); ++i) {
if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
@@ -182,33 +183,29 @@ int main(int argc, const char **argv)
int r = rados.init_with_context(g_ceph_context);
if (r < 0) {
derr << "could not initialize RADOS handle" << dendl;
- goto cleanup;
+ return EXIT_FAILURE;
}
r = rados.connect();
if (r < 0) {
derr << "error connecting to local cluster" << dendl;
- goto cleanup;
+ return EXIT_FAILURE;
}
r = rados.ioctx_create(pool_name.c_str(), io_ctx);
if (r < 0) {
derr << "error finding local pool " << pool_name << ": "
<< cpp_strerror(r) << dendl;
- goto cleanup;
+ return EXIT_FAILURE;
}
r = rbd.open(io_ctx, image, image_name.c_str());
if (r < 0) {
derr << "error opening image " << image_name << ": "
<< cpp_strerror(r) << dendl;
- goto cleanup;
+ return EXIT_FAILURE;
}
write_image(image);
-
- cleanup:
- g_ceph_context->put();
-
- return r < 0 ? EXIT_SUCCESS : EXIT_FAILURE;
+ return EXIT_SUCCESS;
}
diff --git a/src/test/rgw/test_http_manager.cc b/src/test/rgw/test_http_manager.cc
index 4521dd6defb..7c3da281ab3 100644
--- a/src/test/rgw/test_http_manager.cc
+++ b/src/test/rgw/test_http_manager.cc
@@ -48,7 +48,8 @@ int main(int argc, char** argv)
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
curl_global_init(CURL_GLOBAL_ALL);
diff --git a/src/test/rgw/test_rgw_compression.cc b/src/test/rgw/test_rgw_compression.cc
index ac36d832d36..8e3720453a0 100644
--- a/src/test/rgw/test_rgw_compression.cc
+++ b/src/test/rgw/test_rgw_compression.cc
@@ -3,9 +3,7 @@
#include "gtest/gtest.h"
#include "rgw/rgw_compression.h"
-#include "global/global_init.h"
-#include "common/ceph_argparse.h"
-
+#include "test/unit.h"
struct MockGetDataCB : public RGWGetDataCB {
int handle_data(bufferlist& bl, off_t bl_ofs, off_t bl_len) override {
@@ -51,16 +49,3 @@ TEST(Decompress, FixupRangePartial)
ASSERT_EQ(range_t(12, 24), fixup_range(&decompress, 16, 999));
ASSERT_EQ(range_t(18, 24), fixup_range(&decompress, 998, 999));
}
-
-// initialize a CephContext
-int main(int argc, char** argv)
-{
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/src/test/rgw/test_rgw_period_history.cc b/src/test/rgw/test_rgw_period_history.cc
index 320f550dfab..efedd269c48 100644
--- a/src/test/rgw/test_rgw_period_history.cc
+++ b/src/test/rgw/test_rgw_period_history.cc
@@ -322,7 +322,8 @@ int main(int argc, char** argv)
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
::testing::InitGoogleTest(&argc, argv);
diff --git a/src/test/test_arch.cc b/src/test/test_arch.cc
index e2c225b20ac..e215e703333 100644
--- a/src/test/test_arch.cc
+++ b/src/test/test_arch.cc
@@ -19,10 +19,10 @@
#include "arch/probe.h"
#include "arch/intel.h"
#include "arch/arm.h"
-#include "global/global_init.h"
-#include "common/ceph_argparse.h"
#include "global/global_context.h"
#include "gtest/gtest.h"
+#include "test/unit.h"
+
#define FLAGS_SIZE 4096
@@ -84,18 +84,6 @@ TEST(Arch, all)
#endif
}
-int main(int argc, char **argv)
-{
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
/*
* Local Variables:
diff --git a/src/test/test_cors.cc b/src/test/test_cors.cc
index 12cb43a6fab..b03a2361d98 100644
--- a/src/test/test_cors.cc
+++ b/src/test/test_cors.cc
@@ -883,7 +883,8 @@ int main(int argc, char *argv[]){
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
g_test = new test_cors_helper();
finisher = new Finisher(g_ceph_context);
diff --git a/src/test/test_filejournal.cc b/src/test/test_filejournal.cc
index 8a1172c3cc4..0d3c818fbb4 100644
--- a/src/test/test_filejournal.cc
+++ b/src/test/test_filejournal.cc
@@ -70,7 +70,8 @@ int main(int argc, char **argv) {
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
char mb[10];
diff --git a/src/test/test_mempool.cc b/src/test/test_mempool.cc
index 37ad3a31826..32ad4fc45bb 100644
--- a/src/test/test_mempool.cc
+++ b/src/test/test_mempool.cc
@@ -270,7 +270,8 @@ int main(int argc, char **argv)
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
// enable debug mode for the tests
diff --git a/src/test/test_mutate.cc b/src/test/test_mutate.cc
index b9e0d717664..a8d83d5708c 100644
--- a/src/test/test_mutate.cc
+++ b/src/test/test_mutate.cc
@@ -44,7 +44,8 @@ int main(int argc, const char **argv)
vector<const char*> args;
argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
string val;
diff --git a/src/test/test_rgw_admin_log.cc b/src/test/test_rgw_admin_log.cc
index 4f5affe9fa0..a7be06cfefb 100644
--- a/src/test/test_rgw_admin_log.cc
+++ b/src/test/test_rgw_admin_log.cc
@@ -1572,7 +1572,8 @@ int main(int argc, char *argv[]){
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
g_test = new admin_log::test_helper();
finisher = new Finisher(g_ceph_context);
diff --git a/src/test/test_rgw_admin_meta.cc b/src/test/test_rgw_admin_meta.cc
index 063b9ea88fc..0d61c18e705 100644
--- a/src/test/test_rgw_admin_meta.cc
+++ b/src/test/test_rgw_admin_meta.cc
@@ -908,7 +908,8 @@ int main(int argc, char *argv[]){
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
g_test = new admin_meta::test_helper();
finisher = new Finisher(g_ceph_context);
diff --git a/src/test/test_rgw_admin_opstate.cc b/src/test/test_rgw_admin_opstate.cc
index 451d6df22f2..00dde0cb815 100644
--- a/src/test/test_rgw_admin_opstate.cc
+++ b/src/test/test_rgw_admin_opstate.cc
@@ -805,7 +805,8 @@ int main(int argc, char *argv[]){
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
store = RGWStoreManager::get_storage(g_ceph_context, false, false, false, false);
g_test = new admin_log::test_helper();
diff --git a/src/test/test_snap_mapper.cc b/src/test/test_snap_mapper.cc
index 53f1d292897..51244091397 100644
--- a/src/test/test_snap_mapper.cc
+++ b/src/test/test_snap_mapper.cc
@@ -4,15 +4,14 @@
#include <set>
#include <boost/scoped_ptr.hpp>
#include <sys/types.h>
+#include <cstdlib>
#include "include/buffer.h"
#include "common/map_cacher.hpp"
#include "osd/SnapMapper.h"
-#include "global/global_init.h"
-#include "common/ceph_argparse.h"
+#include "test/unit.h"
#include "gtest/gtest.h"
-#include "stdlib.h"
using namespace std;
@@ -660,14 +659,3 @@ TEST_F(SnapMapperTest, MultiPG) {
init(50);
run();
}
-
-int main(int argc, char **argv)
-{
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/src/test/test_striper.cc b/src/test/test_striper.cc
index 2e0c23fc678..cab2f727784 100644
--- a/src/test/test_striper.cc
+++ b/src/test/test_striper.cc
@@ -1,8 +1,6 @@
#include "gtest/gtest.h"
#include "global/global_context.h"
-#include "common/ceph_argparse.h"
-#include "global/global_init.h"
-#include "common/common_init.h"
+#include "test/unit.h"
#include "osdc/Striper.h"
@@ -73,18 +71,3 @@ TEST(Striper, GetNumObj)
numobjs = Striper::get_num_objects(l, size);
ASSERT_EQ(6u, numobjs);
}
-
-
-int main(int argc, char **argv)
-{
- ::testing::InitGoogleTest(&argc, argv);
-
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
- env_to_vec(args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- return RUN_ALL_TESTS();
-}
diff --git a/src/test/test_trans.cc b/src/test/test_trans.cc
index e671e47e04b..722ce889dda 100644
--- a/src/test/test_trans.cc
+++ b/src/test/test_trans.cc
@@ -38,7 +38,8 @@ int main(int argc, const char **argv)
argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
// args
diff --git a/src/test/test_workqueue.cc b/src/test/test_workqueue.cc
index d67f302a8b3..b5ec3e4bfc9 100644
--- a/src/test/test_workqueue.cc
+++ b/src/test/test_workqueue.cc
@@ -1,10 +1,8 @@
#include "gtest/gtest.h"
#include "common/WorkQueue.h"
-#include "global/global_context.h"
#include "common/ceph_argparse.h"
-#include "global/global_init.h"
-#include "common/common_init.h"
+#include "test/unit.h"
TEST(WorkQueue, StartStop)
{
@@ -56,17 +54,3 @@ TEST(WorkQueue, Resize)
sleep(1);
tp.stop();
}
-
-
-int main(int argc, char **argv)
-{
- ::testing::InitGoogleTest(&argc, argv);
-
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
-
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
- return RUN_ALL_TESTS();
-}
diff --git a/src/test/testkeys.cc b/src/test/testkeys.cc
index 2ef1fcd7d84..93bed6b6e9c 100644
--- a/src/test/testkeys.cc
+++ b/src/test/testkeys.cc
@@ -12,7 +12,8 @@ int main(int argc, const char **argv)
argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
KeyRing extra;
KeyServer server(g_ceph_context, &extra);
diff --git a/src/test/testmsgr.cc b/src/test/testmsgr.cc
index 6c5d658e33b..a693461bc92 100644
--- a/src/test/testmsgr.cc
+++ b/src/test/testmsgr.cc
@@ -73,7 +73,8 @@ int main(int argc, const char **argv, const char *envp[]) {
argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
dout(0) << "i am mon " << args[0] << dendl;
diff --git a/src/test/unit.h b/src/test/unit.h
index b1fb373ed43..5c877942b9f 100644
--- a/src/test/unit.h
+++ b/src/test/unit.h
@@ -18,7 +18,9 @@
#include "include/types.h" // FIXME: ordering shouldn't be important, but right
// now, this include has to come before the others.
+#include "common/ceph_argparse.h"
#include "common/code_environment.h"
+#include "common/config.h"
#include "global/global_context.h"
#include "global/global_init.h"
#include "include/msgr.h" // for CEPH_ENTITY_TYPE_CLIENT
@@ -32,10 +34,19 @@
* initialization for you.
*/
int main(int argc, char **argv) {
- std::vector<const char*> args;
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
- CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
+ std::vector<const char*> args(argv, argv + argc);
+ env_to_vec(args);
+ auto cct = global_init(NULL, args,
+ CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
+
+ const char* env = getenv("CEPH_LIB");
+ if (env) {
+ g_conf->set_val("erasure_code_dir", env, false, false);
+ g_conf->set_val("plugin_dir", env, false, false);
+ }
+
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
diff --git a/src/test/xattr_bench.cc b/src/test/xattr_bench.cc
index 5c57b8927fe..d1cb8cb3297 100644
--- a/src/test/xattr_bench.cc
+++ b/src/test/xattr_bench.cc
@@ -152,7 +152,8 @@ int main(int argc, char **argv) {
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
- global_init(0, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(0, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
std::cerr << "args: " << args << std::endl;
diff --git a/src/tools/ceph-client-debug.cc b/src/tools/ceph-client-debug.cc
index a84cadcf69d..a6ab88d84f6 100644
--- a/src/tools/ceph-client-debug.cc
+++ b/src/tools/ceph-client-debug.cc
@@ -85,8 +85,9 @@ int main(int argc, const char **argv)
argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
- CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY,
+ CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS);
common_init_finish(g_ceph_context);
diff --git a/src/tools/ceph_authtool.cc b/src/tools/ceph_authtool.cc
index d7c3724c908..db6b63d1418 100644
--- a/src/tools/ceph_authtool.cc
+++ b/src/tools/ceph_authtool.cc
@@ -63,8 +63,9 @@ int main(int argc, const char **argv)
map<string,bufferlist> caps;
std::string fn;
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
- CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY,
+ CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
bool gen_key = false;
bool gen_print_key = false;
diff --git a/src/tools/ceph_conf.cc b/src/tools/ceph_conf.cc
index f047e7ca87c..7a50c138e60 100644
--- a/src/tools/ceph_conf.cc
+++ b/src/tools/ceph_conf.cc
@@ -153,6 +153,12 @@ int main(int argc, const char **argv)
global_pre_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_DAEMON,
CINIT_FLAG_NO_DAEMON_ACTIONS);
+ std::unique_ptr<CephContext,
+ std::function<void(CephContext*)> > cct_deleter{
+ g_ceph_context,
+ [](CephContext *p) {p->put();}
+ };
+
g_conf->apply_changes(NULL);
g_conf->complain_about_parse_errors(g_ceph_context);
diff --git a/src/tools/ceph_kvstore_tool.cc b/src/tools/ceph_kvstore_tool.cc
index 61d545ece96..751bf106c70 100644
--- a/src/tools/ceph_kvstore_tool.cc
+++ b/src/tools/ceph_kvstore_tool.cc
@@ -230,7 +230,7 @@ int main(int argc, const char *argv[])
argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(
+ auto cct = global_init(
NULL, args,
CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
diff --git a/src/tools/ceph_monstore_tool.cc b/src/tools/ceph_monstore_tool.cc
index 5198ebf5d35..c39f6a2111b 100644
--- a/src/tools/ceph_monstore_tool.cc
+++ b/src/tools/ceph_monstore_tool.cc
@@ -787,7 +787,7 @@ int main(int argc, char **argv) {
ceph_options.push_back(i->c_str());
}
- global_init(
+ auto cct = global_init(
&def_args, ceph_options, CEPH_ENTITY_TYPE_MON,
CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
diff --git a/src/tools/ceph_objectstore_tool.cc b/src/tools/ceph_objectstore_tool.cc
index e2636d202f4..d5ce63a98c1 100644
--- a/src/tools/ceph_objectstore_tool.cc
+++ b/src/tools/ceph_objectstore_tool.cc
@@ -319,13 +319,6 @@ static int get_fd_data(int fd, bufferlist &bl)
return 0;
}
-void myexit(int ret)
-{
- if (g_ceph_context)
- g_ceph_context->put();
- exit(ret);
-}
-
int get_log(ObjectStore *fs, __u8 struct_ver,
coll_t coll, spg_t pgid, const pg_info_t &info,
PGLog::IndexedLog &log, pg_missing_t &missing)
@@ -2378,12 +2371,12 @@ int main(int argc, char **argv)
po::include_positional);
} catch(po::error &e) {
std::cerr << e.what() << std::endl;
- myexit(1);
+ return 1;
}
if (vm.count("help")) {
usage(desc);
- myexit(1);
+ return 1;
}
if (!vm.count("debug")) {
@@ -2444,7 +2437,7 @@ int main(int argc, char **argv)
!(op == "dump-journal" && type == "filestore")) {
cerr << "Must provide --data-path" << std::endl;
usage(desc);
- myexit(1);
+ return 1;
}
if (type == "filestore" && !vm.count("journal-path")) {
jpath = dpath + "/journal";
@@ -2452,29 +2445,29 @@ int main(int argc, char **argv)
if (!vm.count("op") && !vm.count("object")) {
cerr << "Must provide --op or object command..." << std::endl;
usage(desc);
- myexit(1);
+ return 1;
}
if (op != "list" &&
vm.count("op") && vm.count("object")) {
cerr << "Can't specify both --op and object command syntax" << std::endl;
usage(desc);
- myexit(1);
+ return 1;
}
if (op == "apply-layout-settings" && !(vm.count("pool") ^ vm.count("pgid"))) {
cerr << "apply-layout-settings requires either --pool or --pgid"
<< std::endl;
usage(desc);
- myexit(1);
+ return 1;
}
if (op != "list" && vm.count("object") && !vm.count("objcmd")) {
cerr << "Invalid syntax, missing command" << std::endl;
usage(desc);
- myexit(1);
+ return 1;
}
if (op == "fuse" && mountpoint.length() == 0) {
cerr << "Missing fuse mountpoint" << std::endl;
usage(desc);
- myexit(1);
+ return 1;
}
outistty = isatty(STDOUT_FILENO);
@@ -2483,7 +2476,7 @@ int main(int argc, char **argv)
if (!vm.count("file") || file == "-") {
if (outistty) {
cerr << "stdout is a tty and no --file filename specified" << std::endl;
- myexit(1);
+ return 1;
}
file_fd = STDOUT_FILENO;
} else {
@@ -2493,7 +2486,7 @@ int main(int argc, char **argv)
if (!vm.count("file") || file == "-") {
if (isatty(STDIN_FILENO)) {
cerr << "stdin is a tty and no --file filename specified" << std::endl;
- myexit(1);
+ return 1;
}
file_fd = STDIN_FILENO;
} else {
@@ -2506,16 +2499,16 @@ int main(int argc, char **argv)
if (vm.count("file") && file_fd == fd_none && !dry_run) {
cerr << "--file option only applies to import, export, "
<< "get-osdmap, set-osdmap, get-inc-osdmap or set-inc-osdmap" << std::endl;
- myexit(1);
+ return 1;
}
if (file_fd != fd_none && file_fd < 0) {
string err = string("file: ") + file;
perror(err.c_str());
- myexit(1);
+ return 1;
}
- global_init(
+ auto cct = global_init(
NULL, ceph_options, CEPH_ENTITY_TYPE_OSD,
CODE_ENVIRONMENT_UTILITY_NODOUT, 0);
//CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
@@ -2538,7 +2531,7 @@ int main(int argc, char **argv)
formatter = Formatter::create(format);
if (formatter == NULL) {
cerr << "unrecognized format: " << format << std::endl;
- myexit(1);
+ return 1;
}
// Special handling for filestore journal, so we can dump it without mounting
@@ -2547,10 +2540,10 @@ int main(int argc, char **argv)
if (ret < 0) {
cerr << "journal-path: " << jpath << ": "
<< cpp_strerror(ret) << std::endl;
- myexit(1);
+ return 1;
}
formatter->flush(cout);
- myexit(0);
+ return 0;
}
//Verify that data-path really exists
@@ -2558,40 +2551,40 @@ int main(int argc, char **argv)
if (::stat(dpath.c_str(), &st) == -1) {
string err = string("data-path: ") + dpath;
perror(err.c_str());
- myexit(1);
+ return 1;
}
if (pgidstr.length() && !pgid.parse(pgidstr.c_str())) {
cerr << "Invalid pgid '" << pgidstr << "' specified" << std::endl;
- myexit(1);
+ return 1;
}
ObjectStore *fs = ObjectStore::create(g_ceph_context, type, dpath, jpath, flags);
if (fs == NULL) {
cerr << "Unable to create store of type " << type << std::endl;
- myexit(1);
+ return 1;
}
if (op == "fsck" || op == "fsck-deep") {
int r = fs->fsck(op == "fsck-deep");
if (r < 0) {
cerr << "fsck failed: " << cpp_strerror(r) << std::endl;
- myexit(1);
+ return 1;
}
if (r > 0) {
cerr << "fsck found " << r << " errors" << std::endl;
- myexit(1);
+ return 1;
}
cout << "fsck found no errors" << std::endl;
- exit(0);
+ return 0;
}
if (op == "mkfs") {
int r = fs->mkfs();
if (r < 0) {
cerr << "fsck failed: " << cpp_strerror(r) << std::endl;
- myexit(1);
+ return 1;
}
- myexit(0);
+ return 0;
}
ObjectStore::Sequencer *osr = new ObjectStore::Sequencer(__func__);
@@ -2602,7 +2595,7 @@ int main(int argc, char **argv)
} else {
cerr << "Mount failed with '" << cpp_strerror(ret) << "'" << std::endl;
}
- myexit(1);
+ return 1;
}
if (op == "fuse") {
@@ -2612,12 +2605,12 @@ int main(int argc, char **argv)
int r = fuse.main();
if (r < 0) {
cerr << "failed to mount fuse: " << cpp_strerror(r) << std::endl;
- myexit(1);
+ return 1;
}
#else
cerr << "fuse support not enabled" << std::endl;
#endif
- myexit(0);
+ return 0;
}
vector<coll_t> ls;
@@ -3328,5 +3321,5 @@ out:
if (ret < 0)
ret = 1;
- myexit(ret);
+ return ret;
}
diff --git a/src/tools/ceph_osdomap_tool.cc b/src/tools/ceph_osdomap_tool.cc
index ffb45288393..0fb6d98a1f1 100644
--- a/src/tools/ceph_osdomap_tool.cc
+++ b/src/tools/ceph_osdomap_tool.cc
@@ -64,7 +64,7 @@ int main(int argc, char **argv) {
ceph_options.push_back(i->c_str());
}
- global_init(
+ auto cct = global_init(
&def_args, ceph_options, CEPH_ENTITY_TYPE_OSD,
CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
diff --git a/src/tools/cephfs/cephfs-data-scan.cc b/src/tools/cephfs/cephfs-data-scan.cc
index 5e9c05a0717..dcf83bbfd1c 100644
--- a/src/tools/cephfs/cephfs-data-scan.cc
+++ b/src/tools/cephfs/cephfs-data-scan.cc
@@ -14,7 +14,8 @@ int main(int argc, const char **argv)
argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
DataScan data_scan;
diff --git a/src/tools/cephfs/cephfs-journal-tool.cc b/src/tools/cephfs/cephfs-journal-tool.cc
index e9083a5acf5..2764feb0fcb 100644
--- a/src/tools/cephfs/cephfs-journal-tool.cc
+++ b/src/tools/cephfs/cephfs-journal-tool.cc
@@ -27,7 +27,8 @@ int main(int argc, const char **argv)
argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
JournalTool jt;
diff --git a/src/tools/cephfs/cephfs-table-tool.cc b/src/tools/cephfs/cephfs-table-tool.cc
index 749de6f84d6..ef09df49473 100644
--- a/src/tools/cephfs/cephfs-table-tool.cc
+++ b/src/tools/cephfs/cephfs-table-tool.cc
@@ -14,7 +14,8 @@ int main(int argc, const char **argv)
argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
TableTool tt;
diff --git a/src/tools/crushtool.cc b/src/tools/crushtool.cc
index d4bc24fc1d8..19b970aed1a 100644
--- a/src/tools/crushtool.cc
+++ b/src/tools/crushtool.cc
@@ -271,8 +271,9 @@ int main(int argc, const char **argv)
// only parse arguments from CEPH_ARGS, if in the environment
vector<const char *> env_args;
env_to_vec(env_args);
- global_init(NULL, env_args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
- CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
+ auto cct = global_init(NULL, env_args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY,
+ CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
common_init_finish(g_ceph_context);
int x;
diff --git a/src/tools/monmaptool.cc b/src/tools/monmaptool.cc
index 274f67c0c28..b600f5a5393 100644
--- a/src/tools/monmaptool.cc
+++ b/src/tools/monmaptool.cc
@@ -183,8 +183,9 @@ int main(int argc, const char **argv)
list<string> rm;
list<feature_op_t> features;
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
- CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY,
+ CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
common_init_finish(g_ceph_context);
std::string val;
for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
diff --git a/src/tools/osdmaptool.cc b/src/tools/osdmaptool.cc
index a0190753860..8df5c3c3be4 100644
--- a/src/tools/osdmaptool.cc
+++ b/src/tools/osdmaptool.cc
@@ -45,8 +45,9 @@ int main(int argc, const char **argv)
argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
- CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY,
+ CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
common_init_finish(g_ceph_context);
const char *me = argv[0];
diff --git a/src/tools/rados/rados.cc b/src/tools/rados/rados.cc
index 99a55ba82e2..d611ed7b25a 100644
--- a/src/tools/rados/rados.cc
+++ b/src/tools/rados/rados.cc
@@ -3548,7 +3548,8 @@ int main(int argc, const char **argv)
}
}
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
std::vector<const char*>::iterator i;
diff --git a/src/tools/rbd/rbd.cc b/src/tools/rbd/rbd.cc
index bfa18d345b6..c81faf83696 100644
--- a/src/tools/rbd/rbd.cc
+++ b/src/tools/rbd/rbd.cc
@@ -13,7 +13,8 @@ int main(int argc, const char **argv)
argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
rbd::Shell shell;
return shell.execute(args);
diff --git a/src/tools/rbd_mirror/main.cc b/src/tools/rbd_mirror/main.cc
index 0bdafe87675..a423555eac9 100644
--- a/src/tools/rbd_mirror/main.cc
+++ b/src/tools/rbd_mirror/main.cc
@@ -35,9 +35,9 @@ int main(int argc, const char **argv)
env_to_vec(args);
argv_to_vec(argc, argv, args);
- global_init(nullptr, args, CEPH_ENTITY_TYPE_CLIENT,
- CODE_ENVIRONMENT_DAEMON,
- CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS);
+ auto cct = global_init(nullptr, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_DAEMON,
+ CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS);
for (auto i = args.begin(); i != args.end(); ++i) {
if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
@@ -80,7 +80,6 @@ int main(int argc, const char **argv)
shutdown_async_signal_handler();
delete mirror;
- g_ceph_context->put();
return r < 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/tools/rbd_nbd/rbd-nbd.cc b/src/tools/rbd_nbd/rbd-nbd.cc
index 74c269e74af..029d21656c8 100644
--- a/src/tools/rbd_nbd/rbd-nbd.cc
+++ b/src/tools/rbd_nbd/rbd-nbd.cc
@@ -754,8 +754,9 @@ static int rbd_nbd(int argc, const char *argv[])
argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_DAEMON,
- CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS);
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_DAEMON,
+ CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS);
g_ceph_context->_conf->set_val_or_die("pid_file", "");
std::vector<const char*>::iterator i;