[LTP] [PATCH v7 02/16] Add TST_EXP_EQ_STR macro
Andrea Cervesato
andrea.cervesato@suse.de
Wed Oct 9 10:29:04 CEST 2024
From: Andrea Cervesato <andrea.cervesato@suse.com>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
include/tst_test_macros.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
index c02ad38f9..b2ca32f77 100644
--- a/include/tst_test_macros.h
+++ b/include/tst_test_macros.h
@@ -411,4 +411,18 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt);
#define TST_EXP_EQ_SSZ_SILENT(VAL_A, VAL_B) \
TST_EXP_EQ_SILENT_(VAL_A, #VAL_A, VAL_B, #VAL_B, ssize_t, "%zi")
+#define TST_EXP_EQ_STR(STR_A, STR_B) do { \
+ TST_PASS = strcmp(STR_A, STR_B) == 0; \
+ \
+ if (TST_PASS) { \
+ tst_res_(__FILE__, __LINE__, TPASS, \
+ "%s == %s (%s)", \
+ #STR_A, #STR_B, STR_B); \
+ } else { \
+ tst_res_(__FILE__, __LINE__, TFAIL, \
+ "%s (%s) != %s (%s)", \
+ #STR_A, STR_A, #STR_B, STR_B); \
+ } \
+} while (0)
+
#endif /* TST_TEST_MACROS_H__ */
--
2.43.0
More information about the ltp
mailing list