diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core_api.c | 42 | ||||
-rw-r--r-- | tests/fdso.c | 39 | ||||
-rw-r--r-- | tests/locks.c | 110 | ||||
-rwxr-xr-x | tests/make_catalog.py | 5 | ||||
-rw-r--r-- | tests/runner.c | 4 |
5 files changed, 183 insertions, 17 deletions
diff --git a/tests/core_api.c b/tests/core_api.c index d858f1f..7487c1c 100644 --- a/tests/core_api.c +++ b/tests/core_api.c | |||
@@ -1,5 +1,8 @@ | |||
1 | #include "tests.h" | 1 | #include <sys/wait.h> /* for waitpid() */ |
2 | #include <unistd.h> | ||
3 | #include <stdio.h> | ||
2 | 4 | ||
5 | #include "tests.h" | ||
3 | #include "litmus.h" | 6 | #include "litmus.h" |
4 | 7 | ||
5 | 8 | ||
@@ -49,3 +52,40 @@ TESTCASE(job_control_non_rt, ALL, | |||
49 | 52 | ||
50 | SYSCALL_FAILS( EPERM, get_job_no(&job_no) ); | 53 | SYSCALL_FAILS( EPERM, get_job_no(&job_no) ); |
51 | } | 54 | } |
55 | |||
56 | |||
57 | TESTCASE(rt_fork_non_rt, LITMUS, | ||
58 | "children of RT tasks are not automatically RT tasks") | ||
59 | { | ||
60 | unsigned int pid, job_no; | ||
61 | int status; | ||
62 | |||
63 | SYSCALL( sporadic_partitioned(10, 100, 0) ); | ||
64 | SYSCALL( task_mode(LITMUS_RT_TASK) ); | ||
65 | |||
66 | pid = fork(); | ||
67 | |||
68 | ASSERT( pid != -1 ); | ||
69 | |||
70 | if (pid == 0) { | ||
71 | /* child */ | ||
72 | |||
73 | SYSCALL_FAILS( EINVAL, sleep_next_period() ); | ||
74 | SYSCALL_FAILS( EINVAL, wait_for_job_release(0) ); | ||
75 | SYSCALL_FAILS( EPERM, get_job_no(&job_no) ); | ||
76 | |||
77 | exit(0); | ||
78 | } else { | ||
79 | /* parent */ | ||
80 | |||
81 | SYSCALL( sleep_next_period() ); | ||
82 | SYSCALL( wait_for_job_release(20) ); | ||
83 | SYSCALL( get_job_no(&job_no) ); | ||
84 | |||
85 | SYSCALL( task_mode(BACKGROUND_TASK) ); | ||
86 | |||
87 | SYSCALL( waitpid(pid, &status, 0) ); | ||
88 | |||
89 | ASSERT(WEXITSTATUS(status) == 0); | ||
90 | } | ||
91 | } | ||
diff --git a/tests/fdso.c b/tests/fdso.c index c95a578..8a2a0d0 100644 --- a/tests/fdso.c +++ b/tests/fdso.c | |||
@@ -1,3 +1,5 @@ | |||
1 | #include <sys/wait.h> /* for waitpid() */ | ||
2 | |||
1 | #include <fcntl.h> | 3 | #include <fcntl.h> |
2 | #include <unistd.h> | 4 | #include <unistd.h> |
3 | 5 | ||
@@ -18,7 +20,7 @@ TESTCASE(fmlp_not_active, C_EDF | PFAIR | LINUX, | |||
18 | 20 | ||
19 | ASSERT(fd != -1); | 21 | ASSERT(fd != -1); |
20 | 22 | ||
21 | SYSCALL_FAILS(EBUSY, open_fmlp_sem(fd, 0) ); | 23 | SYSCALL_FAILS(ENXIO, open_fmlp_sem(fd, 0) ); |
22 | 24 | ||
23 | SYSCALL( close(fd) ); | 25 | SYSCALL( close(fd) ); |
24 | 26 | ||
@@ -29,16 +31,16 @@ TESTCASE(fmlp_not_active, C_EDF | PFAIR | LINUX, | |||
29 | TESTCASE(invalid_od, ALL, | 31 | TESTCASE(invalid_od, ALL, |
30 | "reject invalid object descriptors") | 32 | "reject invalid object descriptors") |
31 | { | 33 | { |
32 | SYSCALL_FAILS( EINVAL, fmlp_down(3) ); | 34 | SYSCALL_FAILS( EINVAL, litmus_lock(3) ); |
33 | 35 | ||
34 | SYSCALL_FAILS( EINVAL, fmlp_up(3) ); | 36 | SYSCALL_FAILS( EINVAL, litmus_unlock(3) ); |
35 | 37 | ||
36 | SYSCALL_FAILS( EINVAL, od_close(3) ); | 38 | SYSCALL_FAILS( EINVAL, od_close(3) ); |
37 | 39 | ||
38 | 40 | ||
39 | SYSCALL_FAILS( EINVAL, fmlp_down(-1) ); | 41 | SYSCALL_FAILS( EINVAL, litmus_lock(-1) ); |
40 | 42 | ||
41 | SYSCALL_FAILS( EINVAL, fmlp_up(-1) ); | 43 | SYSCALL_FAILS( EINVAL, litmus_unlock(-1) ); |
42 | 44 | ||
43 | SYSCALL_FAILS( EINVAL, od_close(-1) ); | 45 | SYSCALL_FAILS( EINVAL, od_close(-1) ); |
44 | } | 46 | } |
@@ -59,23 +61,34 @@ TESTCASE(not_inherit_od, GSN_EDF | PSN_EDF, | |||
59 | 61 | ||
60 | SYSCALL( od = open_fmlp_sem(fd, 0) ); | 62 | SYSCALL( od = open_fmlp_sem(fd, 0) ); |
61 | 63 | ||
62 | SYSCALL( fmlp_down(od) ); | ||
63 | |||
64 | SYSCALL( fmlp_up(od) ); | ||
65 | |||
66 | pid = fork(); | 64 | pid = fork(); |
67 | 65 | ||
68 | ASSERT( pid != -1 ); | 66 | ASSERT( pid != -1 ); |
69 | 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 | |||
70 | if (pid == 0) { | 72 | if (pid == 0) { |
71 | /* child */ | 73 | /* child */ |
72 | SYSCALL_FAILS(EINVAL, fmlp_down(od) ); | 74 | SYSCALL_FAILS(EINVAL, litmus_lock(od) ); |
73 | SYSCALL_FAILS(EINVAL, fmlp_up(od) ); | 75 | SYSCALL_FAILS(EINVAL, litmus_unlock(od) ); |
76 | |||
77 | SYSCALL( task_mode(BACKGROUND_TASK) ); | ||
78 | |||
74 | exit(0); | 79 | exit(0); |
75 | } else { | 80 | } else { |
76 | SYSCALL( fmlp_down(od) ); | 81 | |
77 | SYSCALL( fmlp_up(od) ); | 82 | SYSCALL( litmus_lock(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 | |||
78 | SYSCALL( waitpid(pid, &status, 0) ); | 90 | SYSCALL( waitpid(pid, &status, 0) ); |
91 | |||
79 | ASSERT(WEXITSTATUS(status) == 0); | 92 | ASSERT(WEXITSTATUS(status) == 0); |
80 | } | 93 | } |
81 | 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 | |||
9 | TESTCASE(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 | |||
32 | TESTCASE(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 | |||
49 | TESTCASE(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 | |||
81 | TESTCASE(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 | } | ||
diff --git a/tests/make_catalog.py b/tests/make_catalog.py index 75b6aca..96f9b23 100755 --- a/tests/make_catalog.py +++ b/tests/make_catalog.py | |||
@@ -63,6 +63,7 @@ def create_tc_tables(out=sys.stdout): | |||
63 | plugins.add(p) | 63 | plugins.add(p) |
64 | 64 | ||
65 | plugins.discard('ALL') | 65 | plugins.discard('ALL') |
66 | plugins.discard('LITMUS') | ||
66 | 67 | ||
67 | _('#include "tests.h"') | 68 | _('#include "tests.h"') |
68 | 69 | ||
@@ -78,7 +79,9 @@ def create_tc_tables(out=sys.stdout): | |||
78 | count = 0 | 79 | count = 0 |
79 | _('int %s_TESTS[] = {' % p) | 80 | _('int %s_TESTS[] = {' % p) |
80 | for (i, tc) in enumerate(tests): | 81 | for (i, tc) in enumerate(tests): |
81 | if p in tc.plugins or 'ALL' in tc.plugins: | 82 | if p in tc.plugins or \ |
83 | 'ALL' in tc.plugins or \ | ||
84 | 'LITMUS' in tc.plugins and p != 'LINUX': | ||
82 | _('\t%d,' % i) | 85 | _('\t%d,' % i) |
83 | count += 1 | 86 | count += 1 |
84 | _('};') | 87 | _('};') |
diff --git a/tests/runner.c b/tests/runner.c index f2e42b2..ccf8d46 100644 --- a/tests/runner.c +++ b/tests/runner.c | |||
@@ -7,8 +7,8 @@ | |||
7 | #include <stdio.h> | 7 | #include <stdio.h> |
8 | 8 | ||
9 | 9 | ||
10 | /* auto generated by SConstruct */ | 10 | /* auto generated by Makefile */ |
11 | #include "__test_catalog.inc" | 11 | #include "../test_catalog.inc" |
12 | 12 | ||
13 | #include "litmus.h" | 13 | #include "litmus.h" |
14 | 14 | ||