From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/2] Add TST_ASSERT_SYSCALL*() macros
Date: Thu, 5 Mar 2020 15:46:06 +0100 [thread overview]
Message-ID: <20200305144606.GC28363@rei> (raw)
In-Reply-To: <20200305143658.26584-1-mdoucha@suse.cz>
Hi!
> +/* assert that syscall returned only 0 and nothing else */
> +#define TST_ASSERT_SYSCALL(SCALL) \
> + TST_ASSERT_SYSCALL_IMPL(SCALL, __FILE__, __LINE__)
> +
> +#define TST_ASSERT_SYSCALL_IMPL(SCALL, FILENAME, LINENO) \
> + ({ \
> + int _tst_ret; \
> + errno = 0; \
> + _tst_ret = SCALL; \
> + if (_tst_ret == -1) { \
> + int _tst_ttype = errno == ENOTSUP ? TCONF : TBROK; \
> + tst_brk(_tst_ttype | TERRNO, "%s:%d " # SCALL \
^
I do not think that is reasonable to
simply stringify the syscall, we are
adding pretty printers for the syscall
parameters and this change is backward.
These two patches are actually removing the pretty printer for the clock
id for the timerfd_create(). I do not like that.
> + " failed", FILENAME, LINENO); \
> + } \
> + if (_tst_ret != 0) { \
> + tst_brk(TBROK | TERRNO, "%s:%d " # SCALL \
> + " returned invalid value %d", FILENAME, \
> + LINENO, _tst_ret); \
> + } \
> + _tst_ret; \
> + })
> +
> +/*
> + * assert that syscall returned any non-negative value (e.g. valid file
> + * descriptor)
> + */
> +#define TST_ASSERT_SYSCALL_FD(SCALL) \
> + TST_ASSERT_SYSCALL_FD_IMPL(SCALL, __FILE__, __LINE__)
> +
> +#define TST_ASSERT_SYSCALL_FD_IMPL(SCALL, FILENAME, LINENO) \
> + ({ \
> + int _tst_ret; \
> + errno = 0; \
> + _tst_ret = SCALL; \
> + if (_tst_ret == -1) { \
> + int _tst_ttype = errno == ENOTSUP ? TCONF : TBROK; \
> + tst_brk(_tst_ttype | TERRNO, "%s:%d " # SCALL \
> + " failed", FILENAME, LINENO); \
> + } \
> + if (_tst_ret < 0) { \
> + tst_brk(TBROK | TERRNO, "%s:%d " # SCALL \
> + " returned invalid value %d", FILENAME, \
> + LINENO, _tst_ret); \
> + } \
> + _tst_ret; \
> + })
> +
> /*
> * Functions to convert ERRNO to its name and SIGNAL to its name.
> */
> --
> 2.25.1
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
prev parent reply other threads:[~2020-03-05 14:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-05 14:36 [LTP] [PATCH 1/2] Add TST_ASSERT_SYSCALL*() macros Martin Doucha
2020-03-05 14:36 ` [LTP] [PATCH 2/2] Reimplement TST_SAFE_TIMERFD_*() using TST_ASSERT_SYSCALL*() Martin Doucha
2020-03-05 14:46 ` 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=20200305144606.GC28363@rei \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox