@@ -15,6 +15,17 @@ int main(int argc, char **argv) {
15
15
std::vector<std::string> command_line (argv + 1 , argv + argc);
16
16
level_zero_tests::init_logging (command_line);
17
17
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
+
18
29
ze_result_t result = zeInit (0 );
19
30
if (result) {
20
31
throw std::runtime_error (" zeInit failed: " +
@@ -23,5 +34,16 @@ int main(int argc, char **argv) {
23
34
LOG_TRACE << " Driver initialized" ;
24
35
25
36
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;
27
49
}
0 commit comments