[LTP] [PATCH] lib: tst_res(): Fix TDEBUG | TERRNO

Cyril Hrubis chrubis@suse.cz
Tue Aug 4 15:28:57 CEST 2026


Properly mask the ttype with TTYPE_MASK() when deciding if TDEBUG
messages should be printed, otherwise any combination of TERRNO etc.
flags is printed regardless the -D flag.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 lib/newlib_tests/tst_res_flags.c | 1 +
 lib/tst_test.c                   | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/newlib_tests/tst_res_flags.c b/lib/newlib_tests/tst_res_flags.c
index cda097070..f4aaa0439 100644
--- a/lib/newlib_tests/tst_res_flags.c
+++ b/lib/newlib_tests/tst_res_flags.c
@@ -22,6 +22,7 @@ static struct tcase {
 	{FLAG(TWARN)},
 	{FLAG(TINFO)},
 	{FLAG(TDEBUG), " (printed only with -D[1,2] or LTP_DEBUG=1(y),2)"},
+	{FLAG(TDEBUG | TERRNO), " (printed only with -D[1,2] or LTP_DEBUG=1(y),2)"},
 };
 
 static void do_cleanup(void)
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 5c3607016..9c5f2617f 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -495,7 +495,7 @@ void tst_res_(const char *file, const int lineno, int ttype,
 	 * 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 (TTYPE_RESULT(ttype) == TDEBUG) {
 		if (!context)
 			return;
 
-- 
2.54.0



More information about the ltp mailing list