public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Richard Palethorpe <rpalethorpe@suse.de>
To: Zhao Gongyi <zhaogongyi@huawei.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2 1/2] syscalls/nice06: new test for nice()
Date: Mon, 24 Oct 2022 12:27:17 +0100	[thread overview]
Message-ID: <87a65lzcjc.fsf@suse.de> (raw)
In-Reply-To: <20221020125747.231509-2-zhaogongyi@huawei.com>

Hello,

Zhao Gongyi via ltp <ltp@lists.linux.it> writes:

> Verify that user of root can decrease the nice value of
> the process successfully by passing a lower increment
> value (< min. applicable limits) to nice() system call.
>
> Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
> ---
>  runtest/syscalls                          |  1 +
>  testcases/kernel/syscalls/nice/.gitignore |  1 +
>  testcases/kernel/syscalls/nice/nice06.c   | 54 +++++++++++++++++++++++
>  3 files changed, 56 insertions(+)
>  create mode 100644 testcases/kernel/syscalls/nice/nice06.c
>
> diff --git a/runtest/syscalls b/runtest/syscalls
> index a52b93c92..557c946ec 100644
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -902,6 +902,7 @@ nice02 nice02
>  nice03 nice03
>  nice04 nice04
>  nice05 nice05
> +nice06 nice06

Ah I see you resubmitted nice05 with a new test name. Please see
my comments on V1.

>
>  open01 open01
>  open01A symlink01 -T open01
> diff --git a/testcases/kernel/syscalls/nice/.gitignore b/testcases/kernel/syscalls/nice/.gitignore
> index 58d64779e..c96064cdf 100644
> --- a/testcases/kernel/syscalls/nice/.gitignore
> +++ b/testcases/kernel/syscalls/nice/.gitignore
> @@ -3,3 +3,4 @@
>  /nice03
>  /nice04
>  /nice05
> +/nice06
> diff --git a/testcases/kernel/syscalls/nice/nice06.c b/testcases/kernel/syscalls/nice/nice06.c
> new file mode 100644
> index 000000000..92138f21e
> --- /dev/null
> +++ b/testcases/kernel/syscalls/nice/nice06.c
> @@ -0,0 +1,54 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright(c) 2022 Huawei Technologies Co., Ltd
> + * Author: Zhao Gongyi <zhaogongyi@huawei.com>
> + */
> +
> +/*\
> + * [Description]
> + *
> + * Verify that user of root can decrease the nice value of
> + * the process successfully by passing a lower increment
> + * value (< min. applicable limits) to nice() system call.
> + */
> +#include <unistd.h>
> +#include "tst_test.h"
> +
> +#define	NICEINC -50
> +#define MIN_PRIO  -20
> +#define DEFAULT_PRIO 0
> +
> +static void verify_nice(void)
> +{
> +	int new_nice;
> +
> +	TEST(nice(NICEINC));
> +	if (TST_RET == -1) {
> +		tst_res(TFAIL | TTERRNO, "nice(%d) returned -1", NICEINC);
> +		return;
> +	}
> +
> +	if (TST_ERR) {
> +		tst_res(TFAIL | TTERRNO, "nice(%d) failed", NICEINC);
> +		return;
> +	}
> +
> +	new_nice = SAFE_GETPRIORITY(PRIO_PROCESS, 0);
> +
> +	if (new_nice != MIN_PRIO) {
> +		tst_res(TFAIL, "Process priority %i, expected %i",
> +			new_nice, MIN_PRIO);
> +		return;
> +	}
> +
> +	tst_res(TPASS, "nice(%d) passed", NICEINC);
> +
> +	TEST(nice(DEFAULT_PRIO));
> +	if (TST_ERR)
> +		tst_brk(TBROK | TTERRNO, "nice(%d) failed", DEFAULT_PRIO);
> +}
> +
> +static struct tst_test test = {
> +	.test_all = verify_nice,
> +	.needs_root = 1,
> +};
> --
> 2.17.1


-- 
Thank you,
Richard.

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

  reply	other threads:[~2022-10-24 11:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-20 12:57 [LTP] [PATCH v2 0/2] new test for nice() Zhao Gongyi via ltp
2022-10-20 12:57 ` [LTP] [PATCH v2 1/2] syscalls/nice06: " Zhao Gongyi via ltp
2022-10-24 11:27   ` Richard Palethorpe [this message]
2022-10-20 12:57 ` [LTP] [PATCH v2 2/2] syscalls/nice07: " Zhao Gongyi via ltp

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=87a65lzcjc.fsf@suse.de \
    --to=rpalethorpe@suse.de \
    --cc=ltp@lists.linux.it \
    --cc=zhaogongyi@huawei.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