[LTP] [PATCH v2 2/2] lib: Extend LTP_ENABLE_DEBUG to support verbosity levels
Li Wang
liwang@redhat.com
Tue Mar 3 15:02:46 CET 2026
Hi Andrea,
The two points make sense, will fix in V3. Thanks for the feedback!
On Tue, Mar 3, 2026 at 6:28 PM Andrea Cervesato <andrea.cervesato@suse.com>
wrote:
> Hi Li,
>
> I ran a review with my LLM config and obtained the following report.
> I thought it was interesting to share how the LTP review agent I'm
> developing is growing. Tested with Claude Sonnet 4.6
>
> Issues Found
>
> 1. "Enabling debug info" printed for level 0 — misleading message
> (still unaddressed from v1)
>
> Both -D0 and LTP_ENABLE_DEBUG=0 print "Enabling debug info (level 0)",
> which is the opposite of what is happening. Level 0 means disable all
> debug output. This was raised in the v1 review and remains unfixed.
>
> $ ./getpid01 -D0
> tst_test.c:833: TINFO: Enabling debug info (level 0)
>
> Additionally, LTP_ENABLE_DEBUG=0 is a behavior regression: previously
> it was silently ignored (no output), now it prints a misleading
> "Enabling"
> message. The fix for the -D path is to guard the message:
>
> if (context->tdebug)
> tst_res(TINFO, "Enabling debug info (level %d)", context->tdebug);
>
> Same fix needed in the env var path.
>
> 2. LTP_ENABLE_DEBUG still silently overrides a more specific -D flag
> — core ordering issue unfixed from v1
>
> The env var check runs after parse_opts(), so LTP_ENABLE_DEBUG always
> wins over the command-line -D flag:
>
> $ LTP_ENABLE_DEBUG=1 ./getpid01 -D2
> tst_test.c:833: TINFO: Enabling debug info (level 2) ← from -D2
> tst_test.c:1457: TINFO: Enabling debug info (level 1) ← env var
> overrides!
>
> And even disabling via the env var overrides an explicit command-line
> enable:
> $ LTP_ENABLE_DEBUG=0 ./getpid01 -D2
> tst_test.c:833: TINFO: Enabling debug info (level 2) ← from -D2
> tst_test.c:1457: TINFO: Enabling debug info (level 0) ← env var kills it
>
> Command-line should take precedence over environment variables. The
> fix is to skip the env var assignment when -D was already used:
>
> if (tdebug_env && !context->tdebug) { /* only if -D wasn't passed */
> ...
> }
>
> Or, more robustly, check the env var before parse_opts() so the
> command-line naturally wins.
>
>
> Point 1. is clearly true, the Point 2. might be a design choice. I don't
> mind the priority of command line or env variable, but it's actually
> correct to assume that env should be skipped if -D is defined.
>
>
> Kind regards,
> --
> Andrea Cervesato
> SUSE QE Automation Engineer Linux
> andrea.cervesato@suse.com
>
>
--
Regards,
Li Wang
More information about the ltp
mailing list