<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Feb 4, 2022 at 9:14 PM Jan Stancek <<a href="mailto:jstancek@redhat.com">jstancek@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">This variant does not print TPASS messages when<br>
SCALL fails as expected.<br>
<br>
Signed-off-by: Jan Stancek <<a href="mailto:jstancek@redhat.com" target="_blank">jstancek@redhat.com</a>><br>
---<br>
 doc/c-test-api.txt        |  3 +++<br>
 include/tst_test_macros.h | 15 ++++++++++-----<br>
 2 files changed, 13 insertions(+), 5 deletions(-)<br>
<br>
diff --git a/doc/c-test-api.txt b/doc/c-test-api.txt<br>
index 6f4de3f80f95..9119e094dbfd 100644<br>
--- a/doc/c-test-api.txt<br>
+++ b/doc/c-test-api.txt<br>
@@ -298,6 +298,9 @@ The 'TST_EXP_FAIL2()' is the same as 'TST_EXP_FAIL()' except the return value is<br>
 expected to be non-negative integer if call passes. These macros build upon the<br>
 +TEST()+ macro and associated variables.<br>
<br>
+'TST_EXP_FAIL_SILENT()' and 'TST_EXP_FAIL2_SILENT()' variants are less verbose<br>
+and do not print TPASS messages when SCALL fails as expected.<br>
+<br>
 [source,c]<br>
 -------------------------------------------------------------------------------<br>
 TEST(socket(AF_INET, SOCK_RAW, 1));<br>
diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h<br>
index ec8c38523344..f7de8d00a666 100644<br>
--- a/include/tst_test_macros.h<br>
+++ b/include/tst_test_macros.h<br>
@@ -163,7 +163,7 @@ extern void *TST_RET_PTR;<br>
                        TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__);     \<br>
        } while (0)                                                            \<br>
<br>
-#define TST_EXP_FAIL_(PASS_COND, SCALL, SSCALL, ERRNO, ...)                    \<br>
+#define TST_EXP_FAIL_(SILENT, PASS_COND, SCALL, SSCALL, ERRNO, ...)            \<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">I think maybe the better way is to define TST_EXP_FAIL_SILENT_</div><div class="gmail_default" style="font-size:small">but not add a new SILENT parameter. So that it keeps consistent with</div><div class="gmail_default" style="font-size:small">the existing TST_EXP_PASS_SILENT_ macros.</div><br></div><div class="gmail_default" style="font-size:small">How about this:</div><div class="gmail_default" style="font-size:small">(changed base on your patch)</div><br><div class="gmail_default" style="font-size:small">--- a/include/tst_test_macros.h<br>+++ b/include/tst_test_macros.h<br>@@ -163,7 +163,7 @@ extern void *TST_RET_PTR;<br>                        TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__);     \<br>        } while (0)                                                            \<br> <br>-#define TST_EXP_FAIL_(SILENT, PASS_COND, SCALL, SSCALL, ERRNO, ...)            \<br>+#define TST_EXP_FAIL_SILENT_(PASS_COND, SCALL, SSCALL, ERRNO, ...)             \<br>        do {                                                                   \<br>                TEST(SCALL);                                                   \<br>                                                                               \<br>@@ -181,9 +181,6 @@ extern void *TST_RET_PTR;<br>                }                                                              \<br>                                                                               \<br>                if (TST_ERR == (ERRNO)) {                                      \<br>-                       if (!SILENT)                                           \<br>-                               TST_MSG_(TPASS | TTERRNO, " ",                 \<br>-                                       SSCALL, ##__VA_ARGS__);                \<br>                        TST_PASS = 1;                                          \<br>                } else {                                                       \<br>                        TST_MSGP_(TFAIL | TTERRNO, " expected %s",             \<br>@@ -192,13 +189,23 @@ extern void *TST_RET_PTR;<br>                }                                                              \<br>        } while (0)<br> <br>-#define TST_EXP_FAIL(SCALL, ERRNO, ...) TST_EXP_FAIL_(0, TST_RET == 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__)<br>+#define TST_EXP_FAIL(SCALL, ERRNO, ...)                                        \<br>+       do {                                                                   \<br>+               TST_EXP_FAIL_SILENT_(TST_RET == 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__); \<br>+               if (TST_PASS)                                                  \<br>+                       TST_MSG_(TPASS | TTERRNO, " ", #SCALL, ##__VA_ARGS__); \<br>+       } while (0)<br> <br>-#define TST_EXP_FAIL2(SCALL, ERRNO, ...) TST_EXP_FAIL_(0, TST_RET >= 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__)<br>+#define TST_EXP_FAIL2(SCALL, ERRNO, ...)                                       \<br>+       do {                                                                   \<br>+               TST_EXP_FAIL_SILENT_(TST_RET >= 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__); \<br>+               if (TST_PASS)                                                  \<br>+                       TST_MSG_(TPASS | TTERRNO, " ", #SCALL, ##__VA_ARGS__); \<br>+       } while (0)<br> <br>-#define TST_EXP_FAIL_SILENT(SCALL, ERRNO, ...) TST_EXP_FAIL_(1, TST_RET == 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__)<br>+#define TST_EXP_FAIL_SILENT(SCALL, ERRNO, ...) TST_EXP_FAIL_SILENT_(TST_RET == 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__) \<br> <br>-#define TST_EXP_FAIL2_SILENT(SCALL, ERRNO, ...) TST_EXP_FAIL_(1, TST_RET >= 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__)<br>+#define TST_EXP_FAIL2_SILENT(SCALL, ERRNO, ...) TST_EXP_FAIL_SILENT_(TST_RET >= 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__) \<br> <br> #define TST_EXP_EXPR(EXPR, FMT, ...)                                           \<br>        tst_res_(__FILE__, __LINE__, (EXPR) ? TPASS : TFAIL, "Expect: " FMT, ##__VA_ARGS__);<br></div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>