All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xiao Yang <yangx.jy@cn.fujitsu.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 2/2] lib: build check parameters for tst_brk()
Date: Fri, 9 Nov 2018 09:56:46 +0800	[thread overview]
Message-ID: <5BE4E95E.4000303@cn.fujitsu.com> (raw)
In-Reply-To: <d3ce5d3247f7f09cfabd288b40893bb631fb190f.1541710635.git.jstancek@redhat.com>

On 2018/11/09 4:59, Jan Stancek wrote:
> This patch adds simple build-check that allows only
> TFAIL, TBROK and TCONF as parameter for tst_brk().
>
> TFAIL is currently quite commonly used as a shortcut for
> TFAIL + exit() by many tests. I kept it for now, since
> it doesn't go against current doc description.
>
> Per kernel comments this approach works fine for simple
> cases, which should be sufficient for LTP, e.g. we don't
> pass TBROK as a paramter to inlined function, that passes
> it further down to tst_brk().
>
> Signed-off-by: Jan Stancek<jstancek@redhat.com>
> ---
>   include/tst_common.h | 3 +++
>   include/tst_test.h   | 7 +++++--
>   2 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/include/tst_common.h b/include/tst_common.h
> index 27924766ef6e..358f2a76ecda 100644
> --- a/include/tst_common.h
> +++ b/include/tst_common.h
> @@ -65,4 +65,7 @@
>   	ERET;								\
>   })
>
> +#define BUILD_BUG_ON(condition) \
> +	do { ((void)sizeof(char[1 - 2 * !!(condition)])); } while (0)
> +
>   #endif /* TST_COMMON_H__ */
> diff --git a/include/tst_test.h b/include/tst_test.h
> index 2ebf746eb720..cd936eb792bd 100644
> --- a/include/tst_test.h
> +++ b/include/tst_test.h
> @@ -69,8 +69,11 @@ void tst_brk_(const char *file, const int lineno, int ttype,
>                 const char *fmt, ...)
>                 __attribute__ ((format (printf, 4, 5)));
>
> -#define tst_brk(ttype, arg_fmt, ...) \
> -	tst_brk_(__FILE__, __LINE__, (ttype), (arg_fmt), ##__VA_ARGS__)
> +#define tst_brk(ttype, arg_fmt, ...)						\
> +	({									\
> +		BUILD_BUG_ON(!((ttype)&  (TBROK | TCONF | TFAIL)));		\
> +		tst_brk_(__FILE__, __LINE__, (ttype), (arg_fmt), ##__VA_ARGS__);\
> +	})
Hi Jan,

Perhaps, we could add some hints about the invalid ttype.
e.g. "tst_brk(): invalid type, please use TBROK/TCONF/TFAIL"

Other than that, this patch set looks good to me.

Best Regards,
Xiao Yang

>
>   /* flush stderr and stdout */
>   void tst_flush(void);




  reply	other threads:[~2018-11-09  1:56 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-08 20:59 [LTP] [PATCH 1/2] syscalls/mq: don't use TWARN with tst_brk() Jan Stancek
2018-11-08 20:59 ` [LTP] [PATCH 2/2] lib: build check parameters for tst_brk() Jan Stancek
2018-11-09  1:56   ` Xiao Yang [this message]
2018-11-09 17:57     ` Jan Stancek
2018-12-04 17:35       ` Petr Vorel
2018-12-05  6:34         ` Li Wang
2018-12-05  9:25           ` Petr Vorel
2018-12-06  8:49             ` Li Wang
2018-12-06  9:19               ` Xiao Yang
2018-12-06 10:15                 ` Li Wang
2018-12-06 10:33               ` Li Wang
2018-12-06 12:59                 ` Petr Vorel
2018-12-06 13:07               ` Petr Vorel
2018-12-07  6:28                 ` Li Wang
2018-12-11 14:58       ` Cyril Hrubis
2019-01-03 11:52         ` Jan Stancek
2019-01-07 18:25           ` Cyril Hrubis
2019-01-07 19:06             ` Jan Stancek
2019-01-07 19:22               ` Cyril Hrubis
2019-01-08 11:14                 ` Jan Stancek
2018-12-04 16:58 ` [LTP] [PATCH 1/2] syscalls/mq: don't use TWARN with tst_brk() Petr Vorel
2018-12-11 14:48 ` 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=5BE4E95E.4000303@cn.fujitsu.com \
    --to=yangx.jy@cn.fujitsu.com \
    --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.