summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorCraig Small <csmall@enc.com.au>2012-03-03 13:56:32 +1100
committerCraig Small <csmall@enc.com.au>2012-03-03 13:56:32 +1100
commit502a79e02fdf7e2b5125f150b3d22aaf0ec1a208 (patch)
tree813706aad2cc44bc3f3efea8d5d22534e3336def /testsuite
parentcda4b65add1f36624e507d19c2d278affd03948d (diff)
parent96e86ef1a0c9288711329761eccfb279fcd90790 (diff)
downloadprocps-ng-502a79e02fdf7e2b5125f150b3d22aaf0ec1a208.tar.gz
Merge remote-tracking branch 'sami/to-craig' into sami-merge
Conflicts: pgrep.c w.c
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();
+ }
+}