[CRIU] [PATCH cr] zdtm: split sched_prio00 on two parts
Andrey Vagin
avagin at openvz.org
Wed Oct 24 07:48:52 EDT 2012
From: Andrew Vagin <avagin at parallels.com>
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 <avagin at openvz.org>
---
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 | 61 ++++++++-----------------------
4 files changed, 80 insertions(+), 46 deletions(-)
create mode 100644 test/zdtm/live/static/sched_policy00.c
diff --git a/test/zdtm.sh b/test/zdtm.sh
index d5169c9..094fe96 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 f776bfd..2b6be83 100644
--- a/test/zdtm/live/static/Makefile
+++ b/test/zdtm/live/static/Makefile
@@ -21,6 +21,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 0000000..e4612ba
--- /dev/null
+++ b/test/zdtm/live/static/sched_policy00.c
@@ -0,0 +1,63 @@
+#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 at 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;
+}
diff --git a/test/zdtm/live/static/sched_prio00.c b/test/zdtm/live/static/sched_prio00.c
index 39496d0..f48581f 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 <xemul at parallels.com>";
-#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;
- }
-
- 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;
- }
+ 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;
}
}
--
1.7.1
More information about the CRIU
mailing list