[LTP] [PATCH 1/2] Add TST_EXP_FAIL_ARR_SILENT() helper macros

Martin Doucha mdoucha@suse.cz
Tue May 12 18:27:16 CEST 2026


Add silent version of TST_EXP_FAIL() macros with the possibility
to check multiple expected errno values.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
 include/tst_test_macros.h | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
index 2cfbdb586..b1e74278d 100644
--- a/include/tst_test_macros.h
+++ b/include/tst_test_macros.h
@@ -675,6 +675,36 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt);
 			&tst_exp_err__, 1, ##__VA_ARGS__);                     \
 	} while (0)
 
+/**
+ * TST_EXP_FAIL_ARR_SILENT() - Test syscall to fail with expected errnos, silent variant.
+ *
+ * @SCALL: Tested syscall.
+ * @EXP_ERRS: Array of expected errnos.
+ * @EXP_ERRS_CNT: Lenght of EXP_ERRS.
+ * @...: A printf-like parameters.
+ *
+ * Unlike TST_EXP_FAIL_ARR() does not print :c:enum:`TPASS <tst_res_flags>` on
+ * success, only prints :c:enum:`TFAIL <tst_res_flags>` on failure.
+ */
+#define TST_EXP_FAIL_ARR_SILENT(SCALL, EXP_ERRS, EXP_ERRS_CNT, ...)            \
+	TST_EXP_FAIL_SILENT_(TST_RET == 0, SCALL, #SCALL,                      \
+		EXP_ERRS, EXP_ERRS_CNT, ##__VA_ARGS__)
+
+/**
+ * TST_EXP_FAIL2_ARR_SILENT() - Test syscall to fail with expected errnos, silent variant.
+ *
+ * @SCALL: Tested syscall.
+ * @EXP_ERRS: Array of expected errnos.
+ * @EXP_ERRS_CNT: Lenght of EXP_ERRS.
+ * @...: A printf-like parameters.
+ *
+ * Unlike TST_EXP_FAIL2_ARR() does not print :c:enum:`TPASS <tst_res_flags>` on
+ * success, only prints :c:enum:`TFAIL <tst_res_flags>` on failure.
+ */
+#define TST_EXP_FAIL2_ARR_SILENT(SCALL, EXP_ERRS, EXP_ERRS_CNT, ...)           \
+	TST_EXP_FAIL_SILENT_(TST_RET >= 0, SCALL, #SCALL,                     \
+		EXP_ERRS, EXP_ERRS_CNT, ##__VA_ARGS__)
+
 /**
  * TST_EXP_EXPR() - Check for expected expression.
  *
-- 
2.53.0



More information about the ltp mailing list