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
|
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
copyrights:
- Copyright (C) 2021 embedded brains GmbH & Co. KG
enabled-by: true
functional-type: action
links:
- role: function-implementation
uid: /score/tq/req/surrender
- role: requirement-refinement
uid: ../if/group
post-conditions:
- name: Status
states:
- name: Ok
test-code: |
T_eq_int( ctx->status, Status( ctx, STATUS_SUCCESSFUL ) );
text: |
The return status of the directive call shall be derived from
${../../status/if/successful:/name}.
- name: MaxCountExceeded
test-code: |
T_eq_int( ctx->status, Status( ctx, STATUS_MAXIMUM_COUNT_EXCEEDED ) );
text: |
The return status of the directive call shall be derived from
${../../status/if/maximum-count-exceeded:/name}.
test-epilogue: null
test-prologue: null
- name: Surrender
states:
- name: FIFO
test-code: |
${../../tq/req/surrender:/test-run}( &ctx->tq_ctx->base );
text: |
The thread queue of the semaphore shall be surrendered in FIFO order.
- name: Priority
test-code: |
${../../tq/req/surrender:/test-run}( &ctx->tq_ctx->base );
text: |
The thread queue of the semaphore shall be surrendered in priority order.
test-epilogue: null
test-prologue: null
- name: Count
states:
- name: Zero
test-code: |
T_eq_u32( ctx->count_after, 0 );
text: |
The count of the semaphore shall be zero.
- name: One
test-code: |
T_eq_u32( ctx->count_after, 1 );
text: |
The count of the semaphore shall be one.
- name: PlusOne
test-code: |
T_eq_u32( ctx->count_after, ctx->count_before + 1 );
text: |
The count of the semaphore shall be incremented by one.
- name: Nop
test-code: |
T_eq_u32( ctx->count_after, ctx->count_before );
text: |
The count of the semaphore shall not be modified.
test-epilogue: null
test-prologue: null
pre-conditions:
- name: Variant
states:
- name: Binary
test-code: |
if ( ctx->tq_ctx->variant != TQ_SEM_BINARY ) {
${.:skip}
}
text: |
Where the semaphore is a binary semaphore.
- name: Counting
test-code: |
if ( ctx->tq_ctx->variant != TQ_SEM_COUNTING ) {
${.:skip}
}
text: |
Where the semaphore is a counting semaphore.
test-epilogue: null
test-prologue: null
- name: Discipline
states:
- name: FIFO
test-code: |
if ( ctx->tq_ctx->base.discipline != TQ_FIFO ) {
${.:skip}
}
text: |
Where the thread queue of the semaphore uses the FIFO discipline.
- name: Priority
test-code: |
if ( ctx->tq_ctx->base.discipline != TQ_PRIORITY ) {
${.:skip}
}
text: |
Where the thread queue of the semaphore uses the priority discipline.
test-epilogue: null
test-prologue: null
- name: Count
states:
- name: LessMax
test-code: |
ctx->blocked = false;
if ( ctx->tq_ctx->variant == TQ_SEM_BINARY ) {
ctx->count_before = 0;
} else {
ctx->count_before = UINT32_MAX - 1;
}
text: |
While the count of the semaphore is less than the maximum count.
- name: Max
test-code: |
ctx->blocked = false;
if ( ctx->tq_ctx->variant == TQ_SEM_BINARY ) {
ctx->count_before = 1;
} else {
ctx->count_before = UINT32_MAX;
}
text: |
While the count of the semaphore is equal to the maximum count.
- name: Blocked
test-code: |
ctx->blocked = true;
ctx->count_before = 0;
text: |
While the semaphore has threads blocked on the semaphore.
test-epilogue: null
test-prologue: null
rationale: null
references: []
requirement-type: functional
skip-reasons: {}
test-action: |
TQSemSetCount( ctx->tq_ctx, ctx->count_before );
if ( ctx->blocked ) {
TQSend( &ctx->tq_ctx->base, TQ_BLOCKER_A, TQ_EVENT_ENQUEUE );
}
ctx->status = TQSurrender( &ctx->tq_ctx->base );
ctx->count_after = TQSemGetCount( ctx->tq_ctx );
TQSemSetCount( ctx->tq_ctx, 1 );
test-brief: null
test-cleanup: null
test-context:
- brief: |
This member specifies the semaphore count before the directive call.
description: null
member: |
uint32_t count_before
- brief: |
This member contains the return status of the directive call.
description: null
member: |
Status_Control status
- brief: |
This member contains the semaphore count after the directive call.
description: null
member: |
uint32_t count_after
- brief: |
If this member is true, then there shall be threads blocked on the
semaphore.
description: null
member: |
bool blocked
test-context-support: null
test-description: null
test-header:
code: null
freestanding: false
includes: []
local-includes:
- tx-thread-queue.h
run-params:
- description: |
is the thread queue context.
dir: inout
name: tq_ctx
specifier: TQSemContext *${.:name}
target: testsuites/validation/tr-sem-surrender.h
test-includes: []
test-local-includes:
- tr-sem-surrender.h
- tr-tq-surrender.h
test-prepare: null
test-setup:
brief: null
code: |
ctx->tq_ctx->base.wait = TQ_WAIT_FOREVER;
TQReset( &ctx->tq_ctx->base );
description: null
test-stop: null
test-support: |
typedef ${.:/test-context-type} Context;
static Status_Control Status( const Context *ctx, Status_Control status )
{
return TQConvertStatus( &ctx->tq_ctx->base, status );
}
test-target: testsuites/validation/tr-sem-surrender.c
test-teardown: null
text: |
When the calling surrenders the semaphore.
transition-map:
- enabled-by: true
post-conditions:
Status: Ok
Surrender: N/A
Count: One
pre-conditions:
Variant:
- Binary
Discipline: all
Count:
- LessMax
- Max
- enabled-by: true
post-conditions:
Status: Ok
Surrender:
- specified-by: Discipline
Count: Zero
pre-conditions:
Variant:
- Binary
Discipline: all
Count:
- Blocked
- enabled-by: true
post-conditions:
Status: Ok
Surrender: N/A
Count: PlusOne
pre-conditions:
Variant:
- Counting
Discipline: all
Count:
- LessMax
- enabled-by: true
post-conditions:
Status: MaxCountExceeded
Surrender: N/A
Count: Nop
pre-conditions:
Variant:
- Counting
Discipline: all
Count:
- Max
- enabled-by: true
post-conditions:
Status: Ok
Surrender:
- specified-by: Discipline
Count: Zero
pre-conditions:
Variant:
- Counting
Discipline: all
Count:
- Blocked
type: requirement
|