From 926ef40535852f20368e9980b909f354e661b5ff Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Mon, 28 Jan 2019 19:07:25 -0500 Subject: Run the test suite in multiple threads Refactor areas where data was being shared --- src/tests/tests.cpp | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'src/tests/tests.cpp') diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp index 2300dfaea..6b44bccd9 100644 --- a/src/tests/tests.cpp +++ b/src/tests/tests.cpp @@ -29,18 +29,6 @@ namespace Botan_Tests { -Test::Registration::Registration(const std::string& name, Test* test) - { - if(Test::global_registry().count(name) == 0) - { - Test::global_registry().insert(std::make_pair(name, std::unique_ptr(test))); - } - else - { - throw Test_Error("Duplicate registration of test '" + name + "'"); - } - } - void Test::Result::merge(const Result& other) { if(who() != other.who()) @@ -484,9 +472,9 @@ std::string Test::Result::result_string() const // static Test:: functions //static -std::map>& Test::global_registry() +std::map>& Test::global_registry() { - static std::map> g_test_registry; + static std::map> g_test_registry; return g_test_registry; } @@ -504,12 +492,12 @@ std::set Test::registered_tests() } //static -Test* Test::get_test(const std::string& test_name) +std::unique_ptr Test::get_test(const std::string& test_name) { auto i = Test::global_registry().find(test_name); if(i != Test::global_registry().end()) { - return i->second.get(); + return std::unique_ptr(i->second()); } return nullptr; } @@ -596,6 +584,14 @@ void Test::set_test_options(const Test_Options& opts) //static void Test::set_test_rng(std::unique_ptr rng) { +#if defined(BOTAN_TARGET_OS_HAS_THREADS) + if(m_opts.test_threads() != 1) + { + m_test_rng.reset(new Botan::Serialized_RNG(rng.release())); + return; + } +#endif + m_test_rng.reset(rng.release()); } -- cgit v1.2.3