public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: zhaogongyi via ltp <ltp@lists.linux.it>
To: "rpalethorpe@suse.de" <rpalethorpe@suse.de>
Cc: "ltp@lists.linux.it" <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH 1/2] syscalls/nice05: new test for nice()
Date: Wed, 16 Nov 2022 03:57:46 +0000	[thread overview]
Message-ID: <79ad7aa50e204033afa1edb70fb83d96@huawei.com> (raw)

Hi!

> 
> Hi,
> 
> >
> > 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/nice05.c   | 54
> > +++++++++++++++++++++++
> > >  3 files changed, 56 insertions(+)
> > >  create mode 100644 testcases/kernel/syscalls/nice/nice05.c
> > >
> > > diff --git a/runtest/syscalls b/runtest/syscalls index
> > > bd74373a4..7db399375 100644
> > > --- a/runtest/syscalls
> > > +++ b/runtest/syscalls
> > > @@ -902,6 +902,7 @@ nice01 nice01
> > >  nice02 nice02
> > >  nice03 nice03
> > >  nice04 nice04
> > > +nice05 nice05
> >
> > 05 has already been taken. Also this test is very similar to nice01.
> > Maybe it could be added to that?
> 
> It seems better that move to nice01, thanks!
> 
> >
> > >
> > >  open01 open01
> > >  open01A symlink01 -T open01
> > > diff --git a/testcases/kernel/syscalls/nice/.gitignore
> > > b/testcases/kernel/syscalls/nice/.gitignore
> > > index 9d7a1bb43..58d64779e 100644
> > > --- a/testcases/kernel/syscalls/nice/.gitignore
> > > +++ b/testcases/kernel/syscalls/nice/.gitignore
> > > @@ -2,3 +2,4 @@
> > >  /nice02
> > >  /nice03
> > >  /nice04
> > > +/nice05
> > > diff --git a/testcases/kernel/syscalls/nice/nice05.c
> > > b/testcases/kernel/syscalls/nice/nice05.c
> > > new file mode 100644
> > > index 000000000..85f10fadf
> > > --- /dev/null
> > > +++ b/testcases/kernel/syscalls/nice/nice05.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));
> >
> > Why not use one of the TST_EXP* macros?
> 
> The errno seems difficult to check in TST_EXP*, TST_EXP_PASS have no
> checking of errno.
> 
> >
> > > +	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);
> >
> > Again, could use TST_EXP* macro. Also just checking TST_ERR is not
> > strictly correct.
> 
> Similialy, TST_EXP_PASS has no checking of errno also, and it seems that
> check the return value is enough since the return value is not -1.
> 
> Regards,
> Gongyi


I have submit a new patch that move the test to nice01.c, please see: https://patchwork.ozlabs.org/project/ltp/patch/20221116034910.37030-1-zhaogongyi@huawei.com/

Regards,
Gongyi

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

             reply	other threads:[~2022-11-16  3:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-16  3:57 zhaogongyi via ltp [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-10-26  8:54 [LTP] [PATCH 1/2] syscalls/nice05: new test for nice() zhaogongyi via ltp
2022-10-14  3:56 Zhao Gongyi via ltp
2022-10-24 11:07 ` 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=79ad7aa50e204033afa1edb70fb83d96@huawei.com \
    --to=ltp@lists.linux.it \
    --cc=rpalethorpe@suse.de \
    --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