]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/ceph_crypto: do not read ceph.conf in global_init() 14701/head
authorKefu Chai <kchai@redhat.com>
Mon, 5 Dec 2016 12:23:21 +0000 (20:23 +0800)
committerNathan Cutler <ncutler@suse.com>
Tue, 25 Apr 2017 13:48:00 +0000 (15:48 +0200)
ForkDeathTest.MD5 expect an empty output while global_init() complains
if ceph.conf is missing if 0 is passed in as the `flags`. this test
passes if ceph.conf is in current working directory, but jenkins does
not prepare this file for this test.

Fixes: http://tracker.ceph.com/issues/18128
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit c72a2271a8012a66d7bbccf5766a73da5bb878d6)

Conflicts:
        src/test/ceph_crypto.cc - jewel does not have
             5af29540675b674c1985ff98b28a783ed124acf6

src/test/ceph_crypto.cc

index 893f332b073f7ab42915ebffc9e8e9ff07f10403..6f166a8de7b27986ec00ecbe061531fb621c1ee4 100644 (file)
@@ -1,6 +1,11 @@
 #include "common/ceph_crypto.h"
 
-#include "test/unit.h"
+#include "gtest/gtest.h"
+#include "common/ceph_argparse.h"
+#include "common/ceph_crypto.h"
+#include "common/common_init.h"
+#include "global/global_init.h"
+#include "global/global_context.h"
 
 class CryptoEnvironment: public ::testing::Environment {
 public:
@@ -138,3 +143,15 @@ TEST_F(ForkDeathTest, MD5) {
   ASSERT_EXIT(do_simple_crypto(), ::testing::ExitedWithCode(0), "^$");
 }
 #endif //GTEST_HAS_DEATH_TEST
+
+int main(int argc, char **argv) {
+  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,
+                         CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
+  common_init_finish(g_ceph_context);
+  ::testing::InitGoogleTest(&argc, argv);
+  return RUN_ALL_TESTS();
+}