summaryrefslogtreecommitdiffstats
path: root/spec/rtems/scheduler/req/add-processor.yml
blob: 73e13fd5492d8de51edcb747310dd84a34856515 (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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
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: interface-function
  uid: ../if/add-processor
post-conditions:
- name: Status
  states:
  - name: Ok
    test-code: |
      T_rsc_success( ctx->status );
    text: |
      The return status of ${../if/add-processor:/name} shall be
      ${../../status/if/successful:/name}.
  - name: InvId
    test-code: |
      T_rsc( ctx->status, RTEMS_INVALID_ID );
    text: |
      The return status of ${../if/add-processor:/name} shall be
      ${../../status/if/invalid-id:/name}.
  - name: NotConf
    test-code: |
      T_rsc( ctx->status, RTEMS_NOT_CONFIGURED );
    text: |
      The return status of ${../if/add-processor:/name} shall be
      ${../../status/if/not-configured:/name}.
  - name: IncStat
    test-code: |
      T_rsc( ctx->status, RTEMS_INCORRECT_STATE );
    text: |
      The return status of ${../if/add-processor:/name} shall be
      ${../../status/if/incorrect-state:/name}.
  - name: InUse
    test-code: |
      T_rsc( ctx->status, RTEMS_RESOURCE_IN_USE );
    text: |
      The return status of ${../if/add-processor:/name} shall be
      ${../../status/if/resource-in-use:/name}.
  test-epilogue: null
  test-prologue: null
- name: Added
  states:
  - name: 'Yes'
    test-code: |
      T_eq_sz( ctx->scheduler_log.header.recorded, 2 );
      T_eq_int(
        ctx->scheduler_log.events[ 0 ].operation,
        T_SCHEDULER_MAP_PRIORITY
      );
      T_eq_int(
        ctx->scheduler_log.events[ 1 ].operation,
        T_SCHEDULER_ADD_PROCESSOR
      );

      priority = GetSelfPriority();

      if ( ctx->scheduler_id == ctx->scheduler_c_id ) {
        SetSelfScheduler( ctx->scheduler_c_id, priority );
      }

      SetSelfAffinityOne( CPU_TO_ADD );
      T_eq_u32( rtems_scheduler_get_processor(), CPU_TO_ADD );
      SetSelfAffinityAll();

      if ( ctx->scheduler_id == ctx->scheduler_c_id ) {
        SetSelfScheduler( ctx->scheduler_a_id, priority );
      }
    text: |
      The processor specified by the ${../if/add-processor:/params[1]/name}
      parameter shall be added to the scheduler specified by the
      ${../if/add-processor:/params[0]/name} by the
      ${../if/add-processor:/name} call.
  - name: Nop
    test-code: |
      T_eq_sz( ctx->scheduler_log.header.recorded, 0 );

      CPU_ZERO( &set );
      CPU_SET( CPU_TO_ADD, &set );
      sc = rtems_task_set_affinity( RTEMS_SELF, sizeof( set ), &set );
      T_rsc( sc, RTEMS_INVALID_NUMBER );
    text: |
      No processor shall be added to a scheduler by the
      ${../if/add-processor:/name} call.
  test-epilogue: null
  test-prologue: |
    rtems_status_code   sc;
    cpu_set_t           set;
    rtems_task_priority priority;
pre-conditions:
- name: HasReady
  states:
  - name: Ready
    test-code: |
      ctx->scheduler_id = ctx->scheduler_a_id;
    text: |
      While the scheduler has at least one ready thread.
  - name: Empty
    test-code: |
      #if defined(RTEMS_SMP)
      ctx->scheduler_id = ctx->scheduler_c_id;
      #else
      ctx->scheduler_id = ctx->scheduler_a_id;
      #endif
    text: |
      While the scheduler has no ready threads.
  test-epilogue: null
  test-prologue: null
- name: Id
  states:
  - name: Invalid
    test-code: |
      ctx->id = INVALID_ID;
    text: |
      While the ${../if/add-processor:/params[0]/name} parameter is not
      associated with a scheduler.
  - name: Scheduler
    test-code: |
      ctx->id = ctx->scheduler_id;
    text: |
      While the ${../if/add-processor:/params[0]/name} parameter is
      associated with a scheduler.
  test-epilogue: null
  test-prologue: null
- name: CPUIndex
  states:
  - name: Valid
    test-code: |
      #if defined(RTEMS_SMP)
      ctx->cpu_index = CPU_TO_ADD;
      #else
      ctx->cpu_index = 0;
      #endif
    text: |
      While the ${../if/add-processor:/params[1]/name} parameter is less than
      the configured processor maximum.
  - name: Invalid
    test-code: |
      ctx->cpu_index = rtems_configuration_get_maximum_processors();
    text: |
      While the ${../if/add-processor:/params[1]/name} parameter is greater
      than or equal to the configured processor maximum.
  test-epilogue: null
  test-prologue: null
- name: CPUState
  states:
  - name: Idle
    test-code: |
      sc = rtems_scheduler_remove_processor(
        ctx->scheduler_b_id,
        CPU_TO_ADD
      );
      T_rsc_success( sc );
      ctx->add_cpu_to_scheduler_b = true;
    text: |
      While the processor associated with the
      ${../if/add-processor:/params[1]/name} parameter is configured to be used
      by a scheduler, while the processor associated with the
      ${../if/add-processor:/params[1]/name} parameter is online, while the
      processor associated with the ${../if/add-processor:/params[1]/name}
      parameter is not owned by a scheduler.
  - name: InUse
    test-code: |
      /* Nothing to do */
    text: |
      While the processor associated with the
      ${../if/add-processor:/params[1]/name} parameter is owned by a scheduler.
  - name: NotOnline
    test-code: |
      sc = rtems_scheduler_remove_processor(
        ctx->scheduler_b_id,
        CPU_TO_ADD
      );
      T_rsc_success( sc );
      ctx->add_cpu_to_scheduler_b = true;
      #if defined(RTEMS_SMP)
      ctx->cpu->online = false;
      #endif
    text: |
      While the processor associated with the
      ${../if/add-processor:/params[1]/name} parameter is not online.
  - name: NotUsable
    test-code: |
      ctx->cpu_index = rtems_configuration_get_maximum_processors() - 1;
    text: |
      While the processor associated with the
      ${../if/add-processor:/params[1]/name} parameter is not configured to be
      used by a scheduler.
  test-epilogue: null
  test-prologue: |
    rtems_status_code sc;
rationale: null
references: []
requirement-type: functional
skip-reasons:
  OnlyOneCPU: |
    Where the system is build with SMP support disabled, the system has exactly
    one processor and there is no other processor available to add to a
    scheduler.
test-action: |
  T_scheduler_log *log;

  log = T_scheduler_record_2( &ctx->scheduler_log );
  T_null( log );

  ctx->status = rtems_scheduler_add_processor( ctx->id, ctx->cpu_index );

  log = T_scheduler_record( NULL );
  T_eq_ptr( &log->header, &ctx->scheduler_log.header );
test-brief: null
test-cleanup: |
  #if defined(RTEMS_SMP)
  rtems_status_code sc;

  ctx->cpu->online = ctx->online;

  if ( ctx->status == RTEMS_SUCCESSFUL ) {
    sc = rtems_scheduler_remove_processor( ctx->scheduler_id, CPU_TO_ADD );
    T_rsc_success( sc );
  }

  if ( ctx->add_cpu_to_scheduler_b ) {
    sc = rtems_scheduler_add_processor( ctx->scheduler_b_id, CPU_TO_ADD );
    T_rsc_success( sc );
  }
  #endif
test-context:
- brief: |
    This member specifies the scheduler used to add the processor.
  description: null
  member: |
    rtems_id scheduler_id
- brief: |
    This member contains the identifier of scheduler A.
  description: null
  member: |
    rtems_id scheduler_a_id
- brief: |
    This member contains the identifier of scheduler B.
  description: null
  member: |
    rtems_id scheduler_b_id
- brief: |
    This member contains the identifier of scheduler C.
  description: null
  member: |
    rtems_id scheduler_c_id
- brief: |
    This member references the processor control of the processor to add.
  description: null
  member: |
    Per_CPU_Control *cpu
- brief: |
    This member contains the online status of the processor to add before the
    ${../if/add-processor:/name} call is prepared.
  description: null
  member: |
    bool online;
- brief: |
    If this member is true, then the processor should be added to the scheduler
    B during cleanup.
  description: null
  member: |
    bool add_cpu_to_scheduler_b;
- brief: |
    This member provides the scheduler operation records.
  description: null
  member: |
    T_scheduler_log_2 scheduler_log;
- brief: |
    This member contains the return value of the
    ${../if/add-processor:/name} call.
  description: null
  member: |
    rtems_status_code status
- brief: |
    This member specifies if the ${../if/add-processor:/params[0]/name}
    parameter value.
  description: null
  member: |
    rtems_id id
- brief: |
    This member specifies if the ${../if/add-processor:/params[1]/name}
    parameter value.
  description: null
  member: |
    uint32_t cpu_index
test-context-support: null
test-description: null
test-header: null
test-includes:
- rtems.h
- rtems/test-scheduler.h
- rtems/score/percpu.h
test-local-includes:
- ts-config.h
- tx-support.h
test-prepare: |
  #if defined(RTEMS_SMP)
  ctx->add_cpu_to_scheduler_b = false;
  ctx->online = _Per_CPU_Is_processor_online( ctx->cpu );
  #endif
test-setup:
  brief: null
  code: |
    rtems_status_code sc;

    sc = rtems_scheduler_ident(
      TEST_SCHEDULER_A_NAME,
      &ctx->scheduler_a_id
    );
    T_rsc_success( sc );

    #if defined(RTEMS_SMP)
    ctx->cpu = _Per_CPU_Get_by_index( CPU_TO_ADD );

    sc = rtems_scheduler_ident( TEST_SCHEDULER_B_NAME, &ctx->scheduler_b_id );
    T_rsc_success( sc );

    sc = rtems_scheduler_ident( TEST_SCHEDULER_C_NAME, &ctx->scheduler_c_id );
    T_rsc_success( sc );
    #else
    ctx->scheduler_b_id = INVALID_ID;
    ctx->scheduler_c_id = INVALID_ID;
    #endif
  description: null
test-stop: null
test-support: |
  #define CPU_TO_ADD 1
test-target: testsuites/validation/tc-scheduler-add-processor.c
test-teardown: null
text: ${.:text-template}
transition-map:
- enabled-by: true
  post-conditions:
    Status: InvId
    Added: Nop
  pre-conditions:
    HasReady: all
    Id:
    - Invalid
    CPUIndex:
    - Valid
    CPUState:
    - InUse
- enabled-by: true
  post-conditions:
    Status: InvId
    Added: Nop
  pre-conditions:
    HasReady: all
    Id:
    - Invalid
    CPUIndex:
    - Invalid
    CPUState: N/A
- enabled-by: true
  post-conditions:
    Status: NotConf
    Added: Nop
  pre-conditions:
    HasReady: all
    Id:
    - Scheduler
    CPUIndex:
    - Invalid
    CPUState: N/A
- enabled-by: true
  post-conditions:
    Status: InUse
    Added: Nop
  pre-conditions:
    HasReady: all
    Id:
    - Scheduler
    CPUIndex:
    - Valid
    CPUState:
    - InUse
- enabled-by: true
  post-conditions: OnlyOneCPU
  pre-conditions:
    HasReady: all
    Id: all
    CPUIndex:
    - Valid
    CPUState:
    - Idle
    - NotOnline
    - NotUsable
- enabled-by: RTEMS_SMP
  post-conditions:
    Status: Ok
    Added: 'Yes'
  pre-conditions:
    HasReady: all
    Id:
    - Scheduler
    CPUIndex:
    - Valid
    CPUState:
    - Idle
- enabled-by: RTEMS_SMP
  post-conditions:
    Status: InvId
    Added: Nop
  pre-conditions:
    HasReady: all
    Id:
    - Invalid
    CPUIndex:
    - Valid
    CPUState:
    - Idle
    - NotOnline
    - NotUsable
- enabled-by: RTEMS_SMP
  post-conditions:
    Status: NotConf
    Added: Nop
  pre-conditions:
    HasReady: all
    Id:
    - Scheduler
    CPUIndex:
    - Valid
    CPUState:
    - NotUsable
- enabled-by: RTEMS_SMP
  post-conditions:
    Status: IncStat
    Added: Nop
  pre-conditions:
    HasReady: all
    Id:
    - Scheduler
    CPUIndex:
    - Valid
    CPUState:
    - NotOnline
type: requirement