[LTP] [RFC PATCH 1/1] lib: Print tcnt in tst_{brk,res}()
Petr Vorel
pvorel@suse.cz
Wed Mar 18 15:41:13 CET 2026
This helps readability on tests with high tcnt.
Inspired by tst_test.sh (shell API) which prints $TST_COUNT in tst_res
and tst_brk.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
NOTE: testing on open01.c which has tcnt = 2.
Before:
tst_tmpdir.c:308: TINFO: Using /tmp/LTP_opebwazQS as tmpdir (tmpfs filesystem)
tst_test.c:2059: TINFO: LTP version: 20260130-78-g68660b12c8
tst_test.c:1887: TINFO: Overall timeout per run is 0h 00m 30s
open01.c:56: TPASS: sticky bit is set as expected
open01.c:56: TPASS: directory bit is set as expected
With the patch:
tst_tmpdir.c:308: 1 TINFO: Using /tmp/LTP_opezEOyj2 as tmpdir (tmpfs filesystem)
tst_test.c:2059: 1 TINFO: LTP version: 20260130-79-g8d8379aa73
tst_test.c:1887: 1 TINFO: Overall timeout per run is 0h 00m 30s
open01.c:56: 1 TPASS: sticky bit is set as expected
open01.c:56: 2 TPASS: directory bit is set as expected
Setup has "1", cleanup has tcnt + 1. We could even print "0" for setup
or even for cleanup as well.
Kind regards,
Petr
lib/tst_test.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 2d62ab164d..b9593b743a 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -69,6 +69,7 @@ static float duration = -1;
static float timeout_mul = -1;
static int reproducible_output;
static int quiet_output;
+static unsigned int tcnt;
struct context {
int32_t lib_pid;
@@ -344,7 +345,7 @@ static void print_result(const char *file, const int lineno, int ttype,
str_errno = tst_strerrno(int_errno);
}
- ret = snprintf(str, size, "%s:%i: ", file, lineno);
+ ret = snprintf(str, size, "%s:%i: %u ", file, lineno, tcnt+1);
str += ret;
size -= ret;
@@ -1705,7 +1706,6 @@ static void heartbeat(void)
static void run_tests(void)
{
- unsigned int i;
struct results saved_results;
if (!tst_test->test) {
@@ -1724,10 +1724,10 @@ static void run_tests(void)
return;
}
- for (i = 0; i < tst_test->tcnt; i++) {
+ for (tcnt = 0; tcnt < tst_test->tcnt; tcnt++) {
saved_results = *results;
heartbeat();
- tst_test->test(i);
+ tst_test->test(tcnt);
if (tst_getpid() != context->main_pid)
exit(0);
@@ -1735,7 +1735,7 @@ static void run_tests(void)
tst_reap_children();
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);
}
}
--
2.51.0
More information about the ltp
mailing list