Re [PATCH] syscalls/sched_setscheduler04: new test for sched_setscheduler()
Hi!
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Review
Quoted 11 lines
Quoted 1 line
+static void
test_sched_setscheduler02(void){(quoted diff) +10
-0+ pthread_t tid; + + SAFE_PTHREAD_CREATE(&tid, NULL, thread_func, NULL); + SAFE_PTHREAD_JOIN(tid, NULL); +} + + +static void run(void) +{ + sched_prio = sched_get_priority_min(SCHED_POLICY);This can go in the setup function.
Quoted 4 lines
Quoted 2 lines
If move it to setup function, we run the test with option "-I 200", it will fail.
Why?
sched_prio is a global variable, and it increase in any running loop, thus it will be out of range and report:
sched_setscheduler04.c:52: TPASS: param.sched_priority == sched_prio (99) sched_setscheduler04.c:53: TPASS: new_policy == EXP_POLICY (1) sched_setscheduler04.c:34: TINFO: Setting of tid: 70774 sched_setscheduler04.c:40: TBROK: sched_setscheduler(70774, 1, ...) failed: EINVAL (22)
Summary:
passed 196 failed 0 broken 1 skipped 0
warnings 0
Quoted 26 lines
Quoted 26 lines
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +3
-0+ + test_sched_setscheduler01(); + test_sched_setscheduler02();This should be replaced with .tcnt = 2 and .test. or else just merge them into run.
Agree, I will fix it int the next version.
Quoted 14 lines
Review
Quoted 5 lines
(quoted diff) +4
-0+} + +static struct tst_test test = { + .test_all = run,We probably need to ensure
CAP_SYS_NICE. Full details are in 'man 7 sched'i.e. .caps = (struct tst_cap[]) {
TST_CAP(TST_CAP_REQ, CAP_SYS_NICE),
null
}
Quoted 6 lines
Quoted 1 line
In this testcase, we just increase the priority, should we add the checking
of capability?
For the test to run we need
CAP_SYS_NICE. If you want to test that the priority can only be set whenCAP_SYS_NICEis available, then that is a seperate test in my opinion.
Anybody can call nice() to increase the priority, i have test it with normal user and passed.
And if decrease the priority, the test will report EPERM when running with normal user.
Regards,
Gongyi
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp