From: Li Wang via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 2/2] lib: Extend LTP_ENABLE_DEBUG to support verbosity levels
Date: Tue, 3 Mar 2026 11:23:11 +0800 [thread overview]
Message-ID: <20260303032311.38988-2-liwang@redhat.com> (raw)
In-Reply-To: <20260303032311.38988-1-liwang@redhat.com>
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-03-03 3:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-03 3:23 [LTP] [PATCH v2 1/2] lib: Extend -D flag to support multiple debug levels Li Wang via ltp
2026-03-03 3:23 ` Li Wang via ltp [this message]
2026-03-03 10:28 ` [LTP] [PATCH v2 2/2] lib: Extend LTP_ENABLE_DEBUG to support verbosity levels Andrea Cervesato via ltp
2026-03-03 14:02 ` Li Wang via ltp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260303032311.38988-2-liwang@redhat.com \
--to=ltp@lists.linux.it \
--cc=liwang@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox