public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Jan Stancek <jstancek@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [RFC PATCH] lib: add tst_no_corefile to avoid corefile dumping
Date: Mon, 1 Jul 2019 07:01:36 -0400 (EDT)	[thread overview]
Message-ID: <2137465502.31003797.1561978896804.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20190701100343.3406-1-liwang@redhat.com>



----- Original Message -----
> Signed-off-by: Li Wang <liwang@redhat.com>
> Cc: Jan Stancek <jstancek@redhat.com>
> ---
>  include/tst_safe_macros.h                        | 16 ++++++++++++++++
>  testcases/kernel/security/umip/umip_basic_test.c |  2 ++
>  testcases/kernel/syscalls/ipc/shmat/shmat01.c    | 16 +++-------------
>  3 files changed, 21 insertions(+), 13 deletions(-)
> 
> diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
> index 53a888c80..110e2984f 100644
> --- a/include/tst_safe_macros.h
> +++ b/include/tst_safe_macros.h
> @@ -394,6 +394,22 @@ static inline int safe_setrlimit(const char *file, const
> int lineno,
>  #define SAFE_SETRLIMIT(resource, rlim) \
>  	safe_setrlimit(__FILE__, __LINE__, (resource), (rlim))
>  
> +/*
> + * Crash is expected, avoid dumping corefile.
> + * 1 is a special value, that disables core-to-pipe.
> + * At the same time it is small enough value for
> + * core-to-file, so it skips creating cores as well.
> + */
> +static inline void tst_no_corefile(void)
> +{
> +       struct rlimit r;
> +
> +       r.rlim_cur = 1;
> +       r.rlim_max = 1;
> +       SAFE_SETRLIMIT(RLIMIT_CORE, &r);
> +       tst_res(TINFO, "Avoid dumping corefile in following test");

I'm fine with helper func. Maybe I'd print also current pid.
It could be little spammy if there are many children, but we could
address that later (if needed) with a parameter to control verbosity.

  reply	other threads:[~2019-07-01 11:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-01 10:03 [LTP] [RFC PATCH] lib: add tst_no_corefile to avoid corefile dumping Li Wang
2019-07-01 11:01 ` Jan Stancek [this message]
2019-07-02  7:53   ` Li Wang
2019-07-02 16:11     ` Jan Stancek
2019-07-03  3:37       ` Li Wang

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=2137465502.31003797.1561978896804.JavaMail.zimbra@redhat.com \
    --to=jstancek@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox