aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Brandenburg <bbb@mpi-sws.org>2012-08-13 07:28:37 -0400
committerBjoern Brandenburg <bbb@mpi-sws.org>2012-08-14 14:46:12 -0400
commitef69f4de3d239bc45e5265f58cf8f802b1c4699c (patch)
tree80aba10af4fce4c42a4a98d89f59e6c83bba7605
parentb1e8b38d93fdd1c5ef015ed2653abf037569d2b6 (diff)
Add tests for the DPCP and the MPCP
Do the basic open/lock/unlock/close test sequence for the MPCP and the DPCP as well.
-rw-r--r--tests/pcp.c72
1 files changed, 70 insertions, 2 deletions
diff --git a/tests/pcp.c b/tests/pcp.c
index a893da6..88d1be3 100644
--- a/tests/pcp.c
+++ b/tests/pcp.c
@@ -37,18 +37,86 @@ TESTCASE(lock_pcp, P_FP,
37 SYSCALL( remove(".pcp_locks") ); 37 SYSCALL( remove(".pcp_locks") );
38} 38}
39 39
40TESTCASE(lock_dpcp, P_FP,
41 "DPCP acquisition and release")
42{
43 int fd, od, cpu = 1;
44
45 SYSCALL( fd = open(".pcp_locks", O_RDONLY | O_CREAT) );
46
47 SYSCALL( sporadic_partitioned(10, 100, 0) );
48 SYSCALL( task_mode(LITMUS_RT_TASK) );
49
50 SYSCALL( od = open_dpcp_sem(fd, 0, cpu) );
51
52 SYSCALL( litmus_lock(od) );
53 SYSCALL( litmus_unlock(od) );
54
55 SYSCALL( litmus_lock(od) );
56 SYSCALL( litmus_unlock(od) );
57
58 SYSCALL( litmus_lock(od) );
59 SYSCALL( litmus_unlock(od) );
60
61 /* tasks may not unlock resources they don't own */
62 SYSCALL_FAILS(EINVAL, litmus_unlock(od) );
63
64 SYSCALL( od_close(od) );
65
66 SYSCALL( close(fd) );
67
68 SYSCALL( remove(".pcp_locks") );
69}
70
40TESTCASE(not_lock_pcp_be, P_FP, 71TESTCASE(not_lock_pcp_be, P_FP,
41 "don't let best-effort tasks lock PCP semaphores") 72 "don't let best-effort tasks lock (D|M-)PCP semaphores")
42{ 73{
43 int fd, od; 74 int fd, od;
44 75
45 SYSCALL( fd = open(".pcp_locks", O_RDONLY | O_CREAT) ); 76 SYSCALL( fd = open(".pcp_locks", O_RDONLY | O_CREAT) );
46 77
47 /* BE task are not even allowed to open a PCP semaphore */ 78 /* BE tasks are not even allowed to open a PCP semaphore */
48 SYSCALL_FAILS(EPERM, od = open_pcp_sem(fd, 0, 1) ); 79 SYSCALL_FAILS(EPERM, od = open_pcp_sem(fd, 0, 1) );
49 80
81 /* BE tasks are not allowed to open a D-PCP semaphore */
82 SYSCALL_FAILS(EPERM, od = open_dpcp_sem(fd, 0, 1) );
83
84 /* BE tasks are not allowed to open an M-PCP semaphore */
85 SYSCALL_FAILS(EPERM, od = open_mpcp_sem(fd, 0) );
86
50 SYSCALL( close(fd) ); 87 SYSCALL( close(fd) );
51 88
52 SYSCALL( remove(".pcp_locks") ); 89 SYSCALL( remove(".pcp_locks") );
53 90
54} 91}
92
93TESTCASE(lock_mpcp, P_FP,
94 "MPCP acquisition and release")
95{
96 int fd, od;
97
98 SYSCALL( fd = open(".pcp_locks", O_RDONLY | O_CREAT) );
99
100 SYSCALL( sporadic_partitioned(10, 100, 0) );
101 SYSCALL( task_mode(LITMUS_RT_TASK) );
102
103 SYSCALL( od = open_mpcp_sem(fd, 0) );
104
105 SYSCALL( litmus_lock(od) );
106 SYSCALL( litmus_unlock(od) );
107
108 SYSCALL( litmus_lock(od) );
109 SYSCALL( litmus_unlock(od) );
110
111 SYSCALL( litmus_lock(od) );
112 SYSCALL( litmus_unlock(od) );
113
114 /* tasks may not unlock resources they don't own */
115 SYSCALL_FAILS(EINVAL, litmus_unlock(od) );
116
117 SYSCALL( od_close(od) );
118
119 SYSCALL( close(fd) );
120
121 SYSCALL( remove(".pcp_locks") );
122}