All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/nice: Adjust the expected priority after calling nice()
@ 2022-08-25 12:50 Zhao Gongyi via ltp
  2022-09-21 14:53 ` Cyril Hrubis
  0 siblings, 1 reply; 2+ messages in thread
From: Zhao Gongyi via ltp @ 2022-08-25 12:50 UTC (permalink / raw)
  To: ltp

If we run test as nice -n -10 ./nice01, it will fail and report:

nice01.c:37: TFAIL: nice(-12) returned -20, expected -22: SUCCESS (0)

for nice01.c/nice02.c: correct log info.

Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
 testcases/kernel/syscalls/nice/nice01.c | 14 +++++++++-----
 testcases/kernel/syscalls/nice/nice02.c |  2 +-
 testcases/kernel/syscalls/nice/nice03.c |  7 +++++--
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/testcases/kernel/syscalls/nice/nice01.c b/testcases/kernel/syscalls/nice/nice01.c
index ee360bfbf..876246180 100644
--- a/testcases/kernel/syscalls/nice/nice01.c
+++ b/testcases/kernel/syscalls/nice/nice01.c
@@ -18,19 +18,23 @@
 #include "tst_test.h"

 #define	NICEINC		-12
+#define MIN_PRIO	-20

 static void verify_nice(void)
 {
 	int new_nice;
 	int orig_nice;
+	int exp_nice;

 	orig_nice = SAFE_GETPRIORITY(PRIO_PROCESS, 0);

 	TEST(nice(NICEINC));

-	if (TST_RET != (orig_nice + NICEINC)) {
+	exp_nice = MAX(MIN_PRIO, (orig_nice + NICEINC));
+
+	if (TST_RET != exp_nice) {
 		tst_res(TFAIL | TTERRNO, "nice(%d) returned %li, expected %i",
-			NICEINC, TST_RET, orig_nice + NICEINC);
+			NICEINC, TST_RET, exp_nice);
 		return;
 	}

@@ -41,9 +45,9 @@ static void verify_nice(void)

 	new_nice = SAFE_GETPRIORITY(PRIO_PROCESS, 0);

-	if (new_nice != (orig_nice + NICEINC)) {
+	if (new_nice != exp_nice) {
 		tst_res(TFAIL, "Process priority %i, expected %i",
-		        new_nice, orig_nice + NICEINC);
+				new_nice, orig_nice + NICEINC);
 		return;
 	}

@@ -51,7 +55,7 @@ static void verify_nice(void)

 	TEST(nice(-NICEINC));
 	if (TST_ERR)
-		tst_brk(TBROK | TTERRNO, "nice(-NICEINC) failed");
+		tst_brk(TBROK | TTERRNO, "nice(%d) failed", -NICEINC);
 }

 static struct tst_test test = {
diff --git a/testcases/kernel/syscalls/nice/nice02.c b/testcases/kernel/syscalls/nice/nice02.c
index 1c7103758..b08e1d751 100644
--- a/testcases/kernel/syscalls/nice/nice02.c
+++ b/testcases/kernel/syscalls/nice/nice02.c
@@ -50,7 +50,7 @@ static void verify_nice(void)

 	TEST(nice(DEFAULT_PRIO));
 	if (TST_ERR)
-		tst_brk(TBROK | TTERRNO, "nice(-NICEINC) failed");
+		tst_brk(TBROK | TTERRNO, "nice(%d) failed", DEFAULT_PRIO);
 }

 static struct tst_test test = {
diff --git a/testcases/kernel/syscalls/nice/nice03.c b/testcases/kernel/syscalls/nice/nice03.c
index 8198f2cf0..061592e6c 100644
--- a/testcases/kernel/syscalls/nice/nice03.c
+++ b/testcases/kernel/syscalls/nice/nice03.c
@@ -19,11 +19,13 @@
 #include "tst_test.h"

 #define	NICEINC	2
+#define MAX_PRIO 19

 static void nice_test(void)
 {
 	int new_nice;
 	int orig_nice;
+	int exp_nice;

 	orig_nice = SAFE_GETPRIORITY(PRIO_PROCESS, 0);

@@ -40,10 +42,11 @@ static void nice_test(void)
 	}

 	new_nice = SAFE_GETPRIORITY(PRIO_PROCESS, 0);
+	exp_nice = MIN(MAX_PRIO, (orig_nice + NICEINC));

-	if (new_nice != (orig_nice + NICEINC)) {
+	if (new_nice != exp_nice) {
 		tst_res(TFAIL, "Process priority %i, expected %i",
-		        new_nice, orig_nice + NICEINC);
+				new_nice, exp_nice);
 		return;
 	}

--
2.17.1


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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [LTP] [PATCH] syscalls/nice: Adjust the expected priority after calling nice()
  2022-08-25 12:50 [LTP] [PATCH] syscalls/nice: Adjust the expected priority after calling nice() Zhao Gongyi via ltp
@ 2022-09-21 14:53 ` Cyril Hrubis
  0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2022-09-21 14:53 UTC (permalink / raw)
  To: Zhao Gongyi; +Cc: ltp

Hi!
Pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-21 14:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-25 12:50 [LTP] [PATCH] syscalls/nice: Adjust the expected priority after calling nice() Zhao Gongyi via ltp
2022-09-21 14:53 ` Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.