summaryrefslogtreecommitdiffstats
path: root/spec/rtems/timer/req/initiate-server.yml
blob: b430c9286b2bf61e4dbdc01eb31012bd5d68f576 (plain) (blame)
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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
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/initiate-server
- role: interface-function
  uid: ../if/server-default-priority
post-conditions:
- name: Status
  states:
  - name: Ok
    test-code: |
      T_rsc_success( ctx->status );
    text: |
      The return status of ${../if/initiate-server:/name} shall be
      ${../../status/if/successful:/name}.
  - name: IncStat
    test-code: |
      T_rsc( ctx->status, RTEMS_INCORRECT_STATE );
    text: |
      The return status of ${../if/initiate-server:/name} shall be
      ${../../status/if/incorrect-state:/name}
  - name: InvPrio
    test-code: |
      T_rsc( ctx->status, RTEMS_INVALID_PRIORITY );
    text: |
      The return status of ${../if/initiate-server:/name} shall be
      ${../../status/if/invalid-priority:/name}.
  - name: TooMany
    test-code: |
      T_rsc( ctx->status, RTEMS_TOO_MANY );
    text: |
      The return status of ${../if/initiate-server:/name} shall be
      ${../../status/if/too-many:/name}.
  - name: Unsat
    test-code: |
      T_rsc( ctx->status, RTEMS_UNSATISFIED  );
    text: |
      The return status of ${../if/initiate-server:/name} shall be
      ${../../status/if/unsatisfied:/name}.
  test-epilogue: null
  test-prologue: null
- name: Started
  states:
  - name: 'Yes'
    test-code: |
      T_true( ExistTimerServer() );
    text: |
      The Timer Server task shall be started after the
      ${../if/initiate-server:/name} call.
  - name: 'No'
    test-code: |
      T_false( ExistTimerServer() );
    text: |
      The Timer Server task shall not be started after the
      ${../if/initiate-server:/name} call.
  test-epilogue: null
  test-prologue: null
- name: TaskPrio
  states:
  - name: Set
    test-code: |
      if ( ctx->priority == RTEMS_TIMER_SERVER_DEFAULT_PRIORITY ) {
        T_eq_u32( GetTimerServerPriority(), 0 );
      } else {
        T_eq_u32( GetTimerServerPriority(), ctx->priority );
      }
    text: |
      The priority of the Timer Server task shall be equal to the priority
      specified by the ${../if/initiate-server:/params[0]/name} parameter in
      the ${../if/initiate-server:/name} call.
  - name: Nop
    test-code: |
      T_eq_u32( GetTimerServerPriority(), ctx->before_priority );
    text: |
      The priority of the Timer Server task shall not be modified
      by the ${../if/initiate-server:/name} call.
  test-epilogue: null
  test-prologue: null
- name: TaskStack
  states:
  - name: Set
    test-code: |
      T_ge_sz( GetTimerServerStackSize(), ctx->stack_size );
    text: |
      The stack size of the Timer Server task shall be greater than or equal to
      the stack size specified by the ${../if/initiate-server:/params[1]/name}
      parameter in the ${../if/initiate-server:/name} call.
  - name: Nop
    test-code: |
      T_ge_sz( GetTimerServerStackSize(), ctx->before_stack_size );
    text: |
      The stack size of the Timer Server task shall not be modified
      by the ${../if/initiate-server:/name} call.
  test-epilogue: null
  test-prologue: null
- name: TaskAttr
  states:
  - name: Set
    test-code: |
      T_true( HasTimerServerFloatingPoint() );
    text: |
      The task attributes of the Timer Server task shall be specified by the
      ${../if/initiate-server:/params[2]/name} parameter in the
      ${../if/initiate-server:/name} call.
  - name: Nop
    test-code: |
      T_true( HasTimerServerFloatingPoint() == ctx->before_has_floating_point );
    text: |
      The task attributes of the Timer Server task shall not be modified by the
      ${../if/initiate-server:/name} call.
  test-epilogue: null
  test-prologue: null
pre-conditions:
- name: Priority
  states:
  - name: Valid
    test-code: |
      ctx->priority = 13;
    text: |
      While the ${../if/initiate-server:/params[0]/name} parameter is valid.
  - name: Default
    test-code: |
      ctx->priority = RTEMS_TIMER_SERVER_DEFAULT_PRIORITY;
    text: |
      While the ${../if/initiate-server:/params[0]/name} parameter is equal to
      ${../if/server-default-priority:/name}.
  - name: Invalid
    test-code: |
      ctx->priority = PRIO_INVALID;
    text: |
      While the ${../if/initiate-server:/params[0]/name} parameter is invalid.
  test-epilogue: null
  test-prologue: null
- name: Stack
  states:
  - name: Allocatable
    test-code: |
      ctx->stack_size = RTEMS_MINIMUM_STACK_SIZE;
    text: |
      While the ${../if/initiate-server:/params[1]/name} parameter specifies a
      task stack size which is allocatable by the system.
  - name: TooLarge
    test-code: |
      ctx->stack_size = SIZE_MAX;
    text: |
      While the ${../if/initiate-server:/params[1]/name} parameter specifies a
      task stack size which is not allocatable by the system.
  test-epilogue: null
  test-prologue: null
- name: Started
  states:
  - name: 'Yes'
    test-code: |
      rtems_status_code status;

      if ( !ExistTimerServer() ) {
        status = rtems_timer_initiate_server(
          RTEMS_TIMER_SERVER_DEFAULT_PRIORITY,
          RTEMS_MINIMUM_STACK_SIZE,
          RTEMS_DEFAULT_ATTRIBUTES
        );
        T_rsc_success( status );
      }
    text: |
      While the Timer Server task is started.
  - name: 'No'
    test-code: |
      DeleteTimerServer();
    text: |
      While the Timer Server task is not started.
  test-epilogue: null
  test-prologue: null
- name: TaskObj
  states:
  - name: Available
    test-code: |
      /* The test clean up ensures that all tasks objects are free. */
    text: |
      While the system has at least one inactive task object available.
  - name: Unavailable
    test-code: |
      ctx->task_objects = T_seize_objects(
        AllocateTaskObject,
        NULL
      );
    text: |
      While the system has no inactive task object available.
  test-epilogue: null
  test-prologue: null
rationale: null
references: []
requirement-type: functional
skip-reasons: {}
test-action: |
  if ( ExistTimerServer() ) {
    ctx->before_priority = GetTimerServerPriority();
    ctx->before_stack_size = GetTimerServerStackSize();
    ctx->before_has_floating_point = HasTimerServerFloatingPoint();
  }

  ctx->status = rtems_timer_initiate_server(
    ctx->priority,
    ctx->stack_size,
    RTEMS_FLOATING_POINT
  );
test-brief: null
test-cleanup: |
  T_surrender_objects( &ctx->task_objects, rtems_task_delete );
test-context:
- brief: |
    If the Timer Server task exists before the action,
    its priority before the action.
  description: null
  member: |
    rtems_task_priority before_priority
- brief: |
    If the Timer Server task exists before the action,
    its stack size before the action.
  description: null
  member: |
    size_t before_stack_size
- brief: |
    If the Timer Server task exists before the action,
    whether the floating point attribute is set before the action.
  description: null
  member: |
    bool before_has_floating_point
- brief: |
    The ${../if/initiate-server:/params[0]/name}
    parameter for the action.
  description: null
  member: |
    rtems_task_priority priority
- brief: |
    The ${../if/initiate-server:/params[1]/name}
    parameter for the action.
  description: null
  member: |
    size_t stack_size
- brief: |
    The status value returned by the action ${../if/initiate-server:/name}.
  description: null
  member: |
    rtems_status_code status
- brief: |
    This member is used by the T_seize_objects() and T_surrender_objects()
    support functions.
  description: null
  member: |
    void *task_objects
test-context-support: null
test-description: null
test-header: null
test-includes:
- rtems.h
- rtems/rtems/timerimpl.h
test-local-includes:
- tx-support.h
test-prepare: null
test-setup:
  brief: null
  code: |
    ctx->task_objects = NULL;
  description: null
test-stop: null
test-support: |
  static bool ExistTimerServer( void )
  {
    return GetTimerServerTaskId() != RTEMS_INVALID_ID;
  }

  static rtems_task_priority GetTimerServerPriority( void )
  {
    return GetPriority( GetTimerServerTaskId() );
  }

  static size_t GetTimerServerStackSize( void )
  {
    rtems_tcb *tcb;
    rtems_id server_task_id;
    server_task_id = GetTimerServerTaskId();
    T_ne_u32( server_task_id, RTEMS_INVALID_ID );
    tcb = GetThread( server_task_id );
    T_not_null( tcb );
    return tcb->Start.Initial_stack.size;
  }

  static bool HasTimerServerFloatingPoint( void )
  {
    rtems_tcb *tcb;
    rtems_id server_task_id;
    server_task_id = GetTimerServerTaskId();
    T_ne_u32( server_task_id, RTEMS_INVALID_ID );
    tcb = GetThread( server_task_id );
    T_not_null( tcb );
    return tcb->is_fp;
  }

  static rtems_status_code AllocateTaskObject( void *arg, rtems_id *task_id )
  {
    (void) arg;

    return rtems_task_create(
      rtems_build_name( 'T', 'A', ' ', 'N' ),
      PRIO_LOW,
      RTEMS_MINIMUM_STACK_SIZE,
      RTEMS_DEFAULT_MODES,
      RTEMS_DEFAULT_ATTRIBUTES,
      task_id
    );
  }

test-target: testsuites/validation/tc-timer-initiate-server.c
test-teardown:
  brief: Make sure the time server in not running after this test.
  code: |
    DeleteTimerServer();
  description: null
text: ${.:text-template}
transition-map:
- enabled-by: true
  post-conditions:
    Status: Ok
    Started: 'Yes'
    TaskPrio: Set
    TaskStack: Set
    TaskAttr: Set
  pre-conditions:
    Priority:
      - Valid
      - Default
    Stack:
      - Allocatable
    Started:
      - 'No'
    TaskObj:
      - Available
- enabled-by: true
  post-conditions:
    Status: IncStat
    Started: 'Yes'
    TaskPrio: Nop
    TaskStack: Nop
    TaskAttr: Nop
  pre-conditions:
    Priority: all
    Stack: all
    Started:
      - 'Yes'
    TaskObj: all
- enabled-by: true
  post-conditions:
    Status: InvPrio
    Started: 'No'
    TaskPrio: "N/A"
    TaskStack: "N/A"
    TaskAttr: "N/A"
  pre-conditions:
    Priority:
      - Invalid
    Stack: all
    Started:
      - 'No'
    TaskObj: all
- enabled-by: true
  post-conditions:
    Status: TooMany
    Started: 'No'
    TaskPrio: "N/A"
    TaskStack: "N/A"
    TaskAttr: "N/A"
  pre-conditions:
    Priority:
      - Valid
      - Default
    Stack: all
    Started:
      - 'No'
    TaskObj:
      - Unavailable
- enabled-by: true
  post-conditions:
    Status: Unsat
    Started: 'No'
    TaskPrio: "N/A"
    TaskStack: "N/A"
    TaskAttr: "N/A"
  pre-conditions:
    Priority:
      - Valid
      - Default
    Stack:
      - TooLarge
    Started:
      - 'No'
    TaskObj:
      - Available
type: requirement