diff --git a/tests/perf/common/test_harness_macros.h b/tests/perf/common/test_harness_macros.h index 28a15f4bd6..8cfff8408a 100644 --- a/tests/perf/common/test_harness_macros.h +++ b/tests/perf/common/test_harness_macros.h @@ -47,6 +47,8 @@ #include "test_harness_base.h" #include +#include + namespace vt { namespace tests { namespace perf { namespace common { /** @@ -70,36 +72,40 @@ namespace vt { namespace tests { namespace perf { namespace common { struct PerfTestRegistry{ - static void AddTest(TestHarnessBase* test){ - tests_.push_back(test); + static void AddTest(std::unique_ptr&& test) { + tests_.push_back(std::move(test)); } - static const std::vector& - GetTests(){ + static const std::vector>& + GetTests() { return tests_; } private: - inline static std::vector tests_ = {}; + inline static std::vector> tests_ = {}; }; -#define VT_PERF_TEST(StructName, TestName) \ - struct StructName##TestName : StructName { \ - StructName##TestName() { \ - name_ = #TestName; } \ - void SetUp() override { StructName::SetUp(); } \ - void TearDown() override { StructName::TearDown(); } \ - void TestFunc() override; \ - }; \ - \ - static struct StructName##TestName##_registerer_t { \ - StructName##TestName##_registerer_t() { \ - PerfTestRegistry::AddTest(new StructName##TestName());\ - } \ - } StructName##TestName##_registerer; \ +#define VT_PERF_TEST(StructName, TestName) \ + struct StructName##TestName : StructName { \ + StructName##TestName() { \ + name_ = #TestName; \ + } \ + void SetUp() override { \ + StructName::SetUp(); \ + } \ + void TearDown() override { \ + StructName::TearDown(); \ + } \ + void TestFunc() override; \ + }; \ + \ + static struct StructName##TestName##_registerer_t { \ + StructName##TestName##_registerer_t() { \ + PerfTestRegistry::AddTest(std::make_unique()); \ + } \ + } StructName##TestName##_registerer; \ void StructName##TestName::TestFunc() - #define VT_PERF_TEST_MAIN() \ int main(int argc, char** argv) { \ using namespace vt::tests::perf::common; \ @@ -107,7 +113,7 @@ struct PerfTestRegistry{ int rank; \ MPI_Comm_rank(MPI_COMM_WORLD, &rank); \ for (const auto& test_base : PerfTestRegistry::GetTests()) { \ - auto* test = dynamic_cast(test_base); \ + auto* test = dynamic_cast(test_base.get()); \ test->Initialize(argc, argv); \ auto const num_runs = test->GetNumRuns(); \ StopWatch timer; \