[LTP] [RFC PATCH 1/1] lib: Print tcnt in tst_{brk,res}()

Andrea Cervesato andrea.cervesato@suse.com
Fri Mar 20 10:38:40 CET 2026


Hi Petr,

the idea is ok, but there are a few issues in the implementation.

> +static unsigned int tcnt;

`tcnt` is misleading because we are already using the same name inside
`struct tst_test`. Better to use `tcase_idx` or something like this.

>  
>  struct context {
>  	int32_t lib_pid;
> @@ -344,7 +345,7 @@ static void print_result(const char *file, const int lineno, int ttype,

print_result() is used everywhere, by any tst_brk, tst_res, tst_vbrk_, tst_cvres
etc. Which means you will have a `tcnt` printed everywhere. It looks better if
we select only the starting message.

>  
>  		if (results_equal(&saved_results, results))
> -			tst_brk(TBROK, "Test %i haven't reported results!", i);
> +			tst_brk(TBROK, "Test %i haven't reported results!", tcnt);

The new prefix printed by print_result() is 1-indexed (tcnt+1), but this
message body still passes the 0-indexed value. A test skipping its first
case would produce:

  tst_test.c:1738: 1 TBROK: Test 0 haven't reported results!

Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com


More information about the ltp mailing list