All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 2/3] syscalls/alarm03: Rewrite to new library
Date: Wed, 25 Jul 2018 16:20:30 +0200	[thread overview]
Message-ID: <20180725142030.GC23890@rei> (raw)
In-Reply-To: <1532431855-18452-2-git-send-email-huangjh.jy@cn.fujitsu.com>

Hi!
> +	TEST(alarm(100));
> +
> +	pid = SAFE_FORK();
> +	if (pid == 0) {
> +		TEST(alarm(0));
> +		if (TEST_RETURN != 0) {
> +			tst_res(TFAIL,
> +				"alarm(100), fork, alarm(0) child's "
> +				"alarm returned %ld", TEST_RETURN);
> +		} else {
> +			tst_res(TPASS,
> +				"alarm(100), fork, alarm(0) child's "
> +				"alarm returned %ld", TEST_RETURN);
>  		}
> -
> +		exit(0);
> +	} else {
> +		TEST(alarm(0));
> +		if (TEST_RETURN <= 0 || TEST_RETURN > 101) {
> +			tst_res(TFAIL,
> +				"alarm(100), fork, alarm(0) parent's "
> +				"alarm returned %ld", TEST_RETURN);
> +		} else {
> +			tst_res(TPASS,
> +				"alarm(100), fork, alarm(0) parent's "
> +				"alarm returned %ld", TEST_RETURN);
> +		}
> +		tst_reap_children();

There is no need for the else branch here as the child calls exit(0);

>  }
>  
> -void setup(void)
> +static void sighandler(int sig LTP_ATTRIBUTE_UNUSED)
>  {
> -
> -	tst_sig(FORK, DEF_HANDLER, cleanup);
> -
> -	signal(SIGALRM, trapper);
> -
> -	TEST_PAUSE;
> +	SAFE_SIGNAL(SIGALRM, sighandler);

I do wonder why do we call the SAFE_SIGNAL() here?

It does not make much sense.

>  }
>  
> -void cleanup(void)
> +static void setup(void)
>  {
> +	SAFE_SIGNAL(SIGALRM, sighandler);
>  }
>  
> -void trapper(int sig)
> -{
> -	signal(SIGALRM, trapper);
> -}
> +static struct tst_test test = {
> +	.test_all = verify_alarm,
> +	.setup = setup,
> +	.forks_child = 1,
> +};
> -- 
> 1.8.3.1
> 
> 
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2018-07-25 14:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-24 11:30 [LTP] [PATCH 1/3] syscalls/alarm02: Rewrite to new library Jinhui huang
2018-07-24 11:30 ` [LTP] [PATCH 2/3] syscalls/alarm03: " Jinhui huang
2018-07-25 14:20   ` Cyril Hrubis [this message]
2018-07-25 14:52     ` Cyril Hrubis
2018-07-24 11:30 ` [LTP] [PATCH 3/3] syscalls/alarm07: " Jinhui huang
2018-07-25 13:48 ` [LTP] [PATCH 1/3] syscalls/alarm02: " Cyril Hrubis
2018-07-26  5:32   ` [LTP] [PATCH v2 1/2] " Jinhui huang
2018-07-26  5:32     ` [LTP] [PATCH v2 2/2] syscalls/alarm03: " Jinhui huang
2018-08-02 15:54     ` [LTP] [PATCH v2 1/2] syscalls/alarm02: " Cyril Hrubis
2018-08-06  5:11       ` [LTP] [PATCH v3] " Jinhui huang
2018-08-07  9:16         ` 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=20180725142030.GC23890@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 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.