summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorMike Fleetwood <mike.fleetwood@googlemail.com>2011-09-25 05:15:43 -0400
committerSami Kerola <kerolasa@iki.fi>2012-01-09 21:37:41 +0100
commit23d2e0b0b723b2cc64808fc2c21da27759e42c56 (patch)
tree6e1497be0db20fd015a45747f6a89c44d1db4393 /testsuite
parent3c2377ca159861e6eb8c08f68e80292babcb5473 (diff)
downloadprocps-ng-23d2e0b0b723b2cc64808fc2c21da27759e42c56.tar.gz
tests: add SCHED_BATCH test
Reference: https://bugzilla.redhat.com/show_bug.cgi?id=741090 Acked-by:: Jaromir Capik <jcapik@redhat.com> Acked-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Mike Fleetwood <mike.fleetwood@googlemail.com>
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/.gitignore1
-rw-r--r--testsuite/Makefile.am5
-rw-r--r--testsuite/ps.test/ps_sched_batch.exp12
-rw-r--r--testsuite/ps.test/test-schedbatch.c39
4 files changed, 57 insertions, 0 deletions
diff --git a/testsuite/.gitignore b/testsuite/.gitignore
index 96ef030..b14d968 100644
--- a/testsuite/.gitignore
+++ b/testsuite/.gitignore
@@ -2,3 +2,4 @@
*.sum
site.bak
site.exp
+test-schedbatch
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index d1682ac..3f79532 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -4,6 +4,10 @@ export DEJAGNU
# Programs that are expected across the board.
DEJATOOL =
+noinst_PROGRAMS = test-schedbatch
+
+test_schedbatch_SOURCES = ps.test/test-schedbatch.c
+
if LINUX
# These should be in defined in 'across the board' scope, but are
# temporarily disabled on other than linux systems, see commit
@@ -35,6 +39,7 @@ EXTRA_DIST = \
pmap.test/pmap.exp \
ps.test/ps_output.exp \
ps.test/ps_personality.exp \
+ ps.test/ps_sched_batch.exp \
pwdx.test/pwdx.exp \
slabtop.test/slabtop.exp \
sysctl.test/sysctl_read.exp \
diff --git a/testsuite/ps.test/ps_sched_batch.exp b/testsuite/ps.test/ps_sched_batch.exp
new file mode 100644
index 0000000..e0c31ff
--- /dev/null
+++ b/testsuite/ps.test/ps_sched_batch.exp
@@ -0,0 +1,12 @@
+#
+# check the ps SCHED_BATCH scheduler policy output
+#
+set ps "${topdir}ps/pscommand"
+set schedbatch "${topdir}testsuite/test-schedbatch"
+
+spawn $schedbatch 18
+
+set test "ps SCHED_BATCH scheduler"
+spawn $ps --no-header -o comm,cls,nice -a
+expect_pass "$test" "\\s+test-schedbatch\\s+B\\s+18"
+untested "$test"
diff --git a/testsuite/ps.test/test-schedbatch.c b/testsuite/ps.test/test-schedbatch.c
new file mode 100644
index 0000000..13cd6f3
--- /dev/null
+++ b/testsuite/ps.test/test-schedbatch.c
@@ -0,0 +1,39 @@
+/* test-schedbatch.c - Create a process using SCHED_BATCH scheduler
+ * policy and nice value.
+ * Compile: gcc -o test-schedbatch -Wall test-schedbatch.c
+ * Usage: ./test-schedbatch [ <NICE> ]
+ *
+ * Author: Mike Fleetwood
+ * https://bugzilla.redhat.com/show_bug.cgi?id=741090
+ */
+
+#define _GNU_SOURCE
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <sched.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+
+int main(int argc, const char *argv[])
+{
+ int nice = 19;
+ struct sched_param sp;
+ char msg[50];
+
+ if (argc >= 2) {
+ nice = atoi(argv[1]);
+ }
+ sp.sched_priority = 0;
+ if (sched_setscheduler(0, SCHED_BATCH, &sp)) {
+ perror("sched_setscheduler(0,SCHED_BATCH,{.sched_priority=0}");
+ }
+ if (setpriority(PRIO_PROCESS, 0, nice) || errno) {
+ (void)snprintf(msg, sizeof(msg),
+ "setpriority(PRIO_PROCESS, 0, %d)", nice);
+ perror(msg);
+ }
+ while (1) {
+ getchar();
+ }
+}