From a24c4cd9b26b0533464e8bd4b3016d01b84181cf Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Sat, 19 Dec 2015 19:20:53 -0500 Subject: If skipping a test due to diabled algo, only print if in verbose mode. Also fix KDF tests which failed on missing algo GH #367 --- src/tests/main.cpp | 62 ++++++++++++++++++++++++++------------------------ src/tests/test_kdf.cpp | 3 ++- src/tests/tests.cpp | 6 ++++- src/tests/tests.h | 2 +- 4 files changed, 40 insertions(+), 33 deletions(-) (limited to 'src/tests') diff --git a/src/tests/main.cpp b/src/tests/main.cpp index c4313a4ef..6dab50932 100644 --- a/src/tests/main.cpp +++ b/src/tests/main.cpp @@ -30,36 +30,6 @@ namespace { using Botan_Tests::Test; -std::string report_out(const std::vector& results, - size_t& tests_failed, - size_t& tests_ran) - { - std::ostringstream out; - - std::map combined; - for(auto&& result : results) - { - const std::string who = result.who(); - auto i = combined.find(who); - if(i == combined.end()) - { - combined[who] = Test::Result(who); - i = combined.find(who); - } - - i->second.merge(result); - } - - for(auto&& result : combined) - { - out << result.second.result_string(); - tests_failed += result.second.tests_failed(); - tests_ran += result.second.tests_run(); - } - - return out.str(); - } - std::unique_ptr setup_tests(std::ostream& out, size_t threads, size_t soak_level, @@ -188,6 +158,38 @@ class Test_Runner : public Botan_CLI::Command throw Botan_Tests::Test_Error("Test suite failure"); } private: + + std::string report_out(const std::vector& results, + size_t& tests_failed, + size_t& tests_ran) + { + std::ostringstream out; + + std::map combined; + for(auto&& result : results) + { + const std::string who = result.who(); + auto i = combined.find(who); + if(i == combined.end()) + { + combined[who] = Test::Result(who); + i = combined.find(who); + } + + i->second.merge(result); + } + + for(auto&& result : combined) + { + out << result.second.result_string(verbose()); + tests_failed += result.second.tests_failed(); + tests_ran += result.second.tests_run(); + } + + return out.str(); + } + + size_t run_tests(const std::vector& tests_to_run, std::ostream& out, size_t threads) diff --git a/src/tests/test_kdf.cpp b/src/tests/test_kdf.cpp index d9a172bad..ccf742edd 100644 --- a/src/tests/test_kdf.cpp +++ b/src/tests/test_kdf.cpp @@ -26,7 +26,8 @@ class KDF_KAT_Tests : public Text_Based_Test Test::Result run_one_test(const std::string& kdf_name, const VarMap& vars) { Test::Result result(kdf_name); - std::unique_ptr kdf(Botan::get_kdf(kdf_name)); + + std::unique_ptr kdf(Botan::KDF::create(kdf_name)); if(!kdf) { diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp index 111622dab..35a1e01dc 100644 --- a/src/tests/tests.cpp +++ b/src/tests/tests.cpp @@ -305,9 +305,13 @@ std::string format_time(uint64_t ns) } -std::string Test::Result::result_string() const +std::string Test::Result::result_string(bool verbose) const { + if(tests_run() == 0 && !verbose) + return ""; + std::ostringstream report; + report << who() << " ran "; if(tests_run() == 0) diff --git a/src/tests/tests.h b/src/tests/tests.h index 71b839363..74b6de08e 100644 --- a/src/tests/tests.h +++ b/src/tests/tests.h @@ -69,7 +69,7 @@ class Test bool any_results() const { return tests_run() > 0; } const std::string& who() const { return m_who; } - std::string result_string() const; + std::string result_string(bool verbose) const; static Result Failure(const std::string& who, const std::string& what) -- cgit v1.2.3