From: Loic Dachary Date: Tue, 23 Sep 2014 12:37:57 +0000 (+0200) Subject: erasure_code: implement ceph_erasure_code to assert the existence of a plugin X-Git-Tag: v0.89~35^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=efe121d9f2028c312eef2650d32ccf0cbc828edb;p=ceph.git erasure_code: implement ceph_erasure_code to assert the existence of a plugin This is handy when scripting in the context of teuthology and only conditionally run tests for the isa plugin, for instance. Signed-off-by: Loic Dachary --- diff --git a/src/test/erasure-code/ceph_erasure_code.cc b/src/test/erasure-code/ceph_erasure_code.cc index 1d8dd903f598..c17c8e9f19b5 100644 --- a/src/test/erasure-code/ceph_erasure_code.cc +++ b/src/test/erasure-code/ceph_erasure_code.cc @@ -4,6 +4,7 @@ * Ceph distributed storage system * * Copyright (C) 2014 Cloudwatt + * Copyright (C) 2014 Red Hat * * Author: Loic Dachary * @@ -39,6 +40,8 @@ class ErasureCodeCommand { public: int setup(int argc, char** argv); int run(); + int plugin_exists(); + int display_information(); }; int ErasureCodeCommand::setup(int argc, char** argv) { @@ -58,6 +61,8 @@ int ErasureCodeCommand::setup(int argc, char** argv) { ("get_chunk_count", "display get_chunk_count()") ("parameter,P", po::value >(), "parameters") + ("plugin_exists", po::value(), + "succeeds if the plugin given in argument exists and can be loaded") ; po::parsed_options parsed = @@ -107,17 +112,37 @@ int ErasureCodeCommand::setup(int argc, char** argv) { if (parameters.count("directory") == 0) parameters["directory"] = ".libs"; - if (parameters.count("plugin") == 0) { - cerr << "--parameter plugin= is mandatory" << endl; - return 1; - } return 0; } int ErasureCodeCommand::run() { + if (vm.count("plugin_exists")) + return plugin_exists(); + else + return display_information(); +} + +int ErasureCodeCommand::plugin_exists() { + ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance(); + ErasureCodePlugin *plugin = 0; + Mutex::Locker l(instance.lock); + stringstream ss; + int code = instance.load(vm["plugin_exists"].as(), parameters["directory"], &plugin, ss); + if (code) + cerr << ss.str() << endl; + return code; +} + +int ErasureCodeCommand::display_information() { ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance(); ErasureCodeInterfaceRef erasure_code; + + if (parameters.count("plugin") == 0) { + cerr << "--parameter plugin= is mandatory" << endl; + return 1; + } + int code = instance.factory(parameters["plugin"], parameters, &erasure_code, cerr); @@ -160,7 +185,7 @@ int main(int argc, char** argv) { * Local Variables: * compile-command: "cd ../.. ; make -j4 && * make -j4 ceph_erasure_code && - * valgrind --tool=memcheck --leak-check=full \ + * libtool --mode=execute valgrind --tool=memcheck --leak-check=full \ * ./ceph_erasure_code \ * --parameter plugin=jerasure \ * --parameter directory=.libs \