public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/getpriority01: Check the returned prio values in a range.
@ 2016-11-24  8:19 Guangwen Feng
  2016-11-24  8:55 ` Cyril Hrubis
  0 siblings, 1 reply; 2+ messages in thread
From: Guangwen Feng @ 2016-11-24  8:19 UTC (permalink / raw)
  To: ltp

Verify that the priority values returned by getpriority(2) are
in the range of [0, 0], [0, 0] and [-20, 0] by default for the
flags PRIO_PROCESS, PRIO_PGRP and PRIO_USER respectively.

Signed-off-by: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
---
 .../kernel/syscalls/getpriority/getpriority01.c    | 25 ++++++++++++++++------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/testcases/kernel/syscalls/getpriority/getpriority01.c b/testcases/kernel/syscalls/getpriority/getpriority01.c
index cca88a7..6edf39d 100644
--- a/testcases/kernel/syscalls/getpriority/getpriority01.c
+++ b/testcases/kernel/syscalls/getpriority/getpriority01.c
@@ -19,7 +19,9 @@
 
 /*
  * Verify that getpriority(2) succeeds get the scheduling priority of
- * the current process, process group or user.
+ * the current process, process group or user, and the priority values
+ * are in the ranges of [0, 0], [0, 0] and [-20, 0] by default for the
+ * flags PRIO_PROCESS, PRIO_PGRP and PRIO_USER respectively.
  */
 
 #include <errno.h>
@@ -29,10 +31,12 @@
 
 static struct tcase {
 	int which;
+	int min;
+	int max;
 } tcases[] = {
-	{PRIO_PROCESS},
-	{PRIO_PGRP},
-	{PRIO_USER}
+	{PRIO_PROCESS, 0, 0},
+	{PRIO_PGRP, 0, 0},
+	{PRIO_USER, -20, 0}
 };
 
 static void verify_getpriority(unsigned int n)
@@ -41,9 +45,16 @@ static void verify_getpriority(unsigned int n)
 
 	TEST(getpriority(tc->which, 0));
 
-	if (TEST_RETURN != 0 || TEST_ERRNO != 0) {
-		tst_res(TFAIL | TTERRNO, "getpriority(%d, 0) returned %ld",
-			tc->which, TEST_RETURN);
+	if (TEST_ERRNO != 0) {
+		tst_res(TFAIL | TTERRNO, "getpriority(%d, 0) failed",
+			tc->which);
+		return;
+	}
+
+	if (TEST_RETURN < tc->min || TEST_RETURN > tc->max) {
+		tst_res(TFAIL, "getpriority(%d, 0) returned %ld, "
+			"expected in the range of [%d, %d]",
+			tc->which, TEST_RETURN, tc->min, tc->max);
 		return;
 	}
 
-- 
1.8.4.2




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

* [LTP] [PATCH] syscalls/getpriority01: Check the returned prio values in a range.
  2016-11-24  8:19 [LTP] [PATCH] syscalls/getpriority01: Check the returned prio values in a range Guangwen Feng
@ 2016-11-24  8:55 ` Cyril Hrubis
  0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2016-11-24  8:55 UTC (permalink / raw)
  To: ltp

Hi!
Pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

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

end of thread, other threads:[~2016-11-24  8:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-24  8:19 [LTP] [PATCH] syscalls/getpriority01: Check the returned prio values in a range Guangwen Feng
2016-11-24  8:55 ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox