aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-10-24 19:00:34 -0400
committerJack Lloyd <[email protected]>2017-10-24 19:00:34 -0400
commit4bff25a393c771618f0d14428adbd40e37625d2e (patch)
treecc0bc90c3ed57d2e1c71b69fe1fc866af0d7f848 /src/tests
parentd689e0f9148282148135034a32622df62b53d7c0 (diff)
Fix botan-test --help
[ci skip]
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/main.cpp51
-rw-r--r--src/tests/test_runner.cpp31
-rw-r--r--src/tests/test_runner.h2
3 files changed, 48 insertions, 36 deletions
diff --git a/src/tests/main.cpp b/src/tests/main.cpp
index 3144b957d..7ed539001 100644
--- a/src/tests/main.cpp
+++ b/src/tests/main.cpp
@@ -6,9 +6,11 @@
#include "../cli/argparse.h"
#include "test_runner.h"
+#include "tests.h"
#include <iostream>
#include <vector>
#include <string>
+#include <sstream>
#include <botan/version.h>
@@ -16,18 +18,61 @@
#include <botan/internal/openssl.h>
#endif
+namespace {
+
+std::string help_text(const std::string& spec)
+ {
+ std::ostringstream err;
+
+ err << "Usage: " << spec << "\n\n"
+ << "Available test suites\n"
+ << "----------------\n";
+
+ size_t line_len = 0;
+
+ for(auto const& test : Botan_Tests::Test::registered_tests())
+ {
+ err << test << " ";
+ line_len += test.size() + 1;
+
+ if(line_len > 64)
+ {
+ err << "\n";
+ line_len = 0;
+ }
+ }
+
+ if(line_len > 0)
+ {
+ err << "\n";
+ }
+
+ return err.str();
+ }
+
+}
+
int main(int argc, char* argv[])
{
std::cerr << Botan::runtime_version_check(BOTAN_VERSION_MAJOR, BOTAN_VERSION_MINOR, BOTAN_VERSION_PATCH);
try
{
- Botan_CLI::Argument_Parser parser("test --data-dir= --pkcs11-lib= --provider= --log-success "
- "--verbose --help --run-long-tests --run-online-tests --test-runs=1 --drbg-seed= "
- "*suites");
+ const std::string arg_spec =
+ "botan-test --data-dir= --pkcs11-lib= --provider= --log-success "
+ "--verbose --help --run-long-tests --run-online-tests --test-runs=1 --drbg-seed= "
+ "*suites";
+
+ Botan_CLI::Argument_Parser parser(arg_spec);
parser.parse_args(std::vector<std::string>(argv + 1, argv + argc));
+ if(parser.flag_set("help"))
+ {
+ std::cout << help_text(arg_spec);
+ return 0;
+ }
+
const std::string data_dir = parser.get_arg_or("data-dir", "src/tests/data");
const std::string pkcs11_lib = parser.get_arg("pkcs11-lib");
const std::string provider = parser.get_arg("provider");
diff --git a/src/tests/test_runner.cpp b/src/tests/test_runner.cpp
index 9abf43795..6900a32ed 100644
--- a/src/tests/test_runner.cpp
+++ b/src/tests/test_runner.cpp
@@ -124,37 +124,6 @@ create_test_rng(const std::string& drbg_seed, std::ostream& output)
}
-std::string Test_Runner::help_text() const
- {
- std::ostringstream err;
-
- err << "Usage: botan-test "
- << "--run-long-tests --run-online-tests --test-runs=1 --drbg-seed= --data-dir= --pkcs11-lib= --provider= --log-success"
- << "\n\nAvailable test suites\n"
- << "----------------\n";
-
- size_t line_len = 0;
-
- for(auto const& test : Botan_Tests::Test::registered_tests())
- {
- err << test << " ";
- line_len += test.size() + 1;
-
- if(line_len > 64)
- {
- err << "\n";
- line_len = 0;
- }
- }
-
- if(line_len > 0)
- {
- err << "\n";
- }
-
- return err.str();
- }
-
int Test_Runner::run(const std::vector<std::string>& requested_tests,
const std::string& data_dir,
const std::string& pkcs11_lib,
diff --git a/src/tests/test_runner.h b/src/tests/test_runner.h
index 7d111920c..96c562024 100644
--- a/src/tests/test_runner.h
+++ b/src/tests/test_runner.h
@@ -18,8 +18,6 @@ class Test_Runner final
public:
Test_Runner(std::ostream& out);
- std::string help_text() const;
-
int run(const std::vector<std::string>& requested_tests,
const std::string& data_dir,
const std::string& pkcs11_lib,