]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/ceph_crypto: do not read ceph.conf in global_init() 12318/head
authorKefu Chai <kchai@redhat.com>
Mon, 5 Dec 2016 12:23:21 +0000 (20:23 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 5 Dec 2016 12:26:37 +0000 (20:26 +0800)
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>
src/test/CMakeLists.txt
src/test/ceph_crypto.cc

index 4618b29ec7cf22f3a6b2532d499ba64445f22fda..dad63293fa1d3618e936a490f244a47b4cf14638 100644 (file)
@@ -751,7 +751,6 @@ target_link_libraries(unittest_perf_counters global)
 # unittest_ceph_crypto
 add_executable(unittest_ceph_crypto
   ceph_crypto.cc
-  $<TARGET_OBJECTS:unit-main>
   )
 add_ceph_unittest(unittest_ceph_crypto ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/unittest_ceph_crypto)
 target_link_libraries(unittest_ceph_crypto global)
index 478260168d511fc1bcd98a6a413ab9cffae52dc8..cafe1691c2e08781e3eb0196971c6f1449799d36 100644 (file)
@@ -1,5 +1,8 @@
 #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 {
@@ -138,3 +141,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();
+}