diff options
author | Bjoern Brandenburg <bbb@mpi-sws.org> | 2013-06-08 18:13:55 -0400 |
---|---|---|
committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2013-06-08 18:13:55 -0400 |
commit | fcf492f8e1c7ef975e0d20cb50826ddacd33b884 (patch) | |
tree | 6f1e7ca511d12485ea2fab5a6d080f961bc4a702 /tests | |
parent | 4928cb8f9b596dde0f977bd8924a28dd38541f5f (diff) |
Add a test for admission of tasks that are currently running
Complements the prior test for suspended tasks. All plugins currently
pass this test.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core_api.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/core_api.c b/tests/core_api.c index 42529ce..0a87838 100644 --- a/tests/core_api.c +++ b/tests/core_api.c | |||
@@ -229,3 +229,63 @@ TESTCASE(suspended_admission, LITMUS, | |||
229 | SYSCALL( waitpid(child_rt, &status, 0) ); | 229 | SYSCALL( waitpid(child_rt, &status, 0) ); |
230 | ASSERT( status == 0 ); | 230 | ASSERT( status == 0 ); |
231 | } | 231 | } |
232 | |||
233 | TESTCASE(running_admission, LITMUS, | ||
234 | "admission control handles running tasks correctly") | ||
235 | { | ||
236 | int child_rt, status; | ||
237 | struct sched_param param; | ||
238 | |||
239 | int pipefd[2], err, token = 0, scheduler; | ||
240 | struct rt_task params; | ||
241 | |||
242 | SYSCALL( pipe(pipefd) ); | ||
243 | |||
244 | child_rt = FORK_TASK( | ||
245 | child_rt = gettid(); | ||
246 | /* make sure we are on the right CPU */ | ||
247 | be_migrate_to_cpu(0); | ||
248 | |||
249 | /* unblock parent */ | ||
250 | token = 1234; | ||
251 | ASSERT( write(pipefd[1], &token, sizeof(token)) == sizeof(token) ); | ||
252 | |||
253 | scheduler = -1; | ||
254 | |||
255 | while (scheduler != SCHED_LITMUS) { | ||
256 | SYSCALL( scheduler = sched_getscheduler(child_rt) ); | ||
257 | } | ||
258 | |||
259 | SYSCALL( sleep_next_period() ); | ||
260 | SYSCALL( sleep_next_period() ); | ||
261 | |||
262 | exit(0); | ||
263 | ); | ||
264 | |||
265 | /* carry out a blocking read to suspend */ | ||
266 | err = read(pipefd[0], &token, sizeof(token)); | ||
267 | ASSERT(err = sizeof(token)); | ||
268 | ASSERT(token == 1234); | ||
269 | |||
270 | /* give child some time to run */ | ||
271 | SYSCALL( lt_sleep(ms2ns(10)) ); | ||
272 | |||
273 | init_rt_task_param(¶ms); | ||
274 | params.cpu = 0; | ||
275 | params.exec_cost = ms2ns(10); | ||
276 | params.period = ms2ns(100); | ||
277 | |||
278 | /* configure parameters of child */ | ||
279 | SYSCALL( set_rt_task_param(child_rt, ¶ms) ); | ||
280 | |||
281 | /* make it a real-time task */ | ||
282 | param.sched_priority = 0; | ||
283 | SYSCALL( sched_setscheduler(child_rt, SCHED_LITMUS, ¶m) ); | ||
284 | |||
285 | /* should be a real-time task now */ | ||
286 | ASSERT( sched_getscheduler(child_rt) == SCHED_LITMUS ); | ||
287 | |||
288 | /* wait for child to exit */ | ||
289 | SYSCALL( waitpid(child_rt, &status, 0) ); | ||
290 | ASSERT( status == 0 ); | ||
291 | } | ||