The unified diff between revisions [695f5995..] and [b773b0a7..] is displayed below. It can also be downloaded as a raw diff.
This diff has been restricted to the following files: 'checks/check.cpp'
#
#
# patch "checks/check.cpp"
# from [f206b6011fc0d8f6400fa947062d727a40c9eaa2]
# to [8bfeb47c287bea56e3b4543a034b486664a0d60d]
#
============================================================
--- checks/check.cpp f206b6011fc0d8f6400fa947062d727a40c9eaa2
+++ checks/check.cpp 8bfeb47c287bea56e3b4543a034b486664a0d60d
@@ -1,7 +1,5 @@
/*
* Test Driver for Botan
- *
- * This file is in the public domain
*/
#include <vector>
@@ -20,7 +18,6 @@ using namespace Botan_types;
#include "getopt.h"
-
const std::string VALIDATION_FILE = "checks/validate.dat";
const std::string BIGINT_VALIDATION_FILE = "checks/mp_valid.dat";
const std::string PK_VALIDATION_FILE = "checks/pk_valid.dat";
@@ -28,29 +25,36 @@ void bench_pk(const std::string&, bool h
void benchmark(const std::string&, bool html, double seconds);
void bench_pk(const std::string&, bool html, double seconds);
-u32bit bench_algo(const std::string&);
+u32bit bench_algo(const std::string&, double);
int validate();
-void print_help();
int main(int argc, char* argv[])
{
try
{
- if(argc <= 1)
- { print_help(); return 1; }
-
OptionParser opts("help|html|init=|validate|"
"benchmark|bench-type=|bench-algo=|seconds=");
opts.parse(argv);
- if(opts.is_set("help"))
- { print_help(); return 1; }
+ Botan::InitializerOptions init_options(opts.value_if_set("init"));
+ Botan::LibraryInitializer init(init_options);
- std::string init_flags = (opts.is_set("init") ? opts.value("init") : "");
+ if(opts.is_set("help") || argc <= 1)
+ {
+ std::cerr << "Test driver for "
+ << Botan::version_string() << "\n"
+ << "Options:\n"
+ << " --validate: Check test vectors\n"
+ << " --benchmark: Benchmark everything\n"
+ << " --bench-type={block,mode,stream,hash,mac,rng,pk}:\n"
+ << " Benchmark only algorithms of a particular type\n"
+ << " --html: Produce HTML output for benchmarks\n"
+ << " --seconds=n: Benchmark for n seconds\n"
+ << " --init=<str>: Pass <str> to the library\n"
+ << " --help: Print this message\n";
+ return 1;
+ }
- Botan::InitializerOptions init_options(init_flags);
- Botan::LibraryInitializer init(init_options);
-
if(opts.is_set("validate"))
return validate();
@@ -59,23 +63,29 @@ int main(int argc, char* argv[])
if(opts.is_set("seconds"))
{
seconds = std::atof(opts.value("seconds").c_str());
- if((seconds < 0.1 || seconds > 30) && seconds != 0)
+ if(seconds && (seconds < 0.1 || seconds > (5 * 60)))
{
std::cout << "Invalid argument to --seconds\n";
return 2;
}
}
+ const bool html = opts.is_set("html");
+
if(opts.is_set("bench-algo"))
{
- const std::string alg = opts.value("bench-algo");
- u32bit found = bench_algo(alg);
- if(!found) // maybe it's a PK algorithm
- bench_pk(alg, false, seconds);
+ std::vector<std::string> algs =
+ Botan::split_on(opts.value("bench-algo"), ',');
+
+ for(u32bit j = 0; j != algs.size(); j++)
+ {
+ const std::string alg = algs[j];
+ u32bit found = bench_algo(alg, seconds);
+ if(!found) // maybe it's a PK algorithm
+ bench_pk(alg, html, seconds);
+ }
}
- const bool html = opts.is_set("html");
-
if(opts.is_set("benchmark"))
benchmark("All", html, seconds);
else if(opts.is_set("bench-type"))
@@ -118,19 +128,6 @@ int main(int argc, char* argv[])
return 0;
}
-void print_help()
- {
- std::cout << Botan::version_string() << " test driver" << std::endl
- << "Usage:\n"
- << " --validate: Check test vectors\n"
- << " --benchmark: Benchmark everything\n"
- << " --bench-type={block,mode,stream,hash,mac,rng,pk}:\n"
- << " Benchmark only algorithms of a particular type\n"
- << " --html: Produce HTML output for benchmarks\n"
- << " --seconds=n: Benchmark for n seconds\n"
- << " --help: Print this message\n";
- }
-
int validate()
{
void test_types();