[LTP] [PATCH v1] Add TST_EXP_FAIL_PTR

Wei Gao wegao@suse.com
Thu Jan 11 02:26:50 CET 2024


Signed-off-by: Wei Gao <wegao@suse.com>
---
 include/tst_test_macros.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

This is draft patch and should rebase after following patch merge.
https://patchwork.ozlabs.org/project/ltp/patch/20240103115700.14585-1-chrubis@suse.cz/

diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
index 3f4f9f11d..6e45e0b27 100644
--- a/include/tst_test_macros.h
+++ b/include/tst_test_macros.h
@@ -212,6 +212,26 @@ extern void *TST_RET_PTR;
 		}                                                              \
 	} while (0)
 
+#define TST_EXP_FAIL_SILENT_PTR_(SCALL, SSCALL, ERRNO, ...)             \
+	do {                                                                   \
+		TESTPTR(SCALL);                                                   \
+		                                                               \
+		TST_PASS = 0;                                                  \
+		                                                               \
+		if (TST_RET_PTR) {                                               \
+			TST_MSG_(TFAIL, " succeeded", SSCALL, ##__VA_ARGS__);  \
+		        break;                                                 \
+		}                                                              \
+		                                                               \
+		if (TST_ERR == (ERRNO)) {                                      \
+			TST_PASS = 1;                                          \
+		} else {                                                       \
+			TST_MSGP_(TFAIL | TTERRNO, " expected %s",             \
+				  tst_strerrno(ERRNO),                         \
+				  SSCALL, ##__VA_ARGS__);                      \
+		}                                                              \
+	} while (0)
+
 #define TST_EXP_FAIL(SCALL, ERRNO, ...)                                        \
 	do {                                                                   \
 		TST_EXP_FAIL_SILENT_(TST_RET == 0, SCALL, #SCALL,              \
@@ -228,6 +248,14 @@ extern void *TST_RET_PTR;
 			TST_MSG_(TPASS | TTERRNO, " ", #SCALL, ##__VA_ARGS__); \
 	} while (0)
 
+#define TST_EXP_FAIL_PTR(SCALL, ERRNO, ...)                                        \
+	do {                                                                   \
+		TST_EXP_FAIL_SILENT_PTR_(SCALL, #SCALL,              \
+			ERRNO, ##__VA_ARGS__);                                 \
+		if (TST_PASS)                                                  \
+			TST_MSG_(TPASS | TTERRNO, " ", #SCALL, ##__VA_ARGS__); \
+	} while (0)
+
 #define TST_EXP_FAIL_SILENT(SCALL, ERRNO, ...) \
 	TST_EXP_FAIL_SILENT_(TST_RET == 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__)
 
-- 
2.35.3



More information about the ltp mailing list