aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/tests.h
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-01-28 19:07:25 -0500
committerJack Lloyd <[email protected]>2019-01-31 11:07:59 -0500
commit926ef40535852f20368e9980b909f354e661b5ff (patch)
tree24c2dd6978b9047d0a5adbd59cb4520771f0cdb7 /src/tests/tests.h
parent55c7751b1eee10b5d850a500dd000cbe81d88942 (diff)
Run the test suite in multiple threads
Refactor areas where data was being shared
Diffstat (limited to 'src/tests/tests.h')
-rw-r--r--src/tests/tests.h31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/tests/tests.h b/src/tests/tests.h
index 93e972900..4bf9fb0db 100644
--- a/src/tests/tests.h
+++ b/src/tests/tests.h
@@ -60,6 +60,7 @@ class Test_Options
const std::string& provider,
const std::string& drbg_seed,
size_t test_runs,
+ size_t test_threads,
bool verbose,
bool log_success,
bool run_online_tests,
@@ -73,6 +74,7 @@ class Test_Options
m_provider(provider),
m_drbg_seed(drbg_seed),
m_test_runs(test_runs),
+ m_test_threads(test_threads),
m_verbose(verbose),
m_log_success(log_success),
m_run_online_tests(run_online_tests),
@@ -98,6 +100,8 @@ class Test_Options
size_t test_runs() const { return m_test_runs; }
+ size_t test_threads() const { return m_test_threads; }
+
bool log_success() const { return m_log_success; }
bool run_online_tests() const { return m_run_online_tests; }
@@ -126,6 +130,7 @@ class Test_Options
std::string m_provider;
std::string m_drbg_seed;
size_t m_test_runs;
+ size_t m_test_threads;
bool m_verbose;
bool m_log_success;
bool m_run_online_tests;
@@ -436,22 +441,30 @@ class Test
std::vector<std::string> m_log;
};
- class Registration final
- {
- public:
- Registration(const std::string& name, Test* test);
- };
-
virtual ~Test() = default;
virtual std::vector<Test::Result> run() = 0;
virtual std::vector<std::string> possible_providers(const std::string&);
- static std::map<std::string, std::unique_ptr<Test>>& global_registry();
+ template<typename Test_Class>
+ class Registration
+ {
+ public:
+ Registration(const std::string& name)
+ {
+ if(Test::global_registry().count(name) != 0)
+ throw Test_Error("Duplicate registration of test '" + name + "'");
+
+ auto maker = []() -> Test* { return new Test_Class; };
+ Test::global_registry().insert(std::make_pair(name, maker));
+ }
+ };
+
+ static std::map<std::string, std::function<Test* ()>>& global_registry();
static std::set<std::string> registered_tests();
- static Test* get_test(const std::string& test_name);
+ static std::unique_ptr<Test> get_test(const std::string& test_name);
static std::string data_file(const std::string& what);
@@ -515,7 +528,7 @@ class Test
* Register the test with the runner
*/
#define BOTAN_REGISTER_TEST(type, Test_Class) \
- Test::Registration reg_ ## Test_Class ## _tests(type, new Test_Class)
+ Test::Registration<Test_Class> reg_ ## Test_Class ## _tests(type)
class VarMap
{