From: Kefu Chai Date: Mon, 13 Jun 2016 04:26:29 +0000 (+0800) Subject: test: ceph_test_objectstore: do not override plugin-dir if not necessary X-Git-Tag: v11.0.0~168^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9c4d1beca15a4b2b7c5564deb091668c2a88147e;p=ceph.git test: ceph_test_objectstore: do not override plugin-dir if not necessary there is chance that we launch the test with the plugins installed in `/usr/${lib}/ceph'. and we don't have ".lib" or $CEPH_LIB for ceph_test_objectstore, in this case, we should leave plugin-dir unchanged. it will work just fine if ceph-base or ceph-common is installed. Fixes: http://tracker.ceph.com/issues/16254 Signed-off-by: Kefu Chai --- diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index c0220d22db1c..e8ca94c44652 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -12,6 +12,7 @@ * */ +#include #include #include #include @@ -4485,6 +4486,15 @@ TEST(DummyTest, ValueParameterizedTestsAreNotSupportedOnThisPlatform) {} #endif +static bool plugin_exists(const string& compressor_dir) +{ + string pattern(compressor_dir + "/libceph*.so"); + glob_t buf; + int ret = glob(pattern.c_str(), 0, nullptr, &buf); + globfree(&buf); + return ret == 0; +} + int main(int argc, char **argv) { vector args; argv_to_vec(argc, (const char **)argv, args); @@ -4495,20 +4505,35 @@ int main(int argc, char **argv) { const char* env = getenv("CEPH_LIB"); std::string directory(env ? env : ".libs"); - string mkdir_compressor = "mkdir -p " + directory + "/compressor"; - int r = system(mkdir_compressor.c_str()); - (void)r; - - string cp_libceph_snappy = "cp " + directory + "/libceph_snappy.so* " + directory + "/compressor/"; - r = system(cp_libceph_snappy.c_str()); - (void)r; - - string cp_libceph_zlib = "cp " + directory + "/libceph_zlib.so* " + directory + "/compressor/"; - r = system(cp_libceph_zlib.c_str()); - (void)r; - - g_ceph_context->_conf->set_val("plugin_dir", directory, false, false); - + if (plugin_exists(directory)) { + string mkdir_compressor = "mkdir -p " + directory + "/compressor"; + int r = system(mkdir_compressor.c_str()); + (void)r; + + string cp_libceph_snappy = "cp " + directory + "/libceph_snappy.so* " + directory + "/compressor/"; + r = system(cp_libceph_snappy.c_str()); + (void)r; + + string cp_libceph_zlib = "cp " + directory + "/libceph_zlib.so* " + directory + "/compressor/"; + r = system(cp_libceph_zlib.c_str()); + (void)r; + g_ceph_context->_conf->set_val("plugin_dir", directory, false, false); + } else { + char plugin_dir[PATH_MAX]; + char *val = plugin_dir; + int r = g_ceph_context->_conf->get_val("plugin_dir", &val, + sizeof(plugin_dir)); + if (r) + return r; + string compressor_dir(val); + compressor_dir += "/compressor"; + if (!plugin_exists(compressor_dir)) { + std::cerr << "compressor plugins not found in '" + << directory << "' or '" << compressor_dir << "'" + << std::endl; + return EINVAL; + } + } g_ceph_context->_conf->set_val("osd_journal_size", "400"); g_ceph_context->_conf->set_val("filestore_index_retry_probability", "0.5"); @@ -4527,7 +4552,7 @@ int main(int argc, char **argv) { g_ceph_context->_conf->apply_changes(NULL); ::testing::InitGoogleTest(&argc, argv); - r = RUN_ALL_TESTS(); + int r = RUN_ALL_TESTS(); g_ceph_context->put(); return r; }