From: JINMEI Tatuya Date: Sat, 25 Aug 2012 00:30:03 +0000 (-0700) Subject: [2216] unrelated improvement: catch exceptions from the test body X-Git-Tag: trac2351_base~115^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=80f7c9687b1b0d30c481055ff83f367a325988f6;p=thirdparty%2Fkea.git [2216] unrelated improvement: catch exceptions from the test body this sometimes happens, and depending on the environment, what() isn't always displayed. so it's helpful to catch it and report the error. --- diff --git a/src/bin/auth/benchmarks/query_bench.cc b/src/bin/auth/benchmarks/query_bench.cc index 391866bb1f..93253db8fe 100644 --- a/src/bin/auth/benchmarks/query_bench.cc +++ b/src/bin/auth/benchmarks/query_bench.cc @@ -262,34 +262,39 @@ main(int argc, char* argv[]) { return (1); } - BenchQueries queries; - loadQueryData(query_data_file, queries, RRClass::IN()); - OutputBuffer buffer(4096); - Message message(Message::PARSE); + try { + BenchQueries queries; + loadQueryData(query_data_file, queries, RRClass::IN()); + OutputBuffer buffer(4096); + Message message(Message::PARSE); - cout << "Parameters:" << endl; - cout << " Iterations: " << iteration << endl; - cout << " Data Source: type=" << opt_datasrc_type << ", file=" << - datasrc_file << endl; - if (origin != NULL) { - cout << " Origin: " << origin << endl; - } - cout << " Query data: file=" << query_data_file << " (" << queries.size() - << " queries)" << endl << endl; + cout << "Parameters:" << endl; + cout << " Iterations: " << iteration << endl; + cout << " Data Source: type=" << opt_datasrc_type << ", file=" << + datasrc_file << endl; + if (origin != NULL) { + cout << " Origin: " << origin << endl; + } + cout << " Query data: file=" << query_data_file << " (" + << queries.size() << " queries)" << endl << endl; - switch (datasrc_type) { - case SQLITE3: - cout << "Benchmark with SQLite3" << endl; - BenchMark( - iteration, Sqlite3QueryBenchMark(datasrc_file, queries, - message, buffer)); - break; - case MEMORY: - cout << "Benchmark with In Memory Data Source" << endl; - BenchMark( - iteration, MemoryQueryBenchMark(datasrc_file, origin, queries, - message, buffer)); - break; + switch (datasrc_type) { + case SQLITE3: + cout << "Benchmark with SQLite3" << endl; + BenchMark( + iteration, Sqlite3QueryBenchMark(datasrc_file, queries, + message, buffer)); + break; + case MEMORY: + cout << "Benchmark with In Memory Data Source" << endl; + BenchMark( + iteration, MemoryQueryBenchMark(datasrc_file, origin, queries, + message, buffer)); + break; + } + } catch (const std::exception& ex) { + cout << "Test unexpectedly failed: " << ex.what() << endl; + return (1); } return (0);