@@ -50,15 +50,8 @@ MT_TEST_GROUP(acl_profile) {
50
50
enum { MAX_DEVICES = 100 , m_num_devices_in_context = 3 };
51
51
void setup () {
52
52
if (threadNum () == 0 ) {
53
- static char profile_runtime_env_var[] = " ACL_RUNTIME_PROFILING_ACTIVE=1" ;
54
- static char profiler_timer_env_var[] = " ACL_PROFILE_TIMER=1" ;
55
- #ifdef _WIN32
56
- _putenv (profile_runtime_env_var);
57
- _putenv (profiler_timer_env_var);
58
- #else // Linux
59
- putenv (profile_runtime_env_var);
60
- putenv (profiler_timer_env_var);
61
- #endif
53
+ acl_test_setenv (" ACL_RUNTIME_PROFILING_ACTIVE" , " 1" );
54
+ acl_test_setenv (" ACL_PROFILE_TIMER" , " 1" );
62
55
acl_test_setup_generic_system ();
63
56
acl_dot_push (&m_devlog, &acl_platform.device_op_queue );
64
57
@@ -71,6 +64,8 @@ MT_TEST_GROUP(acl_profile) {
71
64
void teardown () {
72
65
syncThreads ();
73
66
if (threadNum () == 0 ) {
67
+ acl_test_unsetenv (" ACL_RUNTIME_PROFILING_ACTIVE" );
68
+ acl_test_unsetenv (" ACL_PROFILE_TIMER" );
74
69
this ->unload_program (m_program);
75
70
this ->unload ();
76
71
acl_test_teardown_generic_system ();
@@ -449,63 +444,35 @@ TEST(acl_profile, valid_checks) {
449
444
}
450
445
451
446
TEST (acl_profile, shared_counter_checks) {
452
- const std::string env_name = " ACL_INTERAL_SHARED_CONTROL_SETTING" ;
453
- #ifdef _WIN32
454
- _putenv ((env_name + " =" ).c_str ());
455
- #else // Linux
456
- unsetenv (env_name.c_str ());
457
- #endif
447
+ acl_test_unsetenv (" ACL_INTERAL_SHARED_CONTROL_SETTING" );
458
448
set_env_shared_counter_val ();
459
449
CHECK_EQUAL (-1 , get_env_profile_shared_counter_val ());
460
450
461
451
for (int i = 0 ; i < 4 ; i++) {
462
452
const std::string env_value = std::to_string (i);
463
- #ifdef _WIN32
464
- _putenv ((env_name + " =" + env_value).c_str ());
465
- #else // Linux
466
- setenv (env_name.c_str (), env_value.c_str (), 1 );
467
- #endif
453
+ acl_test_setenv (" ACL_INTERAL_SHARED_CONTROL_SETTING" , env_value.c_str ());
468
454
set_env_shared_counter_val ();
469
455
CHECK_EQUAL (i, get_env_profile_shared_counter_val ());
470
456
}
457
+
458
+ acl_test_unsetenv (" ACL_INTERAL_SHARED_CONTROL_SETTING" );
471
459
}
472
460
473
461
TEST (acl_profile, init_profiler) {
474
- char profiling_runtime_invalid_value[] = " ACL_RUNTIME_PROFILING_ACTIVE=2" ;
475
- char profiling_timer_invalid_value[] = " ACL_PROFILE_TIMER=2" ;
476
- #ifdef _WIN32
477
- _putenv (profiling_runtime_invalid_value);
478
- _putenv (profiling_timer_invalid_value);
479
- #else // Linux
480
- putenv (profiling_runtime_invalid_value);
481
- putenv (profiling_timer_invalid_value);
482
- #endif
462
+ acl_test_setenv (" ACL_RUNTIME_PROFILING_ACTIVE" , " 2" );
463
+ acl_test_setenv (" ACL_PROFILE_TIMER" , " 2" );
483
464
ACL_LOCKED (acl_init_profiler ());
484
465
CHECK (!is_profile_enabled ());
485
466
CHECK (!is_profile_timer_on ());
486
467
487
- char profiling_runtime_enabled[] = " ACL_RUNTIME_PROFILING_ACTIVE=1" ;
488
- char profiling_timer_enabled[] = " ACL_PROFILE_TIMER=1" ;
489
- #ifdef _WIN32
490
- _putenv (profiling_runtime_enabled);
491
- _putenv (profiling_timer_enabled);
492
- #else // Linux
493
- putenv (profiling_runtime_enabled);
494
- putenv (profiling_timer_enabled);
495
- #endif
468
+ acl_test_setenv (" ACL_RUNTIME_PROFILING_ACTIVE" , " 1" );
469
+ acl_test_setenv (" ACL_PROFILE_TIMER" , " 1" );
496
470
ACL_LOCKED (acl_init_profiler ());
497
471
CHECK (is_profile_enabled ());
498
472
CHECK (is_profile_timer_on ());
499
473
500
- char profiling_runtime_disabled[] = " ACL_RUNTIME_PROFILING_ACTIVE=" ;
501
- char profiling_timer_disabled[] = " ACL_PROFILE_TIMER=" ;
502
- #ifdef _WIN32
503
- _putenv (profiling_runtime_disabled);
504
- _putenv (profiling_timer_disabled);
505
- #else // Linux
506
- putenv (profiling_runtime_disabled);
507
- putenv (profiling_timer_disabled);
508
- #endif
474
+ acl_test_unsetenv (" ACL_RUNTIME_PROFILING_ACTIVE" );
475
+ acl_test_unsetenv (" ACL_PROFILE_TIMER" );
509
476
ACL_LOCKED (acl_init_profiler ());
510
477
CHECK (!is_profile_enabled ());
511
478
CHECK (!is_profile_timer_on ());
@@ -646,14 +613,6 @@ MT_TEST_GROUP(acl_no_profile) {
646
613
if (threadNum () == 0 ) {
647
614
remove (PROFILE_MON);
648
615
649
- #ifdef _WIN32
650
- char profile_runtime_env_var[] = " ACL_RUNTIME_PROFILING_ACTIVE=" ;
651
- _putenv (profile_runtime_env_var);
652
- #else // Linux
653
- char profile_runtime_env_var[] = " ACL_RUNTIME_PROFILING_ACTIVE" ;
654
- unsetenv (profile_runtime_env_var);
655
- #endif
656
-
657
616
acl_test_setup_generic_system ();
658
617
659
618
this ->load ();
0 commit comments