[LTP] [PATCH] lib: Extend -D flag to support multiple debug levels

Cyril Hrubis chrubis@suse.cz
Mon Mar 2 10:59:54 CET 2026


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


More information about the ltp mailing list