* [LTP] [PATCH] lib: Extend -D flag to support multiple debug levels
@ 2026-03-01 1:28 Li Wang via ltp
2026-03-02 9:59 ` Cyril Hrubis
2026-03-02 15:11 ` Andrea Cervesato via ltp
0 siblings, 2 replies; 6+ messages in thread
From: Li Wang via ltp @ 2026-03-01 1:28 UTC (permalink / raw)
To: ltp
This patch extends the LTP debugging framework by introducing multiple
levels of verbosity for the '-D' command line option. Instead of a simple
on/off toggle, it now allows developers to specify whether they want debug
output exclusively from the test process, or from both the test and library
processes.
The supported debug levels are:
-D0 : Disable all debug logs (default behavior)
-D1 (-D): Enable debug logs for the test process only
-D2 : Enable verbose debug logs for both the test and library processes
Signed-off-by: Li Wang <liwang@redhat.com>
---
doc/developers/debugging.rst | 6 ++++++
lib/tst_test.c | 25 +++++++++++++++----------
2 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/doc/developers/debugging.rst b/doc/developers/debugging.rst
index 181e5b096..8b5550b73 100644
--- a/doc/developers/debugging.rst
+++ b/doc/developers/debugging.rst
@@ -12,6 +12,12 @@ The LTP framework supports ``TDEBUG`` flag test debug messages. These
messages can be enabled using the ``-D`` parameter or setting ``LTP_ENABLE_DEBUG=1``
environment variable (see :doc:`../users/setup_tests`).
+The ``-D`` parameter also supports the following verbosity levels:
+
+ ``-D0``: Disable all debug logs (default behavior).
+ ``-D1`` (or ``-D``): Enable debug logs for the test process only.
+ ``-D2``: Enable verbose debug logs for both the test and library processes.
+
Tracing and debugging syscalls
------------------------------
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 239494b6f..f7907223e 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -83,7 +83,7 @@ struct context {
tst_atomic_t abort_flag;
uint32_t mntpoint_mounted:1;
uint32_t ovl_mounted:1;
- uint32_t tdebug:1;
+ uint32_t tdebug;
};
struct results {
@@ -217,7 +217,7 @@ void tst_reinit(void)
tst_max_futexes = (size - offsetof(struct ipc_region, futexes)) / sizeof(futex_t);
if (context->tdebug)
- tst_res(TINFO, "Restored metadata for PID %d", getpid());
+ tst_res(TDEBUG, "Restored metadata for PID %d", getpid());
}
extern char **environ;
@@ -490,19 +490,20 @@ void tst_res_(const char *file, const int lineno, int ttype,
va_list va;
/*
- * Suppress TDEBUG output in these cases:
+ * Control TDEBUG output in these cases:
* 1. No context available (e.g., called before IPC initialization)
- * 2. Called from the library process, unless explicitly enabled
- * 3. Debug output is not enabled (context->tdebug == 0)
+ * 2. Debug output is completely disabled (context->tdebug == 0).
+ * 3. Debug output is only for test process (context->tdebug == 1).
+ * 4. Debug output is enabled for both test and lib processes (context->tdebug == 2).
*/
if (ttype == TDEBUG) {
if (!context)
return;
- if (context->lib_pid == getpid())
+ if (context->tdebug == 0)
return;
- if (!context->tdebug)
+ if (context->tdebug == 1 && context->lib_pid == getpid())
return;
}
@@ -657,7 +658,7 @@ static struct option {
{"h", "-h Prints this help"},
{"i:", "-i n Execute test n times"},
{"I:", "-I x Execute test for n seconds"},
- {"D", "-D Prints debug information"},
+ {"D::", "-D[0-2] Prints debug information"},
{"V", "-V Prints LTP version"},
};
@@ -825,8 +826,12 @@ static void parse_opts(int argc, char *argv[])
tst_brk(TBROK, "Invalid option");
break;
case 'D':
- tst_res(TINFO, "Enabling debug info");
- context->tdebug = 1;
+ if (optarg)
+ context->tdebug = SAFE_STRTOL(optarg, 0, 2);
+ else
+ context->tdebug = 1;
+
+ tst_res(TINFO, "Enabling debug info (level %d)", context->tdebug);
break;
case 'h':
print_help();
--
2.53.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [LTP] [PATCH] lib: Extend -D flag to support multiple debug levels
2026-03-01 1:28 [LTP] [PATCH] lib: Extend -D flag to support multiple debug levels Li Wang via ltp
@ 2026-03-02 9:59 ` Cyril Hrubis
2026-03-02 15:11 ` Andrea Cervesato via ltp
1 sibling, 0 replies; 6+ messages in thread
From: Cyril Hrubis @ 2026-03-02 9:59 UTC (permalink / raw)
To: Li Wang; +Cc: ltp
Hi!
> This patch extends the LTP debugging framework by introducing multiple
> levels of verbosity for the '-D' command line option. Instead of a simple
> on/off toggle, it now allows developers to specify whether they want debug
> output exclusively from the test process, or from both the test and library
> processes.
>
> The supported debug levels are:
> -D0 : Disable all debug logs (default behavior)
> -D1 (-D): Enable debug logs for the test process only
> -D2 : Enable verbose debug logs for both the test and library processes
>
> Signed-off-by: Li Wang <liwang@redhat.com>
> ---
> doc/developers/debugging.rst | 6 ++++++
> lib/tst_test.c | 25 +++++++++++++++----------
> 2 files changed, 21 insertions(+), 10 deletions(-)
>
> diff --git a/doc/developers/debugging.rst b/doc/developers/debugging.rst
> index 181e5b096..8b5550b73 100644
> --- a/doc/developers/debugging.rst
> +++ b/doc/developers/debugging.rst
> @@ -12,6 +12,12 @@ The LTP framework supports ``TDEBUG`` flag test debug messages. These
> messages can be enabled using the ``-D`` parameter or setting ``LTP_ENABLE_DEBUG=1``
> environment variable (see :doc:`../users/setup_tests`).
>
> +The ``-D`` parameter also supports the following verbosity levels:
> +
> + ``-D0``: Disable all debug logs (default behavior).
> + ``-D1`` (or ``-D``): Enable debug logs for the test process only.
> + ``-D2``: Enable verbose debug logs for both the test and library processes.
> +
> Tracing and debugging syscalls
> ------------------------------
>
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index 239494b6f..f7907223e 100644
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -83,7 +83,7 @@ struct context {
> tst_atomic_t abort_flag;
> uint32_t mntpoint_mounted:1;
> uint32_t ovl_mounted:1;
> - uint32_t tdebug:1;
> + uint32_t tdebug;
> };
>
> struct results {
> @@ -217,7 +217,7 @@ void tst_reinit(void)
> tst_max_futexes = (size - offsetof(struct ipc_region, futexes)) / sizeof(futex_t);
>
> if (context->tdebug)
> - tst_res(TINFO, "Restored metadata for PID %d", getpid());
> + tst_res(TDEBUG, "Restored metadata for PID %d", getpid());
I suppose that we do not need the if (context->tdebug) now.
Otherwise it looks good.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [LTP] [PATCH] lib: Extend -D flag to support multiple debug levels
2026-03-01 1:28 [LTP] [PATCH] lib: Extend -D flag to support multiple debug levels Li Wang via ltp
2026-03-02 9:59 ` Cyril Hrubis
@ 2026-03-02 15:11 ` Andrea Cervesato via ltp
2026-03-03 2:45 ` Li Wang via ltp
1 sibling, 1 reply; 6+ messages in thread
From: Andrea Cervesato via ltp @ 2026-03-02 15:11 UTC (permalink / raw)
To: Li Wang via ltp
Maybe we should also apply the same approach to the LTP_ENABLE_DEBUG
environment variables, otherwise we might support only 0/1 while using
it.
WDYT?
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH] lib: Extend -D flag to support multiple debug levels
2026-03-02 15:11 ` Andrea Cervesato via ltp
@ 2026-03-03 2:45 ` Li Wang via ltp
2026-03-03 2:55 ` Li Wang via ltp
0 siblings, 1 reply; 6+ messages in thread
From: Li Wang via ltp @ 2026-03-03 2:45 UTC (permalink / raw)
To: andrea.cervesato; +Cc: Li Wang via ltp
On Mon, Mar 02, 2026 at 03:11:24PM +0000, Andrea Cervesato via ltp wrote:
> Maybe we should also apply the same approach to the LTP_ENABLE_DEBUG
> environment variables, otherwise we might support only 0/1 while using
> it.
>
> WDYT?
Sounds reasonable, LTP_ENABLE_DEBUG now should support '0, 1 or 2' and
drop the 'y' option.
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH] lib: Extend -D flag to support multiple debug levels
2026-03-03 2:45 ` Li Wang via ltp
@ 2026-03-03 2:55 ` Li Wang via ltp
0 siblings, 0 replies; 6+ messages in thread
From: Li Wang via ltp @ 2026-03-03 2:55 UTC (permalink / raw)
To: andrea.cervesato; +Cc: Li Wang via ltp
On Tue, Mar 03, 2026 at 10:45:31AM +0800, Li Wang wrote:
> On Mon, Mar 02, 2026 at 03:11:24PM +0000, Andrea Cervesato via ltp wrote:
> > Maybe we should also apply the same approach to the LTP_ENABLE_DEBUG
> > environment variables, otherwise we might support only 0/1 while using
> > it.
> >
> > WDYT?
>
> Sounds reasonable, LTP_ENABLE_DEBUG now should support '0, 1 or 2' and
> drop the 'y' option.
After thinking over, the 'y option could be reserved for those who are already
familiar with its usage, just like the '-D' option represents '-D1'.
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH] lib: Extend -D flag to support multiple debug levels
@ 2026-03-02 14:41 Andrea Cervesato via ltp
0 siblings, 0 replies; 6+ messages in thread
From: Andrea Cervesato via ltp @ 2026-03-02 14:41 UTC (permalink / raw)
To: ltp
Maybe we should also apply the same approach to the LTP_ENABLE_DEBUG
environment variables, otherwise we might support only 0/1 while using
it.
WDYT?
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-03-03 2:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-01 1:28 [LTP] [PATCH] lib: Extend -D flag to support multiple debug levels Li Wang via ltp
2026-03-02 9:59 ` Cyril Hrubis
2026-03-02 15:11 ` Andrea Cervesato via ltp
2026-03-03 2:45 ` Li Wang via ltp
2026-03-03 2:55 ` Li Wang via ltp
-- strict thread matches above, loose matches on Subject: below --
2026-03-02 14:41 Andrea Cervesato via ltp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox