1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include "tests.h"
#include "litmus.h"
TESTCASE(not_lock_fmlp_be, GSN_EDF | PSN_EDF,
"don't let best-effort tasks lock FMLP semaphores")
{
int fd, od;
SYSCALL( fd = open(".fmlp_locks", O_RDONLY | O_CREAT) );
SYSCALL( od = open_fmlp_sem(fd, 0) );
/* BE tasks may not lock FMLP semaphores */
SYSCALL_FAILS(EPERM, litmus_lock(od) );
/* tasks may not unlock resources they don't own */
SYSCALL_FAILS(EINVAL, litmus_unlock(od) );
SYSCALL( od_close(od) );
SYSCALL( close(fd) );
SYSCALL( remove(".fmlp_locks") );
}
TESTCASE(not_lock_srp_be, PSN_EDF,
"don't let best-effort tasks open SRP semaphores")
{
int fd, od;
SYSCALL( fd = open(".srp_locks", O_RDONLY | O_CREAT) );
/* BE tasks may not open SRP semaphores */
SYSCALL_FAILS(EPERM, od = open_srp_sem(fd, 0) );
SYSCALL( close(fd) );
SYSCALL( remove(".srp_locks") );
}
TESTCASE(lock_srp, PSN_EDF,
"SRP acquisition and release")
{
int fd, od;
SYSCALL( fd = open(".srp_locks", O_RDONLY | O_CREAT) );
SYSCALL( sporadic_partitioned(10, 100, 0) );
SYSCALL( task_mode(LITMUS_RT_TASK) );
SYSCALL( od = open_srp_sem(fd, 0) );
SYSCALL( litmus_lock(od) );
SYSCALL( litmus_unlock(od) );
SYSCALL( litmus_lock(od) );
SYSCALL( litmus_unlock(od) );
SYSCALL( litmus_lock(od) );
SYSCALL( litmus_unlock(od) );
/* tasks may not unlock resources they don't own */
SYSCALL_FAILS(EINVAL, litmus_unlock(od) );
SYSCALL( od_close(od) );
SYSCALL( close(fd) );
SYSCALL( remove(".srp_locks") );
}
TESTCASE(lock_fmlp, PSN_EDF | GSN_EDF,
"FMLP acquisition and release")
{
int fd, od;
SYSCALL( fd = open(".fmlp_locks", O_RDONLY | O_CREAT) );
SYSCALL( sporadic_partitioned(10, 100, 0) );
SYSCALL( task_mode(LITMUS_RT_TASK) );
SYSCALL( od = open_fmlp_sem(fd, 0) );
SYSCALL( litmus_lock(od) );
SYSCALL( litmus_unlock(od) );
SYSCALL( litmus_lock(od) );
SYSCALL( litmus_unlock(od) );
SYSCALL( litmus_lock(od) );
SYSCALL( litmus_unlock(od) );
/* tasks may not unlock resources they don't own */
SYSCALL_FAILS(EINVAL, litmus_unlock(od) );
SYSCALL( od_close(od) );
SYSCALL( close(fd) );
SYSCALL( remove(".fmlp_locks") );
}
|