From: Li Wang via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3 2/2] lib: Extend LTP_ENABLE_DEBUG to support verbosity levels
Date: Wed, 4 Mar 2026 11:40:34 +0800 [thread overview]
Message-ID: <20260304034034.59303-2-liwang@redhat.com> (raw)
In-Reply-To: <20260304034034.59303-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 (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.
And, command-line should take precedence over environment variables when
set both.
Signed-off-by: Li Wang <liwang@redhat.com>
---
Notes:
v2 --> v3:
* Command-line -D take precedence over environment variables.
doc/developers/debugging.rst | 2 +-
lib/newlib_tests/tst_res_flags.c | 2 +-
lib/tst_test.c | 15 +++++++++++----
3 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/doc/developers/debugging.rst b/doc/developers/debugging.rst
index dcb287bb6..86050aa86 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[1,2]`` parameter or setting ``LTP_ENABLE_DEBUG=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..21637a472 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[1,2] or LTP_ENABLE_DEBUG=1,2)"},
};
static void do_cleanup(void)
diff --git a/lib/tst_test.c b/lib/tst_test.c
index e01c14638..669d43768 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 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");
@@ -1445,9 +1445,16 @@ 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 && !context->tdebug) {
+ 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);
+
+ if (context->tdebug)
+ 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-04 3:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-04 3:40 [LTP] [PATCH v3 1/2] lib: Extend -D flag to support multiple debug levels Li Wang via ltp
2026-03-04 3:40 ` Li Wang via ltp [this message]
2026-03-04 9:20 ` [LTP] [PATCH v3 2/2] lib: Extend LTP_ENABLE_DEBUG to support verbosity levels Andrea Cervesato via ltp
2026-03-04 9:19 ` [LTP] [PATCH v3 1/2] lib: Extend -D flag to support multiple debug levels Andrea Cervesato via ltp
2026-03-05 1:22 ` 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=20260304034034.59303-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