All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [RFC] syscalls/ipc: Make use of TST_EXP_FAIL macro
Date: Tue, 22 Jun 2021 12:58:11 +0200	[thread overview]
Message-ID: <YNHCQ8qWSBdHIAra@yuki> (raw)
In-Reply-To: <1624356737-508-1-git-send-email-xuyang2018.jy@fujitsu.com>

Hi!
> Since TST_EXP_FAIL macro only recognizes sycalls succeeded when syscalls return 0,
> Can we use this macro directly for the these syscalls's error test? It may result in
> invalid retval value and print errno when syscall succeeded. I think it
> is a nit and it can improve this api usage range. Is it right?

I guess that it would be slightly cleaner to add more generic macro that
allows us to pass the condition for succeess and build TST_EXP_FAIL() on
the top of that. Maybe something as:

diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
index 89dfe5a31..4d41741a4 100644
--- a/include/tst_test_macros.h
+++ b/include/tst_test_macros.h
@@ -120,13 +120,13 @@ extern void *TST_RET_PTR;
                        TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__);     \
        } while (0)                                                            \

-#define TST_EXP_FAIL(SCALL, ERRNO, ...)                                        \
+#define TST_EXP_FAIL_(PASS_COND, SCALL, ERRNO, ...)                            \
        do {                                                                   \
                TEST(SCALL);                                                   \
                                                                               \
                TST_PASS = 0;                                                  \
                                                                               \
-               if (TST_RET == 0) {                                            \
+               if (PASS_COND) {                                               \
                        TST_MSG_(TFAIL, " succeeded", #SCALL, ##__VA_ARGS__);  \
                        break;                                                 \
                }                                                              \
@@ -150,4 +150,8 @@ extern void *TST_RET_PTR;
                }                                                              \
        } while (0)

+#define TST_EXP_FAIL(SCALL, ERRNO, ...) TST_EXP_FAIL_(TST_RET == 0, SCALL, ERRNO)
+
+#define TST_EXP_FAIL2(SCALL, ERRNO, ...) TST_EXP_FAIL_(TST_RET >= 0, SCALL, ERRNO)
+
 #endif /* TST_TEST_MACROS_H__ */

The only hard thing is to find a good name for TST_EXP_FAIL2(), I'm out
of ideas here...

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2021-06-22 10:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-22 10:12 [LTP] [RFC] syscalls/ipc: Make use of TST_EXP_FAIL macro Yang Xu
2021-06-22 10:58 ` Cyril Hrubis [this message]
2021-06-24  4:41   ` xuyang2018.jy
2021-06-29 10:44   ` [LTP] [PATCH v2 1/2] syscalls: Use more accurate TST_EXP_FAIL2 macro Yang Xu
2021-06-29 10:44     ` [LTP] [PATCH v2 2/2] syscalls/ipc: Make use of TST_EXP_FAIL or " Yang Xu
2021-06-30 14:27       ` Cyril Hrubis
2021-07-01  1:28         ` xuyang2018.jy
2021-06-29 11:16     ` [LTP] [PATCH v2 1/2] syscalls: Use more accurate " xuyang2018.jy
2021-06-30 13:24       ` Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YNHCQ8qWSBdHIAra@yuki \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.