From cd50cd73750d527a5d48aa097bdcfbe874b7baea Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Mon, 23 Mar 2026 14:31:49 +0000 Subject: [PATCH 1/6] DAOS-18595 gurt: Handle "ERR" and "DBUG" environment values with DD_STDERR Previously, the DD_STDERR environment variable did not support the same set of values as DD_LOG_MASK. This patch updates the management of DD_STDERR to ensure consistent value handling between both environment variables. Signed-off-by: Cedric Koch-Hofer --- src/gurt/debug.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/gurt/debug.c b/src/gurt/debug.c index 50f765d35bb..06c5d05dfef 100644 --- a/src/gurt/debug.c +++ b/src/gurt/debug.c @@ -1,6 +1,6 @@ /* * (C) Copyright 2016-2022 Intel Corporation. - * (C) Copyright 2025 Hewlett Packard Enterprise Development LP + * (C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP * * SPDX-License-Identifier: BSD-2-Clause-Patent */ @@ -385,6 +385,17 @@ debug_prio_err_load_env(void) if (env == NULL) return; + /* handle some quirks */ + if (strncasecmp(env, "ERR", sizeof("ERR")) == 0) { + d_dbglog_data.dd_prio_err = DLOG_ERR; + goto out_env; + } + if (strncasecmp(env, "DBUG", sizeof("DBUG")) == 0) { + d_dbglog_data.dd_prio_err = DLOG_DBG; + goto out_env; + } + + d_dbglog_data.dd_prio_err = 0; for (i = 0; i < NUM_DBG_PRIO_ENTRIES; i++) { if (d_dbg_prio_dict[i].dd_name != NULL && strncasecmp(env, d_dbg_prio_dict[i].dd_name, @@ -396,6 +407,8 @@ debug_prio_err_load_env(void) /* invalid DD_STDERR option */ if (d_dbglog_data.dd_prio_err == 0) D_PRINT_ERR("DD_STDERR = %s - invalid option\n", env); + +out_env: d_freeenv_str(&env); } From f7dcb80cfd48b3da15c7ba7ad6d8b03d993517bb Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Fri, 24 Apr 2026 09:45:27 +0000 Subject: [PATCH 2/6] DAOS-18595 gurt: Fix reviewers comments - Update comment messages - Replace ERR with ERROR Signed-off-by: Cedric Koch-Hofer --- src/gurt/debug.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gurt/debug.c b/src/gurt/debug.c index 06c5d05dfef..546fd522a2a 100644 --- a/src/gurt/debug.c +++ b/src/gurt/debug.c @@ -385,11 +385,12 @@ debug_prio_err_load_env(void) if (env == NULL) return; - /* handle some quirks */ - if (strncasecmp(env, "ERR", sizeof("ERR")) == 0) { + /* ERROR can be used as an alias for ERR */ + if (strncasecmp(env, "ERROR", sizeof("ERROR")) == 0) { d_dbglog_data.dd_prio_err = DLOG_ERR; goto out_env; } + /* DBUG can be used as an alias for DEBUG */ if (strncasecmp(env, "DBUG", sizeof("DBUG")) == 0) { d_dbglog_data.dd_prio_err = DLOG_DBG; goto out_env; From 6b602eecfd70de6f7ca3a8147ae127d745d3a51c Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Thu, 30 Apr 2026 16:06:26 +0000 Subject: [PATCH 3/6] DAOS-18595 gurt: add DD_STDERR test and filter support Add unit tests for DD_STDERR environment variable parsing, covering standard values, case insensitivity, invalid inputs, and unset behavior. Also add cmocka test filter support via command-line argument when built with cmocka >= 1.1.5. Signed-off-by: Cedric Koch-Hofer --- src/gurt/tests/test_gurt.c | 91 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/src/gurt/tests/test_gurt.c b/src/gurt/tests/test_gurt.c index 762a3a55239..85c89f25179 100644 --- a/src/gurt/tests/test_gurt.c +++ b/src/gurt/tests/test_gurt.c @@ -746,6 +746,89 @@ test_log(void **state) d_log_fini(); } +static void +test_dd_stderr(void **state) +{ + int rc; + int i; + + struct { + const char *env_val; + d_dbug_t expected; + } test_cases[] = { + /* Standard dictionary values */ + {"emit", DLOG_EMIT}, + {"fatal", DLOG_EMERG}, + {"alert", DLOG_ALERT}, + {"crit", DLOG_CRIT}, + {"err", DLOG_ERR}, + {"error", DLOG_ERR}, + {"warn", DLOG_WARN}, + {"note", DLOG_NOTE}, + {"info", DLOG_INFO}, + {"debug", DLOG_DBG}, + {"dbug", DLOG_DBG}, + /* Case insensitivity */ + {"ERR", DLOG_ERR}, + {"Warn", DLOG_WARN}, + {"CRIT", DLOG_CRIT}, + {"Info", DLOG_INFO}, + {"error", DLOG_ERR}, + {"dbug", DLOG_DBG}, + }; + + /* Tear down the log initialized by init_tests */ + d_log_fini(); + + for (i = 0; i < ARRAY_SIZE(test_cases); i++) { + setenv("DD_STDERR", test_cases[i].env_val, 1); + rc = d_log_init(); + assert_int_equal(rc, 0); + assert_int_equal(d_dbglog_data.dd_prio_err, test_cases[i].expected); + d_log_fini(); + } + + /* Test invalid value: dd_prio_err should be 0 */ + setenv("DD_STDERR", "INVALID", 1); + rc = d_log_init(); + assert_int_equal(rc, 0); + assert_int_equal(d_dbglog_data.dd_prio_err, 0); + d_log_fini(); + + /* Test invalid value with valid prefix: dd_prio_err should be 0 */ + setenv("DD_STDERR", "DEBUG_FOO", 1); + rc = d_log_init(); + assert_int_equal(rc, 0); + assert_int_equal(d_dbglog_data.dd_prio_err, 0); + d_log_fini(); + + /* Test invalid value with incomplete name: dd_prio_err should be 0 */ + setenv("DD_STDERR", "DEB", 1); + rc = d_log_init(); + assert_int_equal(rc, 0); + assert_int_equal(d_dbglog_data.dd_prio_err, 0); + d_log_fini(); + + /* Test invalid value with incomplete name: dd_prio_err should be 0 */ + setenv("DD_STDERR", "ERRO", 1); /* codespell:ignore */ + rc = d_log_init(); + assert_int_equal(rc, 0); + assert_int_equal(d_dbglog_data.dd_prio_err, 0); + d_log_fini(); + + /* Test unset: dd_prio_err should remain 0 */ + unsetenv("DD_STDERR"); + rc = d_log_init(); + assert_int_equal(rc, 0); + assert_int_equal(d_dbglog_data.dd_prio_err, 0); + d_log_fini(); + + /* Re-initialize for the group teardown (fini_tests) */ + unsetenv("DD_STDERR"); + rc = d_log_init(); + assert_int_equal(rc, 0); +} + #define TEST_GURT_HASH_NUM_BITS (D_ON_VALGRIND ? 4 : 12) #define TEST_GURT_HASH_NUM_ENTRIES (1 << TEST_GURT_HASH_NUM_BITS) #define TEST_GURT_HASH_NUM_THREADS (D_ON_VALGRIND ? 4 : 16) @@ -2740,6 +2823,7 @@ main(int argc, char **argv) cmocka_unit_test(test_gurt_hlist), cmocka_unit_test(test_binheap), cmocka_unit_test(test_log), + cmocka_unit_test(test_dd_stderr), cmocka_unit_test(test_gurt_hash_empty), cmocka_unit_test(test_gurt_hash_insert_lookup_delete), cmocka_unit_test(test_gurt_hash_decref), @@ -2772,5 +2856,12 @@ main(int argc, char **argv) d_register_alt_assert(mock_assert); +#if CMOCKA_FILTER_SUPPORTED == 1 /** requires cmocka 1.1.5 */ + if (argc > 1) + cmocka_set_test_filter(argv[1]); +#else + printf("Test filtering disabled at compile time.\n"); +#endif + return cmocka_run_group_tests_name("test_gurt", tests, init_tests, fini_tests); } From 617eded3aa7d4afc3404603b6810d5115f71f533 Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Mon, 4 May 2026 07:23:44 +0000 Subject: [PATCH 4/6] DAOS-18595 gurt: fix clan formatting issues Remove extra tabs in variable declarations and struct member definitions in test_dd_stderr function to align with consistent spacing style. Signed-off-by: Cedric Koch-Hofer --- src/gurt/tests/test_gurt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gurt/tests/test_gurt.c b/src/gurt/tests/test_gurt.c index 85c89f25179..cff8d6eaf23 100644 --- a/src/gurt/tests/test_gurt.c +++ b/src/gurt/tests/test_gurt.c @@ -749,12 +749,12 @@ test_log(void **state) static void test_dd_stderr(void **state) { - int rc; - int i; + int rc; + int i; struct { - const char *env_val; - d_dbug_t expected; + const char *env_val; + d_dbug_t expected; } test_cases[] = { /* Standard dictionary values */ {"emit", DLOG_EMIT}, From 7f07137e1abe655910db8d2f08e7bc5e5d261e7f Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Mon, 4 May 2026 07:52:02 +0000 Subject: [PATCH 5/6] DAOS-18595 gurt: fix clang format issue Replace tab-aligned columns with consistent 4-space indentation in the test_dd_stderr test case array. Signed-off-by: Cedric Koch-Hofer --- src/gurt/tests/test_gurt.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/gurt/tests/test_gurt.c b/src/gurt/tests/test_gurt.c index cff8d6eaf23..c92b5259035 100644 --- a/src/gurt/tests/test_gurt.c +++ b/src/gurt/tests/test_gurt.c @@ -756,25 +756,25 @@ test_dd_stderr(void **state) const char *env_val; d_dbug_t expected; } test_cases[] = { - /* Standard dictionary values */ - {"emit", DLOG_EMIT}, - {"fatal", DLOG_EMERG}, - {"alert", DLOG_ALERT}, - {"crit", DLOG_CRIT}, - {"err", DLOG_ERR}, - {"error", DLOG_ERR}, - {"warn", DLOG_WARN}, - {"note", DLOG_NOTE}, - {"info", DLOG_INFO}, - {"debug", DLOG_DBG}, - {"dbug", DLOG_DBG}, - /* Case insensitivity */ - {"ERR", DLOG_ERR}, - {"Warn", DLOG_WARN}, - {"CRIT", DLOG_CRIT}, - {"Info", DLOG_INFO}, - {"error", DLOG_ERR}, - {"dbug", DLOG_DBG}, + /* Standard dictionary values */ + {"emit", DLOG_EMIT}, + {"fatal", DLOG_EMERG}, + {"alert", DLOG_ALERT}, + {"crit", DLOG_CRIT}, + {"err", DLOG_ERR}, + {"error", DLOG_ERR}, + {"warn", DLOG_WARN}, + {"note", DLOG_NOTE}, + {"info", DLOG_INFO}, + {"debug", DLOG_DBG}, + {"dbug", DLOG_DBG}, + /* Case insensitivity */ + {"ERR", DLOG_ERR}, + {"Warn", DLOG_WARN}, + {"CRIT", DLOG_CRIT}, + {"Info", DLOG_INFO}, + {"error", DLOG_ERR}, + {"dbug", DLOG_DBG}, }; /* Tear down the log initialized by init_tests */ From 31e5732d18684087c777283fdda456e3ee63816f Mon Sep 17 00:00:00 2001 From: Cedric Koch-Hofer Date: Tue, 5 May 2026 14:33:29 +0000 Subject: [PATCH 6/6] DAOS-18595 gurt: update log level string casing in test_dd_stderr Fix reviewers comments: - Fix duplicate cases Signed-off-by: Cedric Koch-Hofer --- src/gurt/tests/test_gurt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gurt/tests/test_gurt.c b/src/gurt/tests/test_gurt.c index c92b5259035..e94a65beb56 100644 --- a/src/gurt/tests/test_gurt.c +++ b/src/gurt/tests/test_gurt.c @@ -773,8 +773,8 @@ test_dd_stderr(void **state) {"Warn", DLOG_WARN}, {"CRIT", DLOG_CRIT}, {"Info", DLOG_INFO}, - {"error", DLOG_ERR}, - {"dbug", DLOG_DBG}, + {"eRRor", DLOG_ERR}, + {"DBUG", DLOG_DBG}, }; /* Tear down the log initialized by init_tests */