[LTP] [PATCH] lib: TST_EXP_FAIL: Fix the *_ARR_() macros

Cyril Hrubis chrubis@suse.cz
Wed Jan 17 11:18:01 CET 2024


This is basically the same fix as:
d7e5e102364b (tst_test_macros.h: fix "too many arguments")

The point is that the SCALL parameter has to be stringified in the first
pass otherwise it ends up expandend and as long as it contains coma the
number of parameters will increase breaking the printf() formatting
again.

Fixes: #1120

Fixes: 1cfe61428982 ("lib: TST_EXP_FAIL: Add array variants")
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 include/tst_test_macros.h | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
index 24fd324bf..d2e50a219 100644
--- a/include/tst_test_macros.h
+++ b/include/tst_test_macros.h
@@ -227,41 +227,41 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt);
 		}                                                              \
 	} while (0)
 
-#define TST_EXP_FAIL_ARR_(SCALL, EXP_ERRS, EXP_ERRS_CNT, ...)                  \
+#define TST_EXP_FAIL_ARR_(SCALL, SSCALL, EXP_ERRS, EXP_ERRS_CNT, ...)          \
 	do {                                                                   \
-		TST_EXP_FAIL_SILENT_(TST_RET == 0, SCALL, #SCALL,              \
+		TST_EXP_FAIL_SILENT_(TST_RET == 0, SCALL, SSCALL,              \
 			EXP_ERRS, EXP_ERRS_CNT, ##__VA_ARGS__);                \
 		if (TST_PASS)                                                  \
-			TST_MSG_(TPASS | TTERRNO, " ", #SCALL, ##__VA_ARGS__); \
+			TST_MSG_(TPASS | TTERRNO, " ", SSCALL, ##__VA_ARGS__); \
 	} while (0)
 
 #define TST_EXP_FAIL(SCALL, EXP_ERR, ...)                                      \
 	do {                                                                   \
 		int tst_exp_err__ = EXP_ERR;                                   \
-		TST_EXP_FAIL_ARR_(SCALL, &tst_exp_err__, 1,                    \
+		TST_EXP_FAIL_ARR_(SCALL, #SCALL, &tst_exp_err__, 1,            \
                                   ##__VA_ARGS__);                              \
 	} while (0)
 
 #define TST_EXP_FAIL_ARR(SCALL, EXP_ERRS, ...)                                 \
-		TST_EXP_FAIL_ARR_(SCALL, EXP_ERRS, ARRAY_SIZE(EXP_ERRS),       \
-                                  ##__VA_ARGS__);                              \
+		TST_EXP_FAIL_ARR_(SCALL, #SCALL, EXP_ERRS,                     \
+				  ARRAY_SIZE(EXP_ERRS), ##__VA_ARGS__);
 
-#define TST_EXP_FAIL2_ARR_(SCALL, EXP_ERRS, EXP_ERRS_CNT, ...)                 \
+#define TST_EXP_FAIL2_ARR_(SCALL, SSCALL, EXP_ERRS, EXP_ERRS_CNT, ...)         \
 	do {                                                                   \
-		TST_EXP_FAIL_SILENT_(TST_RET >= 0, SCALL, #SCALL,              \
+		TST_EXP_FAIL_SILENT_(TST_RET >= 0, SCALL, SSCALL,              \
 			EXP_ERRS, EXP_ERRS_CNT, ##__VA_ARGS__);                \
 		if (TST_PASS)                                                  \
-			TST_MSG_(TPASS | TTERRNO, " ", #SCALL, ##__VA_ARGS__); \
+			TST_MSG_(TPASS | TTERRNO, " ", SSCALL, ##__VA_ARGS__); \
 	} while (0)
 
 #define TST_EXP_FAIL2_ARR(SCALL, EXP_ERRS, ...)                                \
-		TST_EXP_FAIL2_ARR_(SCALL, EXP_ERRS, ARRAY_SIZE(EXP_ERRS),      \
-                                  ##__VA_ARGS__);                              \
+		TST_EXP_FAIL2_ARR_(SCALL, #SCALL, EXP_ERRS,                    \
+		                  ARRAY_SIZE(EXP_ERRS), ##__VA_ARGS__);
 
 #define TST_EXP_FAIL2(SCALL, EXP_ERR, ...)                                     \
 	do {                                                                   \
 		int tst_exp_err__ = EXP_ERR;                                   \
-		TST_EXP_FAIL2_ARR_(SCALL, &tst_exp_err__, 1,                   \
+		TST_EXP_FAIL2_ARR_(SCALL, #SCALL, &tst_exp_err__, 1,           \
                                   ##__VA_ARGS__);                              \
 	} while (0)
 
-- 
2.43.0



More information about the ltp mailing list