]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test: test_store_tool: global init before using LevelDBStore
authorJoao Eduardo Luis <joao.luis@inktank.com>
Mon, 17 Jun 2013 13:43:36 +0000 (14:43 +0100)
committerSage Weil <sage@inktank.com>
Wed, 24 Jul 2013 16:12:49 +0000 (09:12 -0700)
Fixes a segfault

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
(cherry picked from commit a7a7d3fc8a2ba4a30ef136a32f2903d157b3e19a)

src/test/ObjectMap/test_store_tool/test_store_tool.cc

index 4ab6289288042062efafb06a124a962c0a80d247..ace91220df66fe1ef854538bc7786c4dbb508279 100644 (file)
 
 #include "os/LevelDBStore.h"
 
+#include "common/ceph_argparse.h"
+#include "global/global_init.h"
+#include "common/errno.h"
+#include "common/safe_io.h"
+#include "common/config.h"
+
 using namespace std;
 
 class StoreTool
@@ -98,15 +104,27 @@ void usage(const char *pname)
     << std::endl;
 }
 
-int main(int argc, char *argv[])
+int main(int argc, const char *argv[])
 {
-  if (argc < 3) {
+  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);
+  common_init_finish(g_ceph_context);
+
+
+  if (args.size() < 2) {
     usage(argv[0]);
     return 1;
   }
 
-  string path(argv[1]);
-  string cmd(argv[2]);
+  string path(args[0]);
+  string cmd(args[1]);
+
+  std::cout << "path: " << path << " cmd " << cmd << std::endl;
 
   StoreTool st(path);