aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSven Dziadek <s9svdzia@stud.uni-saarland.de>2012-04-16 15:37:40 -0400
committerSven Dziadek <s9svdzia@stud.uni-saarland.de>2012-05-31 16:23:38 -0400
commit6e1ceb5ab56005fd343f52bbb8d2879e2c1493bd (patch)
tree7747fe454511e842c273dca77359a1f473cb3c7c /tests
parentaae25e0770ade4083937c7443448cb3f0023b10a (diff)
P-FP: make PCP available to user space
PCP was only used for DPCP before tests: add some basic tests for PCP under P-FP
Diffstat (limited to 'tests')
-rw-r--r--tests/pcp.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/pcp.c b/tests/pcp.c
new file mode 100644
index 0000000..a893da6
--- /dev/null
+++ b/tests/pcp.c
@@ -0,0 +1,54 @@
1#include <fcntl.h>
2#include <unistd.h>
3#include <stdio.h>
4
5#include "tests.h"
6#include "litmus.h"
7
8
9TESTCASE(lock_pcp, P_FP,
10 "PCP acquisition and release")
11{
12 int fd, od, cpu = 0;
13
14 SYSCALL( fd = open(".pcp_locks", O_RDONLY | O_CREAT) );
15
16 SYSCALL( sporadic_partitioned(10, 100, cpu) );
17 SYSCALL( task_mode(LITMUS_RT_TASK) );
18
19 SYSCALL( od = open_pcp_sem(fd, 0, cpu) );
20
21 SYSCALL( litmus_lock(od) );
22 SYSCALL( litmus_unlock(od) );
23
24 SYSCALL( litmus_lock(od) );
25 SYSCALL( litmus_unlock(od) );
26
27 SYSCALL( litmus_lock(od) );
28 SYSCALL( litmus_unlock(od) );
29
30 /* tasks may not unlock resources they don't own */
31 SYSCALL_FAILS(EINVAL, litmus_unlock(od) );
32
33 SYSCALL( od_close(od) );
34
35 SYSCALL( close(fd) );
36
37 SYSCALL( remove(".pcp_locks") );
38}
39
40TESTCASE(not_lock_pcp_be, P_FP,
41 "don't let best-effort tasks lock PCP semaphores")
42{
43 int fd, od;
44
45 SYSCALL( fd = open(".pcp_locks", O_RDONLY | O_CREAT) );
46
47 /* BE task are not even allowed to open a PCP semaphore */
48 SYSCALL_FAILS(EPERM, od = open_pcp_sem(fd, 0, 1) );
49
50 SYSCALL( close(fd) );
51
52 SYSCALL( remove(".pcp_locks") );
53
54}