Skip to content

Commit 9a313e7

Browse files
committed
acl_hal_test: use acl_test_setenv() and acl_test_unsetenv()
Signed-off-by: Peter Colberg <[email protected]>
1 parent c5a738b commit 9a313e7

File tree

1 file changed

+6
-30
lines changed

1 file changed

+6
-30
lines changed

test/acl_hal_test.cpp

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -301,13 +301,8 @@ TEST(acl_hal, debugging) {
301301
const char test_str[] = "hal debug printf test\n";
302302
CHECK(acl_set_hal(&simple_hal));
303303
const acl_hal_t *hal = acl_get_hal();
304-
char env[] = "ACL_DEBUG=0";
305304

306-
#ifdef _WIN32
307-
_putenv(env);
308-
#else
309-
putenv(env);
310-
#endif
305+
acl_test_setenv("ACL_DEBUG", "0");
311306
char *acl_debug_env = getenv("ACL_DEBUG");
312307
CHECK(acl_debug_env);
313308
debug_mode = atoi(acl_debug_env);
@@ -318,32 +313,17 @@ TEST(acl_hal, debugging) {
318313
CHECK_EQUAL(0, acl_print_debug_msg(""));
319314

320315
// Now start debugging.
321-
env[10] = '4';
322-
#ifdef _WIN32
323-
_putenv(env);
324-
#else
325-
putenv(env);
326-
#endif
316+
acl_test_setenv("ACL_DEBUG", "4");
327317
acl_debug_env = getenv("ACL_DEBUG");
328318
CHECK(acl_debug_env);
329319
debug_mode = atoi(acl_debug_env);
330320
CHECK_EQUAL(4, debug_mode);
331-
env[10] = '3';
332-
#ifdef _WIN32
333-
_putenv(env);
334-
#else
335-
putenv(env);
336-
#endif
321+
acl_test_setenv("ACL_DEBUG", "3");
337322
acl_debug_env = getenv("ACL_DEBUG");
338323
CHECK(acl_debug_env);
339324
debug_mode = atoi(acl_debug_env);
340325
CHECK_EQUAL(3, debug_mode);
341-
env[10] = '2';
342-
#ifdef _WIN32
343-
_putenv(env);
344-
#else
345-
putenv(env);
346-
#endif
326+
acl_test_setenv("ACL_DEBUG", "2");
347327
acl_debug_env = getenv("ACL_DEBUG");
348328
CHECK(acl_debug_env);
349329
debug_mode = atoi(acl_debug_env);
@@ -353,17 +333,13 @@ TEST(acl_hal, debugging) {
353333
acl_print_debug_msg(test_str)); // -1 because source array includes a NUL
354334
// char, but we don't print it.
355335
CHECK_EQUAL(0, acl_print_debug_msg(""));
356-
env[10] = '0';
357-
#ifdef _WIN32
358-
_putenv(env);
359-
#else
360-
putenv(env);
361-
#endif
336+
acl_test_setenv("ACL_DEBUG", "0");
362337
acl_debug_env = getenv("ACL_DEBUG");
363338
CHECK(acl_debug_env);
364339
debug_mode = atoi(acl_debug_env);
365340
CHECK_EQUAL(0, debug_mode);
366341
CHECK_EQUAL(0, acl_print_debug_msg(test_str));
342+
acl_test_unsetenv("ACL_DEBUG");
367343

368344
cl_int temp;
369345
CHECK_EQUAL(1, hal->query_temperature(0, &temp));

0 commit comments

Comments
 (0)