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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
|
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
copyrights:
- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
enabled-by: true
functional-type: action
links:
- role: interface-function
uid: ../if/release
post-conditions:
- name: Status
states:
- name: Ok
test-code: |
T_rsc_success( ctx->status );
text: |
The return status of ${../if/release:/name} shall be
${../../status/if/successful:/name}.
- name: InvId
test-code: |
T_rsc( ctx->status, RTEMS_INVALID_ID );
text: |
The return status of ${../if/release:/name} shall be
${../../status/if/invalid-id:/name}.
- name: InvAddr
test-code: |
T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
text: |
The return status of ${../if/release:/name} shall be
${../../status/if/invalid-address:/name}.
test-epilogue: null
test-prologue: null
- name: Released
states:
- name: Valid
test-code: |
T_eq_u32( ctx->released_value, ctx->waiting_tasks );
text: |
The value of the variable for the number of released tasks shall equal
the number of tasks released by the ${../if/release:/name} call.
- name: Unchanged
test-code: |
T_eq_u32( ctx->released_value, RELEASED_INVALID_VALUE );
text: |
The value of variable for the number of released tasks shall be unchanged
by the ${../if/release:/name} call.
test-epilogue: null
test-prologue: null
pre-conditions:
- name: Id
states:
- name: NoObj
test-code: |
ctx->id = 0xffffffff;
text: |
The ${../if/release:/params[0]/name} parameter shall not be associated
with a barrier.
- name: Manual
test-code: |
ctx->id = ctx->manual_release_id;
text: |
The ${../if/release:/params[0]/name} parameter shall be associated with a
manual release barrier.
- name: Auto
test-code: |
ctx->id = ctx->auto_release_id;
text: |
The ${../if/release:/params[0]/name} parameter shall be associated with an
automatic release barrier.
test-epilogue: null
test-prologue: null
- name: Released
states:
- name: Valid
test-code: |
ctx->released = &ctx->released_value;
text: |
The ${../if/release:/params[1]/name} parameter shall reference an object
of type ${/c/if/uint32_t:/name}.
- name: 'Null'
test-code: |
ctx->released = NULL;
text: |
The ${../if/release:/params[1]/name} parameter shall be
${/c/if/null:/name}.
test-epilogue: null
test-prologue: |
ctx->released_value = RELEASED_INVALID_VALUE;
- name: Waiting
states:
- name: Zero
test-code: |
ctx->waiting_tasks = 0;
text: |
The number of tasks waiting at the barrier shall be zero.
- name: Positive
test-code: |
ctx->waiting_tasks = 1;
SendEvents( ctx->worker_id, EVENT_WAIT );
text: |
The number of tasks waiting at the barrier shall be positive.
test-epilogue: null
test-prologue: null
rationale: null
references: []
requirement-type: functional
skip-reasons: {}
test-action: |
ctx->status = rtems_barrier_release( ctx->id, ctx->released );
test-brief: null
test-cleanup: null
test-context:
- brief: null
description: null
member: |
rtems_id worker_id
- brief: null
description: null
member: |
rtems_id manual_release_id
- brief: null
description: null
member: |
rtems_id auto_release_id
- brief: null
description: null
member: |
uint32_t waiting_tasks
- brief: null
description: null
member: |
uint32_t released_value
- brief: null
description: null
member: |
rtems_id id
- brief: null
description: null
member: |
uint32_t *released
- brief: null
description: null
member: |
rtems_status_code status
test-context-support: null
test-description: null
test-header: null
test-includes:
- rtems.h
- string.h
test-local-includes: []
test-prepare: null
test-setup:
brief: null
code: |
rtems_status_code sc;
rtems_task_priority prio;
memset( ctx, 0, sizeof( *ctx ) );
prio = 0;
sc = rtems_task_set_priority( RTEMS_SELF, PRIO_NORMAL, &prio );
T_rsc_success( sc );
T_eq_u32( prio, PRIO_HIGH );
sc = rtems_task_create(
rtems_build_name( 'W', 'O', 'R', 'K' ),
PRIO_HIGH,
RTEMS_MINIMUM_STACK_SIZE,
RTEMS_DEFAULT_MODES,
RTEMS_DEFAULT_ATTRIBUTES,
&ctx->worker_id
);
T_assert_rsc_success( sc );
sc = rtems_task_start(
ctx->worker_id,
Worker,
(rtems_task_argument) ctx
);
T_assert_rsc_success( sc );
sc = rtems_barrier_create(
NAME,
RTEMS_BARRIER_MANUAL_RELEASE,
0,
&ctx->manual_release_id
);
T_assert_rsc_success( sc );
sc = rtems_barrier_create(
NAME,
RTEMS_BARRIER_AUTOMATIC_RELEASE,
2,
&ctx->auto_release_id
);
T_assert_rsc_success( sc );
description: null
test-stop: null
test-support: |
#define NAME rtems_build_name( 'T', 'E', 'S', 'T' )
#define EVENT_WAIT RTEMS_EVENT_0
#define RELEASED_INVALID_VALUE 0xffffffff
typedef RtemsBarrierReqRelease_Context Context;
typedef enum {
PRIO_HIGH = 1,
PRIO_NORMAL
} Priorities;
static void SendEvents( rtems_id id, rtems_event_set events )
{
rtems_status_code sc;
sc = rtems_event_send( id, events );
T_rsc_success( sc );
}
static void Worker( rtems_task_argument arg )
{
Context *ctx;
ctx = (Context *) arg;
while ( true ) {
rtems_status_code sc;
rtems_event_set events;
events = 0;
sc = rtems_event_receive(
RTEMS_ALL_EVENTS,
RTEMS_EVENT_ANY | RTEMS_WAIT,
RTEMS_NO_TIMEOUT,
&events
);
T_rsc_success( sc );
if ( ( events & EVENT_WAIT ) != 0 ) {
sc = rtems_barrier_wait( ctx->id, RTEMS_NO_TIMEOUT );
T_rsc_success( sc );
}
}
}
test-target: testsuites/validation/tc-barrier-release.c
test-teardown:
brief: null
code: |
rtems_status_code sc;
rtems_task_priority prio;
prio = 0;
sc = rtems_task_set_priority( RTEMS_SELF, PRIO_HIGH, &prio );
T_rsc_success( sc );
T_eq_u32( prio, PRIO_NORMAL );
if ( ctx->worker_id != 0 ) {
sc = rtems_task_delete( ctx->worker_id );
T_rsc_success( sc );
}
if ( ctx->manual_release_id != 0 ) {
sc = rtems_barrier_delete( ctx->manual_release_id );
T_rsc_success( sc );
}
if ( ctx->auto_release_id != 0 ) {
sc = rtems_barrier_delete( ctx->auto_release_id );
T_rsc_success( sc );
}
description: null
text: ${.:text-template}
transition-map:
- enabled-by: true
post-conditions:
Status: InvAddr
Released: Unchanged
pre-conditions:
Id: all
Released:
- 'Null'
Waiting: N/A
- enabled-by: true
post-conditions:
Status: InvId
Released: Unchanged
pre-conditions:
Id:
- NoObj
Released:
- Valid
Waiting: N/A
- enabled-by: true
post-conditions:
Status: Ok
Released: Valid
pre-conditions:
Id:
- Manual
- Auto
Released:
- Valid
Waiting: all
type: requirement
|