From: Sandeep Patil <sspatil@android.com>
To: ltp@lists.linux.it
Subject: [LTP] [RFC PATCH 1/4] syscalls/abort01: convert to new library
Date: Tue, 26 Mar 2019 21:47:43 +0900 [thread overview]
Message-ID: <20190326124743.GC5826@google.com> (raw)
In-Reply-To: <20190326115825.GA32549@rei.lan>
On Tue, Mar 26, 2019 at 12:58:25PM +0100, Cyril Hrubis wrote:
> Hi!
> I've further simplified the test and pushed, thanks.
>
> What I have done:
>
> * Got rid of tst_brk(TFAIL, ...) calls
> see: https://github.com/linux-test-project/ltp/issues/462
Thanks for this, it is good to know. What is the recommended replacement?
tst_res()?
>
> * Used tst_strsig() and tst_strstatus() to print signal and status
>
> * Used tst_res() API in the child
>
> * Got rid of unused variables, etc.
I am surprised that didn't throw a warning + build error for me.
other than that, thanks for doing this
>
> diff --git a/testcases/kernel/syscalls/abort/abort01.c b/testcases/kernel/syscalls/abort/abort01.c
> index ac5ddb140..386a22f26 100644
> --- a/testcases/kernel/syscalls/abort/abort01.c
> +++ b/testcases/kernel/syscalls/abort/abort01.c
> @@ -27,51 +27,45 @@
> static void do_child(void)
> {
> abort();
> - fprintf(stderr, "\tchild - abort failed.\n");
> - exit(1);
> + tst_res(TFAIL, "Abort returned");
> + exit(0);
> }
>
> -void verify_abort(unsigned int nr)
> +void verify_abort(void)
> {
> - int i;
> - int status, child, kidpid;
> - int sig, ex;
> - int core;
> - core = ex = sig = 0;
> + int status, kidpid;
> + int sig, core;
>
> kidpid = SAFE_FORK();
> if (kidpid == 0)
> do_child();
>
> - child = SAFE_WAIT(&status);
> -
> - if (WIFSIGNALED(status)) {
> - core = WCOREDUMP(status);
> - sig = WTERMSIG(status);
> + SAFE_WAIT(&status);
>
> + if (!WIFSIGNALED(status)) {
> + tst_res(TFAIL, "Child %s, expected SIGIOT",
> + tst_strstatus(status));
> + return;
> }
>
> - if (WIFEXITED(status))
> - ex = WEXITSTATUS(status);
> + core = WCOREDUMP(status);
> + sig = WTERMSIG(status);
>
> if (core == 0)
> - tst_brk(TFAIL,
> - "Missing core dump; exit(%d), signal(%d)",
> - ex, sig);
> - else if (core != -1)
> + tst_res(TFAIL, "abort() failed to dump core");
> + else
> tst_res(TPASS, "abort() dumped core");
>
> if (sig == SIGIOT)
> tst_res(TPASS, "abort() raised SIGIOT");
> else
> - tst_brk(TFAIL,
> - "Unexpected signal(%d), expected SIGIOT(%d)",
> - sig, SIGIOT);
> + tst_res(TFAIL, "abort() raised %s", tst_strsig(sig));
> }
>
> +#define MIN_RLIMIT_CORE (1024 * 1024)
> +
> static void setup(void)
> {
> -#define MIN_RLIMIT_CORE (1024 * 1024)
> struct rlimit rlim;
>
> /* make sure we get core dumps */
> @@ -83,9 +77,8 @@ static void setup(void)
> }
>
> static struct tst_test test = {
> - .tcnt = 3,
> .needs_tmpdir = 1,
> .forks_child = 1,
> .setup = setup,
> - .test = verify_abort,
> + .test_all = verify_abort,
> };
>
>
> --
> Cyril Hrubis
> chrubis@suse.cz
next prev parent reply other threads:[~2019-03-26 12:47 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-25 23:20 [LTP] [PATCH 0/4] Convert tests to use new library Sandeep Patil
2019-03-25 23:20 ` [LTP] [RFC PATCH 1/4] syscalls/abort01: convert to " Sandeep Patil
2019-03-26 11:58 ` Cyril Hrubis
2019-03-26 12:47 ` Sandeep Patil [this message]
2019-03-26 12:51 ` Cyril Hrubis
2019-03-28 4:07 ` Sandeep Patil
2019-04-03 12:06 ` Cyril Hrubis
2019-04-03 15:49 ` Sandeep Patil
2019-03-25 23:20 ` [LTP] [PATCH 2/4] syscalls/accept01: " Sandeep Patil
2019-03-26 12:35 ` Cyril Hrubis
2019-03-26 12:44 ` Sandeep Patil
2019-03-25 23:20 ` [LTP] [PATCH 3/4] syscalls/accept4: " Sandeep Patil
2019-03-26 15:33 ` Cyril Hrubis
2019-03-25 23:20 ` [LTP] [PATCH 4/4] syscalls/acct01: " Sandeep Patil
2019-03-26 16:11 ` Cyril Hrubis
2019-03-26 9:42 ` [LTP] [PATCH 0/4] Convert tests to use " Cyril Hrubis
2019-03-26 12:48 ` Sandeep Patil
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=20190326124743.GC5826@google.com \
--to=sspatil@android.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