aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-10-24 13:58:41 -0400
committerJack Lloyd <[email protected]>2017-10-24 13:59:34 -0400
commitc2830ddf08b41a9f5f2a472e0cc488c9c358fdb2 (patch)
tree02799f4ca7da4fdf34068f95c472424a796a7063 /src/tests
parent7edec05c6056ab890a70eaf9f5c7a73321581ede (diff)
Inline Test::run_test into only caller
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/test_runner.cpp24
-rw-r--r--src/tests/tests.cpp38
-rw-r--r--src/tests/tests.h4
3 files changed, 21 insertions, 45 deletions
diff --git a/src/tests/test_runner.cpp b/src/tests/test_runner.cpp
index 8d3fe7558..9abf43795 100644
--- a/src/tests/test_runner.cpp
+++ b/src/tests/test_runner.cpp
@@ -298,16 +298,32 @@ size_t Test_Runner::run_tests(const std::vector<std::string>& tests_to_run)
for(auto const& test_name : tests_to_run)
{
+ output() << test_name << ':' << std::endl;
+
+ std::vector<Test::Result> results;
+
try
{
- output() << test_name << ':' << std::endl;
- const auto results = Botan_Tests::Test::run_test(test_name, false);
- output() << report_out(results, tests_failed, tests_ran) << std::flush;
+ if(Test* test = Test::get_test(test_name))
+ {
+ std::vector<Test::Result> test_results = test->run();
+ results.insert(results.end(), test_results.begin(), test_results.end());
+ }
+ else
+ {
+ results.push_back(Test::Result::Note(test_name, "Test missing or unavailable"));
+ }
}
catch(std::exception& e)
{
- output() << "Test " << test_name << " failed with exception " << e.what() << std::flush;
+ results.push_back(Test::Result::Failure(test_name, e.what()));
+ }
+ catch(...)
+ {
+ results.push_back(Test::Result::Failure(test_name, "unknown exception"));
}
+
+ output() << report_out(results, tests_failed, tests_ran) << std::flush;
}
const uint64_t total_ns = Botan_Tests::Test::timestamp() - start_time;
diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp
index 7c4e8a258..3d937b9de 100644
--- a/src/tests/tests.cpp
+++ b/src/tests/tests.cpp
@@ -506,44 +506,6 @@ Test* Test::get_test(const std::string& test_name)
return nullptr;
}
-//static
-std::vector<Test::Result> Test::run_test(const std::string& test_name, bool fail_if_missing)
- {
- std::vector<Test::Result> results;
-
- try
- {
- if(Test* test = get_test(test_name))
- {
- std::vector<Test::Result> test_results = test->run();
- results.insert(results.end(), test_results.begin(), test_results.end());
- }
- else
- {
- Test::Result result(test_name);
- if(fail_if_missing)
- {
- result.test_failure("Test missing or unavailable");
- }
- else
- {
- result.test_note("Test missing or unavailable");
- }
- results.push_back(result);
- }
- }
- catch(std::exception& e)
- {
- results.push_back(Test::Result::Failure(test_name, e.what()));
- }
- catch(...)
- {
- results.push_back(Test::Result::Failure(test_name, "unknown exception"));
- }
-
- return results;
- }
-
// static member variables of Test
Botan::RandomNumberGenerator* Test::m_test_rng = nullptr;
std::string Test::m_data_dir;
diff --git a/src/tests/tests.h b/src/tests/tests.h
index d8573444a..fdbd080f4 100644
--- a/src/tests/tests.h
+++ b/src/tests/tests.h
@@ -357,8 +357,6 @@ class Test
virtual ~Test() = default;
virtual std::vector<std::string> possible_providers(const std::string&);
- static std::vector<Test::Result> run_test(const std::string& what, bool fail_if_missing);
-
static std::map<std::string, std::unique_ptr<Test>>& global_registry();
static std::set<std::string> registered_tests();
@@ -397,7 +395,7 @@ class Test
return r;
}
- static void setup_tests(bool log_succcss,
+ static void setup_tests(bool log_success,
bool run_online_tests,
bool run_long_tests,
const std::string& data_dir,