syscalls/nice05: new test for nice()
Hi!
Quoted 117 lines
Hi,
Quoted 18 lines
Hello,
Quoted 9 lines · Zhao Gongyi via ltp
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 <[email protected]>--- runtest/syscalls | 1 + testcases/kernel/syscalls/nice/.gitignore | 1 + testcases/kernel/syscalls/nice/nice05.c | 54+++++++++++++++++++++++
Quoted 3 lines
3 files changed, 56 insertions(+) create mode 100644 testcases/kernel/syscalls/nice/nice05.cQuoted 12 lines
runtest/syscalls nice01 nice01 · line 905
Quoted 9 lines
runtest/syscalls index renamed from runtest/syscalls +0
-0
bd74373a4..7db399375100644runtest/syscalls +1
-0@@ -902,6 +902,7 @@ nice01 nice01 nice02 nice02 nice03 nice03 nice04 nice04 +nice05 nice0505 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!
Quoted 39 lines
Quoted 39 lines
runtest/syscalls +0
-0open01 open01 open01A symlink01 -T open01testcases/kernel/syscalls/nice/.gitignore +1
-0@@ -2,3 +2,4 @@ /nice02 /nice03 /nice04 +/nice05testcases/kernel/syscalls/nice/nice05.c new file +18
-0@@ -0,0 +1,54 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright(c) 2022 Huawei Technologies Co., Ltd +* Author: Zhao Gongyi <[email protected]> */ + +/*\ +* [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 0Quoted 8 lines
testcases/kernel/syscalls/nice/nice05.c line 24
Quoted 6 lines
testcases/kernel/syscalls/nice/nice05.c new file +6
-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_PASShave no checking of errno.Quoted 16 lines
Quoted 6 lines
testcases/kernel/syscalls/nice/nice05.c new file +5
-0+if (TST_RET ==-1 ) { +tst_res (TFAIL |TTERRNO ,"nice(%d) returned -1" ,NICEINC ); +return ; + } +testcases/kernel/syscalls/nice/nice05.c line 39
Quoted 10 lines
testcases/kernel/syscalls/nice/nice05.c new file +10
-0+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);Quoted 4 lines
Quoted 4 lines
testcases/kernel/syscalls/nice/nice05.c new file +4
-0+return ; + } + +tst_res (TPASS ,"nice(%d) passed" ,NICEINC );Quoted 8 lines
Quoted 5 lines
testcases/kernel/syscalls/nice/nice05.c new file +4
-0+ +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_ERRis not strictly correct.
Quoted 5 lines
Similialy,
TST_EXP_PASShas 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/[email protected]/
Regards,
Gongyi
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp