[LTP] [PATCH v2 2/2] lib: Extend LTP_ENABLE_DEBUG to support verbosity levels
Li Wang
liwang@redhat.com
Tue Mar 3 04:23:11 CET 2026
Following the introduction of verbosity levels for the `-D` command line
flag, this patch extends the `LTP_ENABLE_DEBUG` environment variable to
support the same levels (0, 1, and 2).
Previously, `LTP_ENABLE_DEBUG` acted as a simple boolean toggle. It now
mirrors the behavior of `-D`, allowing developers to specify the exact
level of debug verbosity required from the environment.
Signed-off-by: Li Wang <liwang@redhat.com>
---
doc/developers/debugging.rst | 2 +-
lib/newlib_tests/tst_res_flags.c | 2 +-
lib/tst_test.c | 16 ++++++++++++----
3 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/doc/developers/debugging.rst b/doc/developers/debugging.rst
index 8b5550b73..741924f0b 100644
--- a/doc/developers/debugging.rst
+++ b/doc/developers/debugging.rst
@@ -9,7 +9,7 @@ Debug messages
--------------
The LTP framework supports ``TDEBUG`` flag test debug messages. These
-messages can be enabled using the ``-D`` parameter or setting ``LTP_ENABLE_DEBUG=1``
+messages can be enabled using the ``-D[0-2]`` parameter or setting ``LTP_ENABLE_DEBUG=0,1,2``
environment variable (see :doc:`../users/setup_tests`).
The ``-D`` parameter also supports the following verbosity levels:
diff --git a/lib/newlib_tests/tst_res_flags.c b/lib/newlib_tests/tst_res_flags.c
index a14f0df2c..83477fc98 100644
--- a/lib/newlib_tests/tst_res_flags.c
+++ b/lib/newlib_tests/tst_res_flags.c
@@ -21,7 +21,7 @@ static struct tcase {
{FLAG(TCONF)},
{FLAG(TWARN)},
{FLAG(TINFO)},
- {FLAG(TDEBUG), " (printed only with -D or LTP_ENABLE_DEBUG=1)"},
+ {FLAG(TDEBUG), " (printed only with -D[0-2] or LTP_ENABLE_DEBUG=0,1,2)"},
};
static void do_cleanup(void)
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 3b21a8639..2dc3704c4 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -675,7 +675,7 @@ static void print_help(void)
fprintf(stderr, "LTP_COLORIZE_OUTPUT Force colorized output behaviour (y/1 always, n/0: never)\n");
fprintf(stderr, "LTP_DEV Path to the block device to be used (for .needs_device)\n");
fprintf(stderr, "LTP_DEV_FS_TYPE Filesystem used for testing (default: %s)\n", DEFAULT_FS_TYPE);
- fprintf(stderr, "LTP_ENABLE_DEBUG Print debug messages (set 1 or y)\n");
+ fprintf(stderr, "LTP_ENABLE_DEBUG Print debug messages (set 0, 1 (y) or 2)\n");
fprintf(stderr, "LTP_REPRODUCIBLE_OUTPUT Values 1 or y discard the actual content of the messages printed by the test\n");
fprintf(stderr, "LTP_QUIET Values 1 or y will suppress printing TCONF, TWARN, TINFO, and TDEBUG messages\n");
fprintf(stderr, "LTP_SINGLE_FS_TYPE Specifies filesystem instead all supported (for .all_filesystems)\n");
@@ -1444,9 +1444,17 @@ static void do_setup(int argc, char *argv[])
parse_opts(argc, argv);
- if (tdebug_env && (!strcmp(tdebug_env, "1") || !strcmp(tdebug_env, "y"))) {
- tst_res(TINFO, "Enabling debug info");
- context->tdebug = 1;
+ if (tdebug_env) {
+ if (!strcmp(tdebug_env, "0"))
+ context->tdebug = 0;
+ else if (!strcmp(tdebug_env, "2"))
+ context->tdebug = 2;
+ else if (!strcmp(tdebug_env, "1") || !strcmp(tdebug_env, "y"))
+ context->tdebug = 1;
+ else
+ tst_res(TWARN, "Invalid LTP_ENABLE_DEBUG value: %s", tdebug_env);
+
+ tst_res(TINFO, "Enabling debug info (level %d)", context->tdebug);
}
if (tst_test->needs_kconfigs && tst_kconfig_check(tst_test->needs_kconfigs))
--
2.53.0
More information about the ltp
mailing list