* [LTP] [PATCH] syscalls/nice01: Add test nice(-1) and nice(-50)
@ 2022-11-16 3:49 Zhao Gongyi via ltp
2022-11-28 14:26 ` Richard Palethorpe
0 siblings, 1 reply; 3+ messages in thread
From: Zhao Gongyi via ltp @ 2022-11-16 3:49 UTC (permalink / raw)
To: ltp
1. Add test verify that the errno is zero when callling of nice
legitimately return -1.(nice(-1), the default nice is usally 0)
2. Add test 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.(nice(-50))
Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
testcases/kernel/syscalls/nice/nice01.c | 27 ++++++++++++++-----------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/testcases/kernel/syscalls/nice/nice01.c b/testcases/kernel/syscalls/nice/nice01.c
index 876246180..bc022a265 100644
--- a/testcases/kernel/syscalls/nice/nice01.c
+++ b/testcases/kernel/syscalls/nice/nice01.c
@@ -17,29 +17,31 @@
#include <sys/resource.h>
#include "tst_test.h"
-#define NICEINC -12
-#define MIN_PRIO -20
+#define MIN_PRIO -20
-static void verify_nice(void)
+static int nice_inc[] = {-1, -12, -50};
+
+static void verify_nice(unsigned int i)
{
int new_nice;
int orig_nice;
int exp_nice;
+ int inc = nice_inc[i];
orig_nice = SAFE_GETPRIORITY(PRIO_PROCESS, 0);
- TEST(nice(NICEINC));
+ TEST(nice(inc));
- exp_nice = MAX(MIN_PRIO, (orig_nice + NICEINC));
+ exp_nice = MAX(MIN_PRIO, (orig_nice + inc));
if (TST_RET != exp_nice) {
tst_res(TFAIL | TTERRNO, "nice(%d) returned %li, expected %i",
- NICEINC, TST_RET, exp_nice);
+ inc, TST_RET, exp_nice);
return;
}
if (TST_ERR) {
- tst_res(TFAIL | TTERRNO, "nice(%d) failed", NICEINC);
+ tst_res(TFAIL | TTERRNO, "nice(%d) failed", inc);
return;
}
@@ -47,18 +49,19 @@ static void verify_nice(void)
if (new_nice != exp_nice) {
tst_res(TFAIL, "Process priority %i, expected %i",
- new_nice, orig_nice + NICEINC);
+ new_nice, exp_nice);
return;
}
- tst_res(TPASS, "nice(%d) passed", NICEINC);
+ tst_res(TPASS, "nice(%d) passed", inc);
- TEST(nice(-NICEINC));
+ TEST(setpriority(PRIO_PROCESS, 0, orig_nice));
if (TST_ERR)
- tst_brk(TBROK | TTERRNO, "nice(%d) failed", -NICEINC);
+ tst_brk(TBROK | TTERRNO, "setpriority(%d) failed", orig_nice);
}
static struct tst_test test = {
- .test_all = verify_nice,
.needs_root = 1,
+ .test = verify_nice,
+ .tcnt = ARRAY_SIZE(nice_inc),
};
--
2.17.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH] syscalls/nice01: Add test nice(-1) and nice(-50)
2022-11-16 3:49 Zhao Gongyi via ltp
@ 2022-11-28 14:26 ` Richard Palethorpe
0 siblings, 0 replies; 3+ messages in thread
From: Richard Palethorpe @ 2022-11-28 14:26 UTC (permalink / raw)
To: Zhao Gongyi; +Cc: ltp
Hello,
Zhao Gongyi via ltp <ltp@lists.linux.it> writes:
> 1. Add test verify that the errno is zero when callling of nice
> legitimately return -1.(nice(-1), the default nice is usally 0)
> 2. Add test 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.(nice(-50))
>
> Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
> ---
> testcases/kernel/syscalls/nice/nice01.c | 27 ++++++++++++++-----------
> 1 file changed, 15 insertions(+), 12 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/nice/nice01.c b/testcases/kernel/syscalls/nice/nice01.c
> index 876246180..bc022a265 100644
> --- a/testcases/kernel/syscalls/nice/nice01.c
> +++ b/testcases/kernel/syscalls/nice/nice01.c
> @@ -17,29 +17,31 @@
> #include <sys/resource.h>
> #include "tst_test.h"
>
> -#define NICEINC -12
> -#define MIN_PRIO -20
> +#define MIN_PRIO -20
>
> -static void verify_nice(void)
> +static int nice_inc[] = {-1, -12, -50};
> +
> +static void verify_nice(unsigned int i)
> {
> int new_nice;
> int orig_nice;
> int exp_nice;
> + int inc = nice_inc[i];
>
> orig_nice = SAFE_GETPRIORITY(PRIO_PROCESS, 0);
>
> - TEST(nice(NICEINC));
> + TEST(nice(inc));
>
> - exp_nice = MAX(MIN_PRIO, (orig_nice + NICEINC));
> + exp_nice = MAX(MIN_PRIO, (orig_nice + inc));
>
> if (TST_RET != exp_nice) {
> tst_res(TFAIL | TTERRNO, "nice(%d) returned %li, expected %i",
> - NICEINC, TST_RET, exp_nice);
> + inc, TST_RET, exp_nice);
> return;
> }
>
> if (TST_ERR) {
> - tst_res(TFAIL | TTERRNO, "nice(%d) failed", NICEINC);
> + tst_res(TFAIL | TTERRNO, "nice(%d) failed", inc);
> return;
> }
>
> @@ -47,18 +49,19 @@ static void verify_nice(void)
>
> if (new_nice != exp_nice) {
> tst_res(TFAIL, "Process priority %i, expected %i",
> - new_nice, orig_nice + NICEINC);
> + new_nice, exp_nice);
> return;
> }
>
> - tst_res(TPASS, "nice(%d) passed", NICEINC);
> + tst_res(TPASS, "nice(%d) passed", inc);
>
> - TEST(nice(-NICEINC));
> + TEST(setpriority(PRIO_PROCESS, 0, orig_nice));
This is the nice test not the setpriority test (which also has a SAFE_ variant).
> if (TST_ERR)
> - tst_brk(TBROK | TTERRNO, "nice(%d) failed", -NICEINC);
> + tst_brk(TBROK | TTERRNO, "setpriority(%d) failed", orig_nice);
> }
>
> static struct tst_test test = {
> - .test_all = verify_nice,
> .needs_root = 1,
> + .test = verify_nice,
> + .tcnt = ARRAY_SIZE(nice_inc),
> };
> --
> 2.17.1
--
Thank you,
Richard.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH] syscalls/nice01: Add test nice(-1) and nice(-50)
@ 2022-11-29 8:17 zhaogongyi via ltp
0 siblings, 0 replies; 3+ messages in thread
From: zhaogongyi via ltp @ 2022-11-29 8:17 UTC (permalink / raw)
To: rpalethorpe@suse.de; +Cc: ltp@lists.linux.it
Hi!
> Hello,
>
> Zhao Gongyi via ltp <ltp@lists.linux.it> writes:
>
> > 1. Add test verify that the errno is zero when callling of nice
> > legitimately return -1.(nice(-1), the default nice is usally 0) 2. Add
> > test 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.(nice(-50))
> >
> > Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
> > ---
> > testcases/kernel/syscalls/nice/nice01.c | 27
> > ++++++++++++++-----------
> > 1 file changed, 15 insertions(+), 12 deletions(-)
> >
> > diff --git a/testcases/kernel/syscalls/nice/nice01.c
> > b/testcases/kernel/syscalls/nice/nice01.c
> > index 876246180..bc022a265 100644
> > --- a/testcases/kernel/syscalls/nice/nice01.c
> > +++ b/testcases/kernel/syscalls/nice/nice01.c
> > @@ -17,29 +17,31 @@
> > #include <sys/resource.h>
> > #include "tst_test.h"
> >
> > -#define NICEINC -12
> > -#define MIN_PRIO -20
> > +#define MIN_PRIO -20
> >
> > -static void verify_nice(void)
> > +static int nice_inc[] = {-1, -12, -50};
> > +
> > +static void verify_nice(unsigned int i)
> > {
> > int new_nice;
> > int orig_nice;
> > int exp_nice;
> > + int inc = nice_inc[i];
> >
> > orig_nice = SAFE_GETPRIORITY(PRIO_PROCESS, 0);
> >
> > - TEST(nice(NICEINC));
> > + TEST(nice(inc));
> >
> > - exp_nice = MAX(MIN_PRIO, (orig_nice + NICEINC));
> > + exp_nice = MAX(MIN_PRIO, (orig_nice + inc));
> >
> > if (TST_RET != exp_nice) {
> > tst_res(TFAIL | TTERRNO, "nice(%d) returned %li, expected %i",
> > - NICEINC, TST_RET, exp_nice);
> > + inc, TST_RET, exp_nice);
> > return;
> > }
> >
> > if (TST_ERR) {
> > - tst_res(TFAIL | TTERRNO, "nice(%d) failed", NICEINC);
> > + tst_res(TFAIL | TTERRNO, "nice(%d) failed", inc);
> > return;
> > }
> >
> > @@ -47,18 +49,19 @@ static void verify_nice(void)
> >
> > if (new_nice != exp_nice) {
> > tst_res(TFAIL, "Process priority %i, expected %i",
> > - new_nice, orig_nice + NICEINC);
> > + new_nice, exp_nice);
> > return;
> > }
> >
> > - tst_res(TPASS, "nice(%d) passed", NICEINC);
> > + tst_res(TPASS, "nice(%d) passed", inc);
> >
> > - TEST(nice(-NICEINC));
> > + TEST(setpriority(PRIO_PROCESS, 0, orig_nice));
>
> This is the nice test not the setpriority test (which also has a SAFE_ variant).
>
Thanks, I have submit a v2 patch, please see: https://patchwork.ozlabs.org/project/ltp/patch/20221129081304.47000-1-zhaogongyi@huawei.com/
Regards,
Gongyi
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-11-29 8:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-29 8:17 [LTP] [PATCH] syscalls/nice01: Add test nice(-1) and nice(-50) zhaogongyi via ltp
-- strict thread matches above, loose matches on Subject: below --
2022-11-16 3:49 Zhao Gongyi via ltp
2022-11-28 14:26 ` Richard Palethorpe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox