aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2011-01-29 19:16:24 -0500
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2011-02-03 17:40:16 -0500
commit5ec8a4d481017390da5ae4de027e937bc04c21ec (patch)
treeb5e6a6008a0f607d79bf99bc1730bdc41d28e3c5
parentc4128b99e1206d03d15c5d2e1b6af164bf261c40 (diff)
add test cases for the FMLP and SRP under GSN- and PSN-EDF
-rw-r--r--tests/fdso.c21
-rw-r--r--tests/locks.c110
2 files changed, 126 insertions, 5 deletions
diff --git a/tests/fdso.c b/tests/fdso.c
index 1e2ab29..8a2a0d0 100644
--- a/tests/fdso.c
+++ b/tests/fdso.c
@@ -20,7 +20,7 @@ TESTCASE(fmlp_not_active, C_EDF | PFAIR | LINUX,
20 20
21 ASSERT(fd != -1); 21 ASSERT(fd != -1);
22 22
23 SYSCALL_FAILS(EBUSY, open_fmlp_sem(fd, 0) ); 23 SYSCALL_FAILS(ENXIO, open_fmlp_sem(fd, 0) );
24 24
25 SYSCALL( close(fd) ); 25 SYSCALL( close(fd) );
26 26
@@ -61,23 +61,34 @@ TESTCASE(not_inherit_od, GSN_EDF | PSN_EDF,
61 61
62 SYSCALL( od = open_fmlp_sem(fd, 0) ); 62 SYSCALL( od = open_fmlp_sem(fd, 0) );
63 63
64 SYSCALL( litmus_lock(od) );
65
66 SYSCALL( litmus_unlock(od) );
67
68 pid = fork(); 64 pid = fork();
69 65
70 ASSERT( pid != -1 ); 66 ASSERT( pid != -1 );
71 67
68 /* must be an RT task to lock at all */
69 SYSCALL( sporadic_partitioned(10, 100, 0) );
70 SYSCALL( task_mode(LITMUS_RT_TASK) );
71
72 if (pid == 0) { 72 if (pid == 0) {
73 /* child */ 73 /* child */
74 SYSCALL_FAILS(EINVAL, litmus_lock(od) ); 74 SYSCALL_FAILS(EINVAL, litmus_lock(od) );
75 SYSCALL_FAILS(EINVAL, litmus_unlock(od) ); 75 SYSCALL_FAILS(EINVAL, litmus_unlock(od) );
76
77 SYSCALL( task_mode(BACKGROUND_TASK) );
78
76 exit(0); 79 exit(0);
77 } else { 80 } else {
81
78 SYSCALL( litmus_lock(od) ); 82 SYSCALL( litmus_lock(od) );
79 SYSCALL( litmus_unlock(od) ); 83 SYSCALL( litmus_unlock(od) );
84
85 SYSCALL( litmus_lock(od) );
86 SYSCALL( litmus_unlock(od) );
87
88 SYSCALL( task_mode(BACKGROUND_TASK) );
89
80 SYSCALL( waitpid(pid, &status, 0) ); 90 SYSCALL( waitpid(pid, &status, 0) );
91
81 ASSERT(WEXITSTATUS(status) == 0); 92 ASSERT(WEXITSTATUS(status) == 0);
82 } 93 }
83 94
diff --git a/tests/locks.c b/tests/locks.c
new file mode 100644
index 0000000..65b932a
--- /dev/null
+++ b/tests/locks.c
@@ -0,0 +1,110 @@
1#include <fcntl.h>
2#include <unistd.h>
3#include <stdio.h>
4
5#include "tests.h"
6#include "litmus.h"
7
8
9TESTCASE(not_lock_fmlp_be, GSN_EDF | PSN_EDF,
10 "don't let best-effort tasks lock FMLP semaphores")
11{
12 int fd, od;
13
14 SYSCALL( fd = open(".fmlp_locks", O_RDONLY | O_CREAT) );
15
16 SYSCALL( od = open_fmlp_sem(fd, 0) );
17
18 /* BE tasks may not lock FMLP semaphores */
19 SYSCALL_FAILS(EPERM, litmus_lock(od) );
20
21 /* tasks may not unlock resources they don't own */
22 SYSCALL_FAILS(EINVAL, litmus_unlock(od) );
23
24 SYSCALL( od_close(od) );
25
26 SYSCALL( close(fd) );
27
28 SYSCALL( remove(".fmlp_locks") );
29
30}
31
32TESTCASE(not_lock_srp_be, PSN_EDF,
33 "don't let best-effort tasks open SRP semaphores")
34{
35 int fd, od;
36
37 SYSCALL( fd = open(".srp_locks", O_RDONLY | O_CREAT) );
38
39 /* BE tasks may not open SRP semaphores */
40
41 SYSCALL_FAILS(EPERM, od = open_srp_sem(fd, 0) );
42
43 SYSCALL( close(fd) );
44
45 SYSCALL( remove(".srp_locks") );
46
47}
48
49TESTCASE(lock_srp, PSN_EDF,
50 "SRP acquisition and release")
51{
52 int fd, od;
53
54 SYSCALL( fd = open(".srp_locks", O_RDONLY | O_CREAT) );
55
56 SYSCALL( sporadic_partitioned(10, 100, 0) );
57 SYSCALL( task_mode(LITMUS_RT_TASK) );
58
59 SYSCALL( od = open_srp_sem(fd, 0) );
60
61 SYSCALL( litmus_lock(od) );
62 SYSCALL( litmus_unlock(od) );
63
64 SYSCALL( litmus_lock(od) );
65 SYSCALL( litmus_unlock(od) );
66
67 SYSCALL( litmus_lock(od) );
68 SYSCALL( litmus_unlock(od) );
69
70 /* tasks may not unlock resources they don't own */
71 SYSCALL_FAILS(EINVAL, litmus_unlock(od) );
72
73 SYSCALL( od_close(od) );
74
75 SYSCALL( close(fd) );
76
77 SYSCALL( remove(".srp_locks") );
78}
79
80
81TESTCASE(lock_fmlp, PSN_EDF | GSN_EDF,
82 "FMLP acquisition and release")
83{
84 int fd, od;
85
86 SYSCALL( fd = open(".fmlp_locks", O_RDONLY | O_CREAT) );
87
88 SYSCALL( sporadic_partitioned(10, 100, 0) );
89 SYSCALL( task_mode(LITMUS_RT_TASK) );
90
91 SYSCALL( od = open_fmlp_sem(fd, 0) );
92
93 SYSCALL( litmus_lock(od) );
94 SYSCALL( litmus_unlock(od) );
95
96 SYSCALL( litmus_lock(od) );
97 SYSCALL( litmus_unlock(od) );
98
99 SYSCALL( litmus_lock(od) );
100 SYSCALL( litmus_unlock(od) );
101
102 /* tasks may not unlock resources they don't own */
103 SYSCALL_FAILS(EINVAL, litmus_unlock(od) );
104
105 SYSCALL( od_close(od) );
106
107 SYSCALL( close(fd) );
108
109 SYSCALL( remove(".fmlp_locks") );
110}