Skip to content

Commit d3d1eef

Browse files
fix: Disable metrics env variable for metric Enable Disable tests. (#266)
* fix: Disable metrics env variable for metric Enable Disable tests. Related to NEO-15708 Signed-off-by: Shreyas Kunder <[email protected]>
1 parent 82599d4 commit d3d1eef

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

conformance_tests/tools/metrics/src/test_metric_enable_main.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ int main(int argc, char **argv) {
1515
std::vector<std::string> command_line(argv + 1, argv + argc);
1616
level_zero_tests::init_logging(command_line);
1717

18+
const std::string var_enable_metrics = "ZET_ENABLE_METRICS";
19+
const char *env_value = std::getenv(var_enable_metrics.c_str());
20+
if (env_value != nullptr) {
21+
LOG_INFO << "ZET_ENABLE_METRICS=1 is Set. Disabling.";
22+
#if defined(_WIN32) || defined(_WIN64)
23+
_putenv_s(var_enable_metrics.c_str(), "0");
24+
#else
25+
setenv(var_enable_metrics.c_str(), "0", 1) == 0;
26+
#endif
27+
}
28+
1829
ze_result_t result = zeInit(0);
1930
if (result) {
2031
throw std::runtime_error("zeInit failed: " +
@@ -23,5 +34,16 @@ int main(int argc, char **argv) {
2334
LOG_TRACE << "Driver initialized";
2435

2536
LOG_TRACE << "Tools API initialized";
26-
return RUN_ALL_TESTS();
37+
int return_val = RUN_ALL_TESTS();
38+
39+
if (env_value != nullptr) {
40+
LOG_INFO << "Re-enabling ZET_ENABLE_METRICS=1";
41+
#if defined(_WIN32) || defined(_WIN64)
42+
_putenv_s(var_enable_metrics.c_str(), "1");
43+
#else
44+
setenv(var_enable_metrics.c_str(), "1", 1) == 0;
45+
#endif
46+
}
47+
48+
return return_val;
2749
}

0 commit comments

Comments
 (0)