From: Loic Dachary Date: Wed, 17 Sep 2014 13:34:01 +0000 (+0200) Subject: test,tools: capture boost::program_options in a try X-Git-Tag: v0.88~91^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b085fd8dbfb00aca0364dda16a0ca6b76878db97;p=ceph.git test,tools: capture boost::program_options in a try When something fails boost::program_options throws an exception that needs to be caught. Signed-off-by: Loic Dachary --- diff --git a/src/test/bench/small_io_bench_dumb.cc b/src/test/bench/small_io_bench_dumb.cc index 73841c3c6e40d..fbcca87c7f52d 100644 --- a/src/test/bench/small_io_bench_dumb.cc +++ b/src/test/bench/small_io_bench_dumb.cc @@ -71,7 +71,9 @@ int main(int argc, char **argv) "don't dump per op stats") ; + vector ceph_option_strings; po::variables_map vm; + try { po::parsed_options parsed = po::command_line_parser(argc, argv).options(desc).allow_unregistered().run(); po::store( @@ -79,9 +81,10 @@ int main(int argc, char **argv) vm); po::notify(vm); + ceph_option_strings = po::collect_unrecognized(parsed.options, + po::include_positional); + } vector ceph_options, def_args; - vector ceph_option_strings = po::collect_unrecognized( - parsed.options, po::include_positional); ceph_options.reserve(ceph_option_strings.size()); for (vector::iterator i = ceph_option_strings.begin(); i != ceph_option_strings.end(); diff --git a/src/test/bench/small_io_bench_fs.cc b/src/test/bench/small_io_bench_fs.cc index 7f03f5ad2a3c6..74f6565174d88 100644 --- a/src/test/bench/small_io_bench_fs.cc +++ b/src/test/bench/small_io_bench_fs.cc @@ -82,7 +82,9 @@ int main(int argc, char **argv) "num write threads") ; + vector ceph_option_strings; po::variables_map vm; + try { po::parsed_options parsed = po::command_line_parser(argc, argv).options(desc).allow_unregistered().run(); po::store( @@ -90,9 +92,10 @@ int main(int argc, char **argv) vm); po::notify(vm); + ceph_option_strings = po::collect_unrecognized(parsed.options, + po::include_positional); + } vector ceph_options, def_args; - vector ceph_option_strings = po::collect_unrecognized( - parsed.options, po::include_positional); ceph_options.reserve(ceph_option_strings.size()); for (vector::iterator i = ceph_option_strings.begin(); i != ceph_option_strings.end(); diff --git a/src/test/bench/tp_bench.cc b/src/test/bench/tp_bench.cc index 31a4db37e09c8..778dcac3ff565 100644 --- a/src/test/bench/tp_bench.cc +++ b/src/test/bench/tp_bench.cc @@ -118,7 +118,9 @@ int main(int argc, char **argv) "layer desc") ; + vector ceph_option_strings; po::variables_map vm; + try { po::parsed_options parsed = po::command_line_parser(argc, argv).options(desc).allow_unregistered().run(); po::store( @@ -126,9 +128,10 @@ int main(int argc, char **argv) vm); po::notify(vm); + ceph_option_strings = po::collect_unrecognized(parsed.options, + po::include_positional); + } vector ceph_options, def_args; - vector ceph_option_strings = po::collect_unrecognized( - parsed.options, po::include_positional); ceph_options.reserve(ceph_option_strings.size()); for (vector::iterator i = ceph_option_strings.begin(); i != ceph_option_strings.end(); diff --git a/src/test/erasure-code/ceph_erasure_code.cc b/src/test/erasure-code/ceph_erasure_code.cc index ed48205e8eff7..4a5282d4f7e74 100644 --- a/src/test/erasure-code/ceph_erasure_code.cc +++ b/src/test/erasure-code/ceph_erasure_code.cc @@ -146,10 +146,12 @@ int ErasureCodeCommand::run() { int main(int argc, char** argv) { ErasureCodeCommand eccommand; + try { int err = eccommand.setup(argc, argv); if (err) return err; return eccommand.run(); + } } /* diff --git a/src/test/erasure-code/ceph_erasure_code_benchmark.cc b/src/test/erasure-code/ceph_erasure_code_benchmark.cc index c6a4228bdc1e4..c104651b372b5 100644 --- a/src/test/erasure-code/ceph_erasure_code_benchmark.cc +++ b/src/test/erasure-code/ceph_erasure_code_benchmark.cc @@ -218,10 +218,12 @@ int ErasureCodeBench::decode() int main(int argc, char** argv) { ErasureCodeBench ecbench; + try { int err = ecbench.setup(argc, argv); if (err) return err; return ecbench.run(); + } } /* diff --git a/src/tools/ceph_monstore_tool.cc b/src/tools/ceph_monstore_tool.cc index d26add613c107..c5cb0e1152e56 100644 --- a/src/tools/ceph_monstore_tool.cc +++ b/src/tools/ceph_monstore_tool.cc @@ -134,12 +134,12 @@ int main(int argc, char **argv) { p.add("version", 1); po::variables_map vm; + try { po::parsed_options parsed = po::command_line_parser(argc, argv).options(desc).positional(p).run(); po::store( parsed, vm); - try { po::notify(vm); } catch (...) { cout << desc << std::endl; diff --git a/src/tools/ceph_objectstore_tool.cc b/src/tools/ceph_objectstore_tool.cc index 288e9cb14a179..827874f704624 100644 --- a/src/tools/ceph_objectstore_tool.cc +++ b/src/tools/ceph_objectstore_tool.cc @@ -1838,10 +1838,10 @@ int main(int argc, char **argv) pd.add("object", 1).add("objcmd", 1).add("arg1", 1).add("arg2", 1); po::variables_map vm; + try { po::parsed_options parsed = po::command_line_parser(argc, argv).options(all).allow_unregistered().positional(pd).run(); po::store( parsed, vm); - try { po::notify(vm); } catch(...) { diff --git a/src/tools/ceph_osdomap_tool.cc b/src/tools/ceph_osdomap_tool.cc index eba41157c9fc2..3e4cae28396b8 100644 --- a/src/tools/ceph_osdomap_tool.cc +++ b/src/tools/ceph_osdomap_tool.cc @@ -42,12 +42,12 @@ int main(int argc, char **argv) { p.add("command", 1); po::variables_map vm; + try { po::parsed_options parsed = po::command_line_parser(argc, argv).options(desc).positional(p).run(); po::store( parsed, vm); - try { po::notify(vm); } catch (...) { cout << desc << std::endl;