Skip to content

Commit

Permalink
#2270: Fix ASAN error when running perf tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobDomagala committed Apr 17, 2024
1 parent 084c6c3 commit 2afdc00
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions tests/perf/common/test_harness_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
#include "test_harness_base.h"

#include <vector>
#include <memory>

namespace vt { namespace tests { namespace perf { namespace common {

/**
Expand All @@ -70,44 +72,48 @@ 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<TestHarnessBase>&& test) {
tests_.push_back(std::move(test));
}

static const std::vector<TestHarnessBase*>&
GetTests(){
static const std::vector<std::unique_ptr<TestHarnessBase>>&
GetTests() {
return tests_;
}

private:
inline static std::vector<TestHarnessBase*> tests_ = {};
inline static std::vector<std::unique_ptr<TestHarnessBase>> 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>()); \
} \
} StructName##TestName##_registerer; \
void StructName##TestName::TestFunc()


#define VT_PERF_TEST_MAIN() \
int main(int argc, char** argv) { \
using namespace vt::tests::perf::common; \
MPI_Init(&argc, &argv); \
int rank; \
MPI_Comm_rank(MPI_COMM_WORLD, &rank); \
for (const auto& test_base : PerfTestRegistry::GetTests()) { \
auto* test = dynamic_cast<PerfTestHarness*>(test_base); \
auto* test = dynamic_cast<PerfTestHarness*>(test_base.get()); \
test->Initialize(argc, argv); \
auto const num_runs = test->GetNumRuns(); \
StopWatch timer; \
Expand Down

0 comments on commit 2afdc00

Please sign in to comment.