All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/2] lib: Implement SAFE_RUN() macro (new API only)
Date: Mon, 23 Mar 2020 10:43:49 +0800	[thread overview]
Message-ID: <edd8ed18-8cb3-2a13-7caa-a55c3447389a@cn.fujitsu.com> (raw)
In-Reply-To: <20200320134937.16616-1-pvorel@suse.cz>

Hi Petr

There are some small nits
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>   doc/test-writing-guidelines.txt |  3 +++
>   include/tst_safe_macros.h       | 20 ++++++++++++++++++++
>   2 files changed, 23 insertions(+)
> 
> diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
> index b56f1a0f2..b8330801b 100644
> --- a/doc/test-writing-guidelines.txt
> +++ b/doc/test-writing-guidelines.txt
> @@ -1282,6 +1282,9 @@ return value is '255' if 'execvp()' failed with 'ENOENT' and '254' otherwise.
>   'stdout_path' and 'stderr_path' determine where to redirect the program
>   stdout and stderr I/O streams.
>   
> +The 'SAFE_RUNCMD()' macro can be used automatic handling non zero exits (exits
> +with 'TBROK') or 'ENOENT' (exits with 'TCONF').
> +
>   .Example
>   [source,c]
>   -------------------------------------------------------------------------------
> diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
> index 80c4d9cb9..d701a003f 100644
> --- a/include/tst_safe_macros.h
> +++ b/include/tst_safe_macros.h
> @@ -547,4 +547,24 @@ int safe_personality(const char *filename, unsigned int lineno,
>   void safe_unshare(const char *file, const int lineno, int flags);
>   #define SAFE_UNSHARE(flags) safe_unshare(__FILE__, __LINE__, (flags))
>   
> +static inline void safe_run_cmd(const char *file, const int lineno,
> +							   const char *const argv[],
> +			      const char *stdout_path,
> +			      const char *stderr_path)
> +{
> +	int rval;
> +
> +	switch ((rval = tst_run_cmd(argv, stdout_path, stderr_path, 1))) {
> +	case 0:
> +		break;
> +	case 255:
> +		tst_brk(TCONF, "%s:%d: %s not found in $PATH", file, lineno, argv[0]);
> +		break;
> +	default:
> +		tst_brk(TBROK, "%s:%d: %s failed (%d)", file, lineno, rc);
typo, rc -> rval and  miss  argv[0].
> +	}
> +}
> +#define SAFE_RUNCMD(argv, stdout_path, stderr_path) \
> +	safe_run_cmd(__FILE__, __LINE__, NULL, (argv), (stdout_path), (stderr_path))
I guess we don't need the third argument(NULL).

Best Regards
Yang Xu
> +
>   #endif /* SAFE_MACROS_H__ */
> 



  parent reply	other threads:[~2020-03-23  2:43 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-20 13:49 [LTP] [PATCH 1/2] lib: Implement SAFE_RUN() macro (new API only) Petr Vorel
2020-03-20 13:49 ` [LTP] [PATCH 2/2] Use SAFE_RUNCMD() Petr Vorel
2020-03-23  3:13   ` Yang Xu
2020-03-23  9:04     ` Petr Vorel
2020-03-23  9:10   ` Li Wang
2020-03-23  9:52     ` Yang Xu
2020-03-23 11:37       ` Petr Vorel
2020-03-23 13:42         ` Li Wang
2020-03-23 14:32           ` Li Wang
2020-03-23 16:04             ` Petr Vorel
2020-03-24 23:51               ` Cyril Hrubis
2020-03-24 17:21                 ` Petr Vorel
2020-03-25  1:53                   ` Cyril Hrubis
2020-03-24 18:55                     ` Petr Vorel
2020-03-25  5:56                       ` Li Wang
2020-03-25  5:30                     ` Li Wang
2020-03-25 17:07                       ` Cyril Hrubis
2020-03-25  9:34                         ` Petr Vorel
2020-03-25 10:03                           ` Cyril Hrubis
2020-03-25 15:40                             ` Petr Vorel
2020-03-25 10:42                           ` Yang Xu
2020-03-25 15:56                             ` Petr Vorel
2020-03-26  5:27                               ` Li Wang
2020-03-26  8:03                               ` Yang Xu
2020-03-23 15:49           ` Petr Vorel
2020-03-24  6:27             ` Li Wang
2020-03-23  2:43 ` Yang Xu [this message]
2020-03-23  9:20   ` [LTP] [PATCH 1/2] lib: Implement SAFE_RUN() macro (new API only) Petr Vorel

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=edd8ed18-8cb3-2a13-7caa-a55c3447389a@cn.fujitsu.com \
    --to=xuyang2018.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.