From 4928cb8f9b596dde0f977bd8924a28dd38541f5f Mon Sep 17 00:00:00 2001 From: Bjoern Brandenburg Date: Sat, 8 Jun 2013 20:05:29 +0200 Subject: Add testcase for admission of suspended tasks The kernel needs to be able to deal with tasks that do not make themselves a real-time task, but get configured by some other task instead. --- tests/core_api.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'tests') diff --git a/tests/core_api.c b/tests/core_api.c index fc4deb9..42529ce 100644 --- a/tests/core_api.c +++ b/tests/core_api.c @@ -1,6 +1,8 @@ #include /* for waitpid() */ #include #include +#include +#include #include "tests.h" #include "litmus.h" @@ -169,3 +171,61 @@ TESTCASE(ctrl_page_writable, ALL, ctrl_page[32] = 0x12345678; } + + +TESTCASE(suspended_admission, LITMUS, + "admission control handles suspended tasks correctly") +{ + int child_rt, status; + struct sched_param param; + + int pipefd[2], err, token = 0; + struct rt_task params; + + SYSCALL( pipe(pipefd) ); + + child_rt = FORK_TASK( + child_rt = gettid(); + /* make sure we are on the right CPU */ + be_migrate_to_cpu(0); + + /* carry out a blocking read to suspend */ + err = read(pipefd[0], &token, sizeof(token)); + ASSERT(err = sizeof(token)); + ASSERT(token == 1234); + + /* when we wake up, we should be a real-time task */ + ASSERT( sched_getscheduler(child_rt) == SCHED_LITMUS ); + + SYSCALL( sleep_next_period() ); + SYSCALL( sleep_next_period() ); + + exit(0); + ); + + /* give child some time to suspend */ + SYSCALL( lt_sleep(ms2ns(100)) ); + + init_rt_task_param(¶ms); + params.cpu = 0; + params.exec_cost = ms2ns(10); + params.period = ms2ns(100); + + /* configure parameters of child */ + SYSCALL( set_rt_task_param(child_rt, ¶ms) ); + + /* make it a real-time task */ + param.sched_priority = 0; + SYSCALL( sched_setscheduler(child_rt, SCHED_LITMUS, ¶m) ); + + /* should be a real-time task now */ + ASSERT( sched_getscheduler(child_rt) == SCHED_LITMUS ); + + /* unblock it */ + token = 1234; + ASSERT( write(pipefd[1], &token, sizeof(token)) == sizeof(token) ); + + /* wait for child to exit */ + SYSCALL( waitpid(child_rt, &status, 0) ); + ASSERT( status == 0 ); +} -- cgit v1.2.2