diff --git a/src/amd/compiler/tests/framework.h b/src/amd/compiler/tests/framework.h index fd239e0045d..33180c4f775 100644 --- a/src/amd/compiler/tests/framework.h +++ b/src/amd/compiler/tests/framework.h @@ -22,7 +22,7 @@ struct TestDef { void (*func)(); }; -extern std::map tests; +extern std::map *tests; extern FILE* output; bool set_variant(const char* name); @@ -46,7 +46,9 @@ void skip_test(const char* fmt, ...); static void struct_name(); \ static __attribute__((constructor)) void CONCAT2(add_test_, __COUNTER__)() \ { \ - tests[#name] = (TestDef){#name, ACO_TEST_BUILD_ROOT "/" __FILE__, &struct_name}; \ + if (!tests) \ + tests = new std::map; \ + (*tests)[#name] = (TestDef){#name, ACO_TEST_BUILD_ROOT "/" __FILE__, &struct_name}; \ } \ static void struct_name() \ { diff --git a/src/amd/compiler/tests/main.cpp b/src/amd/compiler/tests/main.cpp index 29afa166181..5685bfb7ef3 100644 --- a/src/amd/compiler/tests/main.cpp +++ b/src/amd/compiler/tests/main.cpp @@ -33,7 +33,7 @@ static const char* help_message = " -l --list List unit tests.\n" " --no-check Print test output instead of checking it.\n"; -std::map tests; +std::map *tests = NULL; FILE* output = NULL; static TestDef current_test; @@ -225,8 +225,11 @@ main(int argc, char** argv) return 99; } + if (!tests) + tests = new std::map; + if (do_list) { - for (auto test : tests) + for (auto test : *tests) printf("%s\n", test.first.c_str()); return 99; } @@ -253,7 +256,7 @@ main(int argc, char** argv) aco::init(); - for (auto pair : tests) { + for (auto pair : *tests) { bool found = names.empty(); bool all_variants = names.empty(); std::set variants;