aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBjoern Brandenburg <bbb@mpi-sws.org>2013-06-08 14:05:29 -0400
committerBjoern Brandenburg <bbb@mpi-sws.org>2013-06-08 18:13:43 -0400
commit4928cb8f9b596dde0f977bd8924a28dd38541f5f (patch)
tree9d56efc55b291a8fe353bf84e29b2fbbdbfa0343 /tests
parentd671324496bed1cd10fbdf425f049eae11efde14 (diff)
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/core_api.c60
1 files changed, 60 insertions, 0 deletions
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 @@
1#include <sys/wait.h> /* for waitpid() */ 1#include <sys/wait.h> /* for waitpid() */
2#include <unistd.h> 2#include <unistd.h>
3#include <stdio.h> 3#include <stdio.h>
4#include <stdlib.h>
5#include <sched.h>
4 6
5#include "tests.h" 7#include "tests.h"
6#include "litmus.h" 8#include "litmus.h"
@@ -169,3 +171,61 @@ TESTCASE(ctrl_page_writable, ALL,
169 171
170 ctrl_page[32] = 0x12345678; 172 ctrl_page[32] = 0x12345678;
171} 173}
174
175
176TESTCASE(suspended_admission, LITMUS,
177 "admission control handles suspended tasks correctly")
178{
179 int child_rt, status;
180 struct sched_param param;
181
182 int pipefd[2], err, token = 0;
183 struct rt_task params;
184
185 SYSCALL( pipe(pipefd) );
186
187 child_rt = FORK_TASK(
188 child_rt = gettid();
189 /* make sure we are on the right CPU */
190 be_migrate_to_cpu(0);
191
192 /* carry out a blocking read to suspend */
193 err = read(pipefd[0], &token, sizeof(token));
194 ASSERT(err = sizeof(token));
195 ASSERT(token == 1234);
196
197 /* when we wake up, we should be a real-time task */
198 ASSERT( sched_getscheduler(child_rt) == SCHED_LITMUS );
199
200 SYSCALL( sleep_next_period() );
201 SYSCALL( sleep_next_period() );
202
203 exit(0);
204 );
205
206 /* give child some time to suspend */
207 SYSCALL( lt_sleep(ms2ns(100)) );
208
209 init_rt_task_param(&params);
210 params.cpu = 0;
211 params.exec_cost = ms2ns(10);
212 params.period = ms2ns(100);
213
214 /* configure parameters of child */
215 SYSCALL( set_rt_task_param(child_rt, &params) );
216
217 /* make it a real-time task */
218 param.sched_priority = 0;
219 SYSCALL( sched_setscheduler(child_rt, SCHED_LITMUS, &param) );
220
221 /* should be a real-time task now */
222 ASSERT( sched_getscheduler(child_rt) == SCHED_LITMUS );
223
224 /* unblock it */
225 token = 1234;
226 ASSERT( write(pipefd[1], &token, sizeof(token)) == sizeof(token) );
227
228 /* wait for child to exit */
229 SYSCALL( waitpid(child_rt, &status, 0) );
230 ASSERT( status == 0 );
231}