[LTP] [PATCH V2] syscalls/sched_rr_get_interval: Validate the timeslice

Viresh Kumar viresh.kumar@linaro.org
Mon Jul 6 05:31:53 CEST 2020


Validate the timespec returned by sched_rr_get_interval() against the
value read from /proc/sys/kernel/sched_rr_timeslice_ms.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
V2:
- Add .tags entry
- check if file is present or not.

 .../sched_rr_get_interval01.c                     | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c
index 31d7b5d56a52..0466be36bec0 100644
--- a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c
+++ b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c
@@ -5,11 +5,18 @@
  *
  * Gets round-robin time quantum by calling sched_rr_get_interval() and
  * checks that the value is sane.
+ *
+ * It is also a regression test for kernel
+ * commit 975e155ed873 ("sched/rt: Show the 'sched_rr_timeslice' SCHED_RR
+ * timeslice tuning knob in milliseconds").
  */
 
 #include <sched.h>
 #include "tst_timer.h"
 
+#define PROC_SCHED_RR_TIMESLICE_MS	"/proc/sys/kernel/sched_rr_timeslice_ms"
+static int proc_flag;
+
 struct tst_ts tp;
 
 static struct test_variants {
@@ -39,6 +46,8 @@ static void setup(void)
 
 	if ((sched_setscheduler(0, SCHED_RR, &p)) == -1)
 		tst_res(TFAIL | TTERRNO, "sched_setscheduler() failed");
+
+	proc_flag = !access(PROC_SCHED_RR_TIMESLICE_MS, F_OK);
 }
 
 static void run(void)
@@ -62,6 +71,8 @@ static void run(void)
 		        tst_ts_get_sec(tp), tst_ts_get_nsec(tp));
 	}
 
+	if (proc_flag)
+		TST_ASSERT_INT("/proc/sys/kernel/sched_rr_timeslice_ms", tst_ts_to_ms(tp));
 }
 
 static struct tst_test test = {
@@ -69,4 +80,8 @@ static struct tst_test test = {
 	.test_variants = ARRAY_SIZE(variants),
 	.setup = setup,
 	.needs_root = 1,
+	.tags = (const struct tst_tag[]) {
+		{"linux-git", "975e155ed873"},
+		{}
+	}
 };
-- 
2.25.0.rc1.19.g042ed3e048af



More information about the ltp mailing list