Skip to contentSkip to conversation

tst_test_macros.h: Print also returned value

PATCH In review Petr Vorel 2 participants 3 messages Dec 20, 2021 – Dec 21, 2021

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH 1/1 tst_test_macros.h: Print also returned value

in TST_EXP_VAL*() macros.

---
NOTE: tst_test_macros.h would also deserve documentation of "public" macros (to save people read all nested definitions.

Kind regards,
Petr

 include/tst_test_macros.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
include/tst_test_macros.h +6 -2
index 4a023b700a..dd959cad63 100644
@@ -46,6 +46,10 @@ extern void *TST_RET_PTR;
 	tst_res_(__FILE__, __LINE__, RES, \
 		TST_FMT_(TST_2_(dummy, ##__VA_ARGS__, SCALL) FMT, __VA_ARGS__), PAR)
 
+#define TST_MSGP2_(RES, FMT, PAR, PAR2, SCALL, ...) \
+	tst_res_(__FILE__, __LINE__, RES, \
+		TST_FMT_(TST_2_(dummy, ##__VA_ARGS__, SCALL) FMT, __VA_ARGS__), PAR, PAR2)
+
 #define TST_EXP_POSITIVE_(SCALL, SSCALL, ...)                                  \
 	do {                                                                   \
 		TEST(SCALL);                                                   \
@@ -107,8 +111,8 @@ extern void *TST_RET_PTR;
 		TST_PASS = 0;                                                  \
 		                                                               \
 		if (TST_RET != VAL) {                                          \
-			TST_MSGP_(TFAIL | TTERRNO, " retval not %ld",          \
-			          (long )VAL, SSCALL, ##__VA_ARGS__);          \
+			TST_MSGP2_(TFAIL | TTERRNO, " retval not %ld (%ld)",          \
+			          (long)VAL, TST_RET, SSCALL, ##__VA_ARGS__);          \
 			break;                                                 \
 		}                                                              \
 		                                                               \
Signature · 5 lines
2.34.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi!

Quoted 29 lines

in TST_EXP_VAL*() macros.

---
NOTE: tst_test_macros.h would also deserve documentation of "public" macros (to save people read all nested definitions.

Kind regards,
Petr

 include/tst_test_macros.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
include/tst_test_macros.h +4 -0
index 4a023b700a..dd959cad63 100644
@@ -46,6 +46,10 @@ extern void *TST_RET_PTR;
 	tst_res_(__FILE__, __LINE__, RES, \
 		TST_FMT_(TST_2_(dummy, ##__VA_ARGS__, SCALL) FMT, __VA_ARGS__), PAR)
 
+#define TST_MSGP2_(RES, FMT, PAR, PAR2, SCALL, ...) \
+	tst_res_(__FILE__, __LINE__, RES, \
+		TST_FMT_(TST_2_(dummy, ##__VA_ARGS__, SCALL) FMT, __VA_ARGS__), PAR, PAR2)
+
 #define TST_EXP_POSITIVE_(SCALL, SSCALL, ...)                                  \
 	do {                                                                   \
 		TEST(SCALL);                                                   \

include/tst_test_macros.h extern void *TST_RET_PTR; · line 114

Quoted 6 lines
include/tst_test_macros.h +1 -2
@@ -107,8 +111,8 @@ extern void *TST_RET_PTR;
 		TST_PASS = 0;                                                  \
 		                                                               \
 		if (TST_RET != VAL) {                                          \
-			TST_MSGP_(TFAIL | TTERRNO, " retval not %ld",          \
-			          (long )VAL, SSCALL, ##__VA_ARGS__);          \
+			TST_MSGP2_(TFAIL | TTERRNO, " retval not %ld (%ld)",          \
                                                          ^
					Should probably be " retval %ld != %ld", TST_RET, (long)VAL, ...

include/tst_test_macros.h extern void *TST_RET_PTR; · line 118

Quoted 4 lines
include/tst_test_macros.h +1 -0
+			          (long)VAL, TST_RET, SSCALL, ##__VA_ARGS__);          \
 			break;                                                 \
 		}                                                              \
 		                                                               \

Other than this it looks fine.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#2 lore raw

Hi Cyril,

Quoted 3 lines

include/tst_test_macros.h extern void *TST_RET_PTR; · line 114

Quoted 1 line
include/tst_test_macros.h +1 -0
+			TST_MSGP2_(TFAIL | TTERRNO, " retval not %ld (%ld)",          \
                                                          ^
					Should probably be " retval %ld != %ld", TST_RET, (long)VAL, ...

+1, merged this version with your ack.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp