From cf698a9a484eb0a7cc911bee3073b04cbd2a8938 Mon Sep 17 00:00:00 2001 From: Andrew Vagin Date: Wed, 24 Oct 2012 15:52:53 +0400 Subject: [PATCH] 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: Andrey Vagin Signed-off-by: Pavel Emelyanov --- test/zdtm.sh | 1 + test/zdtm/live/static/Makefile | 1 + test/zdtm/live/static/sched_policy00.c | 63 ++++++++++++++++++++++++++ test/zdtm/live/static/sched_prio00.c | 59 ++++++------------------ 4 files changed, 79 insertions(+), 45 deletions(-) create mode 100644 test/zdtm/live/static/sched_policy00.c diff --git a/test/zdtm.sh b/test/zdtm.sh index 3d8997ce2..7349bb603 100644 --- a/test/zdtm.sh +++ b/test/zdtm.sh @@ -20,6 +20,7 @@ static/write_read10 static/wait00 static/vdso00 static/sched_prio00 +static/sched_policy00 static/file_shared static/timers static/futex diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile index 09ba59b0b..03e16a71d 100644 --- a/test/zdtm/live/static/Makefile +++ b/test/zdtm/live/static/Makefile @@ -20,6 +20,7 @@ TST_NOFILE = \ timers \ unbound_sock \ sched_prio00 \ + sched_policy00 \ socket_listen \ socket_udp \ socket6_udp \ diff --git a/test/zdtm/live/static/sched_policy00.c b/test/zdtm/live/static/sched_policy00.c new file mode 100644 index 000000000..e4612ba0f --- /dev/null +++ b/test/zdtm/live/static/sched_policy00.c @@ -0,0 +1,63 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "zdtmtst.h" + +const char *test_doc = "Check sched policy to be preserved"; +const char *test_author = "Pavel Emelyanov "; + +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; +} diff --git a/test/zdtm/live/static/sched_prio00.c b/test/zdtm/live/static/sched_prio00.c index 39496d0fa..f48581f3c 100644 --- a/test/zdtm/live/static/sched_prio00.c +++ b/test/zdtm/live/static/sched_prio00.c @@ -12,7 +12,7 @@ const char *test_doc = "Check sched prios to be preserved"; const char *test_author = "Pavel Emelyanov "; -#define NRTASKS 4 +#define NRTASKS 3 static int do_nothing(void) { @@ -36,34 +36,19 @@ int main(int argc, char ** argv) test_init(argc, argv); - /* first 3 -- normal */ parm[0] = -20; parm[1] = 19; parm[2] = 1; - parm[3] = 3; - - /* next 1 -- RR */ for (i = 0; i < NRTASKS; i++) { pid[i] = fork(); if (!pid[i]) return do_nothing(); - if (i < 3) { - if (setpriority(PRIO_PROCESS, pid[i], parm[i])) { - err("Can't set prio %d", i); - kill_all(pid, i); - 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; - } + if (setpriority(PRIO_PROCESS, pid[i], parm[i])) { + err("Can't set prio %d", i); + kill_all(pid, i); + return -1; } } @@ -71,32 +56,16 @@ int main(int argc, char ** argv) test_waitsig(); for (i = 0; i < NRTASKS; i++) { - if (i < 3) { - errno = 0; - ret = getpriority(PRIO_PROCESS, pid[i]); - if (errno) { - fail("No prio for task %d", i); - break; - } + errno = 0; + ret = getpriority(PRIO_PROCESS, pid[i]); + if (errno) { + fail("No prio for task %d", i); + break; + } - if (ret != parm[i]) { - fail("Broken nice for %d", i); - 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 (ret != parm[i]) { + fail("Broken nice for %d", i); + break; } }