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>
This commit is contained in:
parent
3c2377ca15
commit
23d2e0b0b7
1
testsuite/.gitignore
vendored
1
testsuite/.gitignore
vendored
@ -2,3 +2,4 @@
|
|||||||
*.sum
|
*.sum
|
||||||
site.bak
|
site.bak
|
||||||
site.exp
|
site.exp
|
||||||
|
test-schedbatch
|
||||||
|
@ -4,6 +4,10 @@ export DEJAGNU
|
|||||||
# Programs that are expected across the board.
|
# Programs that are expected across the board.
|
||||||
DEJATOOL =
|
DEJATOOL =
|
||||||
|
|
||||||
|
noinst_PROGRAMS = test-schedbatch
|
||||||
|
|
||||||
|
test_schedbatch_SOURCES = ps.test/test-schedbatch.c
|
||||||
|
|
||||||
if LINUX
|
if LINUX
|
||||||
# These should be in defined in 'across the board' scope, but are
|
# These should be in defined in 'across the board' scope, but are
|
||||||
# temporarily disabled on other than linux systems, see commit
|
# temporarily disabled on other than linux systems, see commit
|
||||||
@ -35,6 +39,7 @@ EXTRA_DIST = \
|
|||||||
pmap.test/pmap.exp \
|
pmap.test/pmap.exp \
|
||||||
ps.test/ps_output.exp \
|
ps.test/ps_output.exp \
|
||||||
ps.test/ps_personality.exp \
|
ps.test/ps_personality.exp \
|
||||||
|
ps.test/ps_sched_batch.exp \
|
||||||
pwdx.test/pwdx.exp \
|
pwdx.test/pwdx.exp \
|
||||||
slabtop.test/slabtop.exp \
|
slabtop.test/slabtop.exp \
|
||||||
sysctl.test/sysctl_read.exp \
|
sysctl.test/sysctl_read.exp \
|
||||||
|
12
testsuite/ps.test/ps_sched_batch.exp
Normal file
12
testsuite/ps.test/ps_sched_batch.exp
Normal file
@ -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"
|
39
testsuite/ps.test/test-schedbatch.c
Normal file
39
testsuite/ps.test/test-schedbatch.c
Normal file
@ -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();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user