public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Andrea Cervesato via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] containers/utsname04: don't use TST_EXP_EQ_LI for tst_clone
Date: Tue, 28 Feb 2023 10:06:32 +0100	[thread overview]
Message-ID: <13c9ecd8-48d7-dccc-a3b7-ec934e2f1369@suse.com> (raw)
In-Reply-To: <1677573864-5319-1-git-send-email-xuyang2018.jy@fujitsu.com>

Hi!

On 2/28/23 09:44, Yang Xu wrote:

> For old kernel that doesn't support clone3, tst_clone returns
it would be nice to add unsupported kernel version inside patch comment 
(in this case, anything below 5.3).
> -2 instead of -1. So we can't use TST_EXP_EQ_LI api.
>
> Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
> ---
>   testcases/kernel/containers/utsname/utsname04.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/testcases/kernel/containers/utsname/utsname04.c b/testcases/kernel/containers/utsname/utsname04.c
> index e8d636d0d..1adc4542c 100644
> --- a/testcases/kernel/containers/utsname/utsname04.c
> +++ b/testcases/kernel/containers/utsname/utsname04.c
> @@ -22,6 +22,7 @@ static void run(void)
>   {
>   	const struct tst_clone_args cargs = { CLONE_NEWUTS, SIGCHLD };
>   	struct passwd *pw;
> +	pid_t pid;
>   
>   	tst_res(TINFO, "Dropping root privileges");
>   
> @@ -29,7 +30,11 @@ static void run(void)
>   	SAFE_SETRESUID(pw->pw_uid, pw->pw_uid, pw->pw_uid);
>   
>   	if (!str_op || !strcmp(str_op, "clone")) {
> -		TST_EXP_EQ_LI(tst_clone(&cargs), -1);

Did you try this?

TST_EXP_FAIL(tst_clone(&cargs), EPERM);

> +		pid = tst_clone(&cargs);
> +		if (pid == -1 || pid == -2)
> +			tst_res(TPASS, "clone() returns an expected value %d", pid);
> +		else
> +			tst_res(TFAIL, "clone() returns an unexpected value %d", pid);
>   		TST_EXP_PASS(errno == EPERM);
>   	} else {
>   		if (!SAFE_FORK()) {

Regards,
Andrea


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

  reply	other threads:[~2023-02-28  9:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-28  8:44 [LTP] [PATCH] containers/utsname04: don't use TST_EXP_EQ_LI for tst_clone Yang Xu
2023-02-28  9:06 ` Andrea Cervesato via ltp [this message]
2023-02-28  9:18   ` xuyang2018.jy
2023-02-28  9:39     ` Cyril Hrubis
2023-03-03  6:11       ` xuyang2018.jy
2023-03-06 14:10         ` Richard Palethorpe
2023-03-07  6:09           ` [LTP] [PATCH v2] " Yang Xu
2023-03-07  8:35             ` Richard Palethorpe
2023-03-07 10:16               ` Richard Palethorpe

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=13c9ecd8-48d7-dccc-a3b7-ec934e2f1369@suse.com \
    --to=ltp@lists.linux.it \
    --cc=andrea.cervesato@suse.com \
    /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