From: Cyril Hrubis <chrubis@suse.cz>
To: Petr Vorel <pvorel@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2 1/2] test macros: Fix TST_EXP_FD_OR_FAIL()
Date: Fri, 10 Jul 2026 15:09:18 +0200 [thread overview]
Message-ID: <alDu_o0TCVP7aMtQ@rei> (raw)
In-Reply-To: <20260710130303.1210731-1-pvorel@suse.cz>
Hi!
> diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
> index f06c8aeb77..e18f1d33f3 100644
> --- a/include/tst_test_macros.h
> +++ b/include/tst_test_macros.h
> @@ -8,6 +8,12 @@
> * DOC: tst_test_macros.h -- helpers for testing syscalls
> */
>
> +/*
> + * NOTE: for all TST_EXP_*() macros SCALL in first macro needs to be stringified
> + * otherwise constants in syscalls will be evaluated (e.g. O_RDONLY becomes 0).
> + * That is the reason for underscore variants (e.g. TST_EXP_FAIL_()).
> + */
> +
> #ifndef TST_TEST_MACROS_H__
> #define TST_TEST_MACROS_H__
>
> @@ -149,7 +155,10 @@ extern int TST_PASS;
> * This is a variant of the TST_EXP_POSITIVE() for a more specific case that
> * the returned value is a file descriptor.
> */
> -#define TST_EXP_FD(SCALL, ...) \
> +#define TST_EXP_FD(SCALL, ...) \
> + TST_EXP_FD_(SCALL, #SCALL, ##__VA_ARGS__)
> +
> +#define TST_EXP_FD_(SCALL, SSCALL, ...) \
> ({ \
> TST_EXP_POSITIVE__(SCALL, #SCALL, ##__VA_ARGS__); \
^
SSCALL
> @@ -174,11 +183,14 @@ extern int TST_PASS;
> * Internally it uses TST_EXP_FAIL() and TST_EXP_FD().
> */
> #define TST_EXP_FD_OR_FAIL(SCALL, ERRNO, ...) \
> - ({ \
> + TST_EXP_FD_OR_FAIL_(SCALL, #SCALL, ERRNO, ##__VA_ARGS__)
> +
> +#define TST_EXP_FD_OR_FAIL_(SCALL, SSCALL, ERRNO, ...) \
> + ({ \
This indirection is not needed as long as TST_EXP_FD_OR_FAIL() is not
called from other macros.
> if (ERRNO) \
> - TST_EXP_FAIL(SCALL, ERRNO, ##__VA_ARGS__); \
> + TST_EXP_FAIL_(SCALL, SSCALL, ERRNO, ##__VA_ARGS__); \
> else \
> - TST_EXP_FD(SCALL, ##__VA_ARGS__); \
> + TST_EXP_FD_(SCALL, SSCALL, ##__VA_ARGS__); \
> \
> TST_RET; \
> })
> @@ -488,10 +500,13 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt);
> * printed by the pass or fail tst_res() calls. If omitted the first parameter
> * is converted to a string and used instead.
> */
> -#define TST_EXP_FAIL(SCALL, EXP_ERR, ...) \
> +#define TST_EXP_FAIL(SCALL, EXP_ERR, ...) \
> + TST_EXP_FAIL_(SCALL, #SCALL, EXP_ERR, ##__VA_ARGS__)
> +
> +#define TST_EXP_FAIL_(SCALL, SSCALL, EXP_ERR, ...) \
> do { \
> int tst_exp_err__ = EXP_ERR; \
> - TST_EXP_FAIL_ARR_(SCALL, #SCALL, &tst_exp_err__, 1, \
> + TST_EXP_FAIL_ARR_(SCALL, SSCALL, &tst_exp_err__, 1, \
> ##__VA_ARGS__); \
> } while (0)
>
> --
> 2.54.0
>
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
prev parent reply other threads:[~2026-07-10 13:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-10 13:03 [LTP] [PATCH v2 1/2] test macros: Fix TST_EXP_FD_OR_FAIL() Petr Vorel
2026-07-10 13:03 ` [LTP] [PATCH v2 2/2] test_macros: Add TST_EXP_PASS_OR_FAIL() Petr Vorel
2026-07-10 13:12 ` Cyril Hrubis
2026-07-10 13:09 ` Cyril Hrubis [this message]
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=alDu_o0TCVP7aMtQ@rei \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
--cc=pvorel@suse.cz \
/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.