Commit cf698a9a authored by Andrew Vagin's avatar Andrew Vagin Committed by Pavel Emelyanov

zdtm: split sched_prio00 on two parts

sched_prio00 tests only priorities and sched_policy00
tests scheduling policy.

scheduling policy can not be changed in OpenVZ containers.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent da879919
...@@ -20,6 +20,7 @@ static/write_read10 ...@@ -20,6 +20,7 @@ static/write_read10
static/wait00 static/wait00
static/vdso00 static/vdso00
static/sched_prio00 static/sched_prio00
static/sched_policy00
static/file_shared static/file_shared
static/timers static/timers
static/futex static/futex
......
...@@ -20,6 +20,7 @@ TST_NOFILE = \ ...@@ -20,6 +20,7 @@ TST_NOFILE = \
timers \ timers \
unbound_sock \ unbound_sock \
sched_prio00 \ sched_prio00 \
sched_policy00 \
socket_listen \ socket_listen \
socket_udp \ socket_udp \
socket6_udp \ socket6_udp \
......
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include <string.h>
#include <sched.h>
#include "zdtmtst.h"
const char *test_doc = "Check sched policy to be preserved";
const char *test_author = "Pavel Emelyanov <xemul@parallels.com>";
static const int parm = 3;
static int do_nothing(void)
{
while (1)
sleep(10);
return -1;
}
int main(int argc, char ** argv)
{
int pid, ret, err = 0;
struct sched_param p;
test_init(argc, argv);
pid = fork();
if (!pid)
return do_nothing();
p.sched_priority = parm;
if (sched_setscheduler(pid, SCHED_RR, &p)) {
err("Can't set policy");
kill(pid, SIGKILL);
return -1;
}
test_daemon();
test_waitsig();
ret = sched_getscheduler(pid);
if (ret != SCHED_RR) {
fail("Broken/No policy");
err++;
}
ret = sched_getparam(pid, &p);
if (ret < 0 || p.sched_priority != parm) {
fail("Broken prio");
err++;
}
if (!err)
pass();
kill(pid, SIGKILL);
return err;
}
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
const char *test_doc = "Check sched prios to be preserved"; const char *test_doc = "Check sched prios to be preserved";
const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; const char *test_author = "Pavel Emelyanov <xemul@parallels.com>";
#define NRTASKS 4 #define NRTASKS 3
static int do_nothing(void) static int do_nothing(void)
{ {
...@@ -36,42 +36,26 @@ int main(int argc, char ** argv) ...@@ -36,42 +36,26 @@ int main(int argc, char ** argv)
test_init(argc, argv); test_init(argc, argv);
/* first 3 -- normal */
parm[0] = -20; parm[0] = -20;
parm[1] = 19; parm[1] = 19;
parm[2] = 1; parm[2] = 1;
parm[3] = 3;
/* next 1 -- RR */
for (i = 0; i < NRTASKS; i++) { for (i = 0; i < NRTASKS; i++) {
pid[i] = fork(); pid[i] = fork();
if (!pid[i]) if (!pid[i])
return do_nothing(); return do_nothing();
if (i < 3) {
if (setpriority(PRIO_PROCESS, pid[i], parm[i])) { if (setpriority(PRIO_PROCESS, pid[i], parm[i])) {
err("Can't set prio %d", i); err("Can't set prio %d", i);
kill_all(pid, i); kill_all(pid, i);
return -1; return -1;
} }
} else {
struct sched_param p;
p.sched_priority = parm[i];
if (sched_setscheduler(pid[i], SCHED_RR, &p)) {
err("Can't set policy %d", i);
kill_all(pid, i);
return -1;
}
}
} }
test_daemon(); test_daemon();
test_waitsig(); test_waitsig();
for (i = 0; i < NRTASKS; i++) { for (i = 0; i < NRTASKS; i++) {
if (i < 3) {
errno = 0; errno = 0;
ret = getpriority(PRIO_PROCESS, pid[i]); ret = getpriority(PRIO_PROCESS, pid[i]);
if (errno) { if (errno) {
...@@ -83,21 +67,6 @@ int main(int argc, char ** argv) ...@@ -83,21 +67,6 @@ int main(int argc, char ** argv)
fail("Broken nice for %d", i); fail("Broken nice for %d", i);
break; break;
} }
} else {
struct sched_param p;
ret = sched_getscheduler(pid[i]);
if (ret != SCHED_RR) {
fail("Broken/No policy for %d", i);
break;
}
ret = sched_getparam(pid[i], &p);
if (ret < 0 || p.sched_priority != parm[i]) {
fail("Broken prio for %d", i);
break;
}
}
} }
if (i == NRTASKS) if (i == NRTASKS)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment