All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v1] Refactor pidns16 test using new LTP API
Date: Fri, 12 Aug 2022 17:30:10 +0200	[thread overview]
Message-ID: <YvZyAt0QGnRZMirP@pevik> (raw)
In-Reply-To: <20220808125025.15167-1-andrea.cervesato@suse.com>

Hi Andrea,

...
> +/*\
> + * [Description]
> + *
> + * Clone a process with CLONE_NEWPID flag and verifies that siginfo->si_pid is
You need to quote variable with +, i.e. +siginfo->si_pid+, otherwise
formatting show siginfo→si_pid instead of siginfo->si_pid.

> + * set to 0 if sender (parent process) sent the signal. Then send signal from
> + * container itself and check if siginfo->si_pid is set to 1.
and here as well.
> + */

>  #define _GNU_SOURCE 1
Do we really need _GNU_SOURCE? Why?

...
> +static int counter;
Shouldn't this be volatile? And maybe also sig_atomic_t instead of int (even
it's the same)?
static volatile sig_atomic_t counter;

> -char *TCID = "pidns16";
> -int TST_TOTAL = 3;
> -
> -void child_signal_handler(int sig, siginfo_t * si, void *unused)
> +static void child_signal_handler(LTP_ATTRIBUTE_UNUSED int sig, siginfo_t *si, LTP_ATTRIBUTE_UNUSED void *unused)
>  {
> -	static int c = 1;
> -	pid_t expected_pid;
> -
> -	/* Verifying from which process the signal handler is signalled */
> +	pid_t exp_pid;

> -	switch (c) {
> -	case 1:
> -		expected_pid = PARENT_PID;
> +	switch (counter) {
> +	case 0:
> +		exp_pid = 0;
>  		break;
> -	case 2:
> -		expected_pid = CHILD_PID;
> +	case 1:
> +		exp_pid = 1;
>  		break;
>  	default:
> -		tst_resm(TBROK, "child should NOT be signalled 3+ times");
> +		tst_brk(TBROK, "Child should NOT be signalled 3+ times");
>  		return;
>  	}

very nit: I'd use if (counter 
if (counter > 1) {
	tst_brk(TBROK, "Child should NOT be signalled 3+ times");
	return;
}
exp_pid = counter;

> +	if (si->si_pid == exp_pid)
> +		tst_res(TPASS, "Signalling PID is %d as expected", exp_pid);
>  	else
> +		tst_res(TFAIL, "Signalling PID is not %d, but %d", exp_pid, si->si_pid);
nit: use TST_EXP_PASS()

...
> +	if (cpid != 1 || ppid != 0) {
> +		tst_res(TFAIL, "Got unexpected result of cpid=%d ppid=%d", cpid, ppid);
> +		return 1;
> +	}
nit: maybe easier for reviewer if these two failures are handled separately.

I also hope we sooner or later get rid of ltp_clone_quick() in favor of
tst_clone(). Not sure where ended the discussion about it, from [1] it looks
like it's needed now. It can wait for another result after we manage to merge
pidns and mqns rewrites.

The rest LGTM. Thanks for your tireless work on rewriting LTP!

Kind regards,
Petr

[1] https://lore.kernel.org/ltp/945eb0ee-b346-5729-3dda-4bff39bb52d9@suse.com/

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2022-08-12 15:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-08 12:50 [LTP] [PATCH v1] Refactor pidns16 test using new LTP API Andrea Cervesato via ltp
2022-08-12 15:30 ` Petr Vorel [this message]
2022-08-15 14:00   ` 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=YvZyAt0QGnRZMirP@pevik \
    --to=pvorel@suse.cz \
    --cc=andrea.cervesato@suse.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.