source: rtems-central/spec/req/rtems/tasks/create-from-config-errors.yml @ 51f9a65

Last change on this file since 51f9a65 was 51f9a65, checked in by Sebastian Huber <sebastian.huber@…>, on 09/10/20 at 13:21:24

spec: Specify rtems_task_create_from_config()

  • Property mode set to 100644
File size: 11.7 KB
Line 
1SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
2copyrights:
3- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
4enabled-by: true
5functional-type: action
6links:
7- role: interface-function
8  uid: /if/rtems/tasks/create-from-config
9post-conditions:
10- name: Status
11  states:
12  - name: Ok
13    test-code: |
14      T_rsc_success( ctx->status );
15      T_eq_ptr( ctx->id, &ctx->id_value );
16      T_ne_u32( ctx->id_value, 0xffffffff );
17
18      sc = rtems_task_delete( ctx->id_value );
19      T_rsc_success( sc );
20    text: |
21      The status shall be RTEMS_SUCCESSFUL.  The value of the object identifier
22      referenced by the id parameter shall identify the created task.
23  - name: InvAddress
24    test-code: |
25      T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
26      T_null( ctx->id );
27      T_eq_u32( ctx->id_value, 0xffffffff );
28    text: |
29      The status shall be RTEMS_INVALID_ADDRESS.
30  - name: InvName
31    test-code: |
32      T_rsc( ctx->status, RTEMS_INVALID_NAME );
33      T_eq_u32( ctx->id_value, 0xffffffff );
34    text: |
35      The status shall be RTEMS_INVALID_NAME.  If the id parameter is not NULL,
36      then the value of the object identifier referenced by the id parameter
37      shall be unchanged.
38  - name: InvPrio
39    test-code: |
40      T_rsc( ctx->status, RTEMS_INVALID_PRIORITY );
41      T_eq_u32( ctx->id_value, 0xffffffff );
42    text: |
43      The status shall be RTEMS_INVALID_PRIORITY.  If the id parameter is not
44      NULL, then the value of the object identifier referenced by the id
45      parameter shall be unchanged.
46  - name: InvSize
47    test-code: |
48      T_rsc( ctx->status, RTEMS_INVALID_SIZE );
49      T_eq_u32( ctx->id_value, 0xffffffff );
50    text: |
51      The status shall be RTEMS_INVALID_SIZE.  If the id parameter is not NULL,
52      then the value of the object identifier referenced by the id parameter
53      shall be unchanged.
54  - name: TooMany
55    test-code: |
56      T_rsc( ctx->status, RTEMS_TOO_MANY );
57      T_eq_u32( ctx->id_value, 0xffffffff );
58    text: |
59      The status shall be RTEMS_TOO_MANY.  If the id parameter is not NULL,
60      then the value of the object identifier referenced by the id parameter
61      shall be unchanged.
62  - name: Unsatisfied
63    test-code: |
64      T_rsc( ctx->status, RTEMS_UNSATISFIED  );
65      T_eq_u32( ctx->id_value, 0xffffffff );
66    text: |
67      The status shall be RTEMS_UNSATISFIED.  If the id parameter is not NULL,
68      then the value of the object identifier referenced by the id parameter
69      shall be unchanged.
70  test-epilogue: null
71  test-prologue: |
72    rtems_status_code sc;
73pre-conditions:
74- name: Id
75  states:
76  - name: Id
77    test-code: |
78      ctx->id = &ctx->id_value;
79    text: |
80      The id parameter shall reference an object identifier value.
81  - name: 'Null'
82    test-code: |
83      ctx->id = NULL;
84    text: |
85      The id parameter shall be NULL.
86  test-epilogue: null
87  test-prologue: null
88- name: Name
89  states:
90  - name: Valid
91    test-code: |
92      ctx->config.name = rtems_build_name( 'N', 'A', 'M', 'E' );
93    text: |
94      The name of the task configuration shall be valid.
95  - name: Inv
96    test-code: |
97      ctx->config.name = 0;
98    text: |
99      The name of the task configuration shall be invalid.
100  test-epilogue: null
101  test-prologue: null
102- name: Prio
103  states:
104  - name: Valid
105    test-code: |
106      ctx->config.initial_priority = 254;
107    text: |
108      The initial priority of the task configuration shall be valid.
109  - name: Zero
110    test-code: |
111      ctx->config.initial_priority = 0;
112    text: |
113      The initial priority of the task configuration shall be zero.
114  - name: Inv
115    test-code: |
116      ctx->config.initial_priority = 0xffffffff;
117    text: |
118      The initial priority of the task configuration shall be invalid.
119  test-epilogue: null
120  test-prologue: null
121- name: Tasks
122  states:
123  - name: Avail
124    test-code: |
125      /* Nothing to do */
126    text: |
127      There shall be at least one inactive task object available.
128  - name: None
129    test-code: |
130      create_extension_status = ctx->create_extension_status;
131      ctx->create_extension_status = true;
132
133      while ( true ) {
134        rtems_status_code sc;
135        rtems_id id;
136
137        sc = rtems_task_create_from_config( &valid_task_config, &id );
138
139        if ( sc == RTEMS_SUCCESSFUL ) {
140          Objects_Control           *obj;
141          const Objects_Information *info;
142
143          info = _Objects_Get_information_id( id );
144          T_quiet_assert_not_null( info );
145          obj = _Objects_Get_no_protection( id, info );
146          T_quiet_assert_not_null( obj );
147          _Chain_Append_unprotected( &ctx->tasks, &obj->Node );
148        } else {
149          T_quiet_rsc( sc, RTEMS_TOO_MANY );
150          break;
151        }
152      }
153
154      ctx->create_extension_status = create_extension_status;
155    text: |
156      There shall be no inactive task object available.
157  test-epilogue: null
158  test-prologue: |
159    bool create_extension_status;
160- name: TLS
161  states:
162  - name: Enough
163    test-code: |
164      ctx->config.maximum_thread_local_storage_size = MAX_TLS_SIZE;
165    text: |
166      The maximum thread-local storage size of the task configuration shall be
167      greater than or equal to the thread-local storage size.
168  - name: Small
169    test-code: |
170      ctx->config.maximum_thread_local_storage_size = 0;
171    text: |
172      The maximum thread-local storage size of the task configuration shall be
173      less than the thread-local storage size.
174  test-epilogue: null
175  test-prologue: null
176- name: Stack
177  states:
178  - name: Enough
179    test-code: |
180      ctx->stack_size = RTEMS_MINIMUM_STACK_SIZE;
181    text: |
182      The task stack size of the task configuration shall be greater than or
183      equal to the configured minimum size.
184  - name: Small
185    test-code: |
186      ctx->stack_size = 0;
187    text: |
188      The task stack size of the task configuration shall be less than to the
189      configured minimum size.
190  test-epilogue: null
191  test-prologue: null
192- name: Ext
193  states:
194  - name: Ok
195    test-code: |
196      ctx->create_extension_status = true;
197    text: |
198      None of the task create extensions shall fail.
199  - name: Err
200    test-code: |
201      ctx->create_extension_status = false;
202    text: |
203      At least one of the task create extensions shall fail.
204  test-epilogue: null
205  test-prologue: null
206- name: Preempt
207  states:
208  - name: 'Yes'
209    test-code: |
210      ctx->config.initial_modes &= ~RTEMS_PREEMPT_MASK;
211      ctx->config.initial_modes |= RTEMS_PREEMPT;
212    text: |
213      The preemptible mode in the initial modes of the task configuration shall
214      be set to preemptible.
215  - name: 'No'
216    test-code: |
217      ctx->config.initial_modes &= ~RTEMS_PREEMPT_MASK;
218      ctx->config.initial_modes |= RTEMS_NO_PREEMPT;
219    text: |
220      The preemptible mode in the initial modes of the task configuration shall
221      be set to non-preemptible.
222  test-epilogue: null
223  test-prologue: null
224rationale: null
225references: []
226requirement-type: functional
227skip-reasons: {}
228test-action: |
229  ctx->config.storage_size = RTEMS_TASK_STORAGE_SIZE(
230    ctx->config.maximum_thread_local_storage_size + ctx->stack_size,
231    ctx->config.attributes
232  );
233  ctx->status = rtems_task_create_from_config( &ctx->config, ctx->id );
234test-brief: null
235test-cleanup: |
236  Chain_Node *node;
237
238  while ( ( node = _Chain_Get_unprotected( &ctx->tasks ) ) ) {
239    Objects_Control   *obj;
240    rtems_status_code  sc;
241
242    obj = (Objects_Control *) node;
243    sc = rtems_task_delete( obj->id );
244    T_quiet_rsc_success( sc );
245  }
246test-context:
247- brief: null
248  description: null
249  member: rtems_status_code status
250- brief: null
251  description: null
252  member: rtems_task_config config
253- brief: null
254  description: null
255  member: rtems_id *id
256- brief: null
257  description: null
258  member: rtems_id id_value
259- brief: null
260  description: null
261  member: bool create_extension_status
262- brief: null
263  description: null
264  member: size_t stack_size
265- brief: null
266  description: null
267  member: rtems_id extension_id
268- brief: null
269  description: null
270  member: Chain_Control tasks
271test-context-support: null
272test-description: null
273test-header: null
274test-includes:
275- rtems.h
276- rtems/score/chainimpl.h
277- rtems/score/objectimpl.h
278- string.h
279test-local-includes: []
280test-prepare: |
281  ctx->id_value = 0xffffffff;
282  memset( &ctx->config, 0, sizeof( ctx->config ) );
283test-setup:
284  brief: null
285  code: |
286    rtems_status_code sc;
287    int var;
288
289    var = tls_variable;
290    RTEMS_OBFUSCATE_VARIABLE( var );
291    tls_variable = var;
292
293    sc = rtems_extension_create(
294      rtems_build_name( 'T', 'C', 'F', 'C' ),
295      &extensions,
296      &ctx->extension_id
297    );
298    T_rsc_success( sc );
299
300    _Chain_Initialize_empty( &ctx->tasks );
301  description: null
302test-stop: null
303test-support: |
304  static _Thread_local int tls_variable;
305
306  #define MAX_TLS_SIZE 128
307
308  RTEMS_TASK_STORAGE_ALIGNMENT static char task_storage[
309    RTEMS_TASK_STORAGE_SIZE(
310      MAX_TLS_SIZE + RTEMS_MINIMUM_STACK_SIZE,
311      RTEMS_FLOATING_POINT
312    )
313  ];
314
315  static const rtems_task_config valid_task_config = {
316    .name = rtems_build_name( 'T', 'A', 'S', 'K' ),
317    .initial_priority = 1,
318    .storage_area = task_storage,
319    .storage_size = sizeof( task_storage ),
320    .maximum_thread_local_storage_size = MAX_TLS_SIZE,
321    .initial_modes = RTEMS_DEFAULT_MODES,
322    .attributes = RTEMS_DEFAULT_MODES
323  };
324
325  static bool ThreadCreate( rtems_tcb *executing, rtems_tcb *created )
326  {
327    (void) executing;
328    (void) created;
329
330    return
331      ReqRtemsTasksCreateFromConfigErrors_Instance.create_extension_status;
332  }
333
334  static const rtems_extensions_table extensions = {
335    .thread_create = ThreadCreate
336  };
337test-target: testsuites/validation/tc-tasks-create-from-config-errors.c
338test-teardown:
339  brief: null
340  code: |
341    rtems_status_code sc;
342
343    sc = rtems_extension_delete( ctx->extension_id );
344    T_rsc_success( sc );
345  description: null
346text: ${.:text-template}
347transition-map:
348- enabled-by: true
349  post-conditions:
350    Status: Ok
351  pre-conditions:
352    Id:
353    - Id
354    Name:
355    - Valid
356    Prio:
357    - Valid
358    Tasks:
359    - Avail
360    TLS:
361    - Enough
362    Stack:
363    - Enough
364    Ext:
365    - Ok
366    Preempt: all
367- enabled-by: true
368  post-conditions:
369    Status: InvAddress
370  pre-conditions:
371    Id:
372    - 'Null'
373    Name: all
374    Prio: all
375    Tasks: all
376    TLS: all
377    Stack: all
378    Ext: all
379    Preempt: all
380- enabled-by: true
381  post-conditions:
382    Status: InvName
383  pre-conditions:
384    Id:
385    - Id
386    Name:
387    - Inv
388    Prio: all
389    Tasks: all
390    TLS: all
391    Stack: all
392    Ext: all
393    Preempt: all
394- enabled-by: true
395  post-conditions:
396    Status: InvPrio
397  pre-conditions:
398    Id:
399    - Id
400    Name:
401    - Valid
402    Prio:
403    - Zero
404    - Inv
405    Tasks: all
406    TLS: all
407    Stack: all
408    Ext: all
409    Preempt: all
410- enabled-by: true
411  post-conditions:
412    Status: TooMany
413  pre-conditions:
414    Id:
415    - Id
416    Name:
417    - Valid
418    Prio:
419    - Valid
420    Tasks:
421    - None
422    TLS: all
423    Stack: all
424    Ext: all
425    Preempt: all
426- enabled-by: true
427  post-conditions:
428    Status: InvSize
429  pre-conditions:
430    Id:
431    - Id
432    Name:
433    - Valid
434    Prio:
435    - Valid
436    Tasks:
437    - Avail
438    TLS:
439    - Small
440    Stack: all
441    Ext: all
442    Preempt: all
443- enabled-by: true
444  post-conditions:
445    Status: InvSize
446  pre-conditions:
447    Id:
448    - Id
449    Name:
450    - Valid
451    Prio:
452    - Valid
453    Tasks:
454    - Avail
455    TLS:
456    - Enough
457    Stack:
458    - Small
459    Ext: all
460    Preempt: all
461- enabled-by: true
462  post-conditions:
463    Status: Unsatisfied
464  pre-conditions:
465    Id:
466    - Id
467    Name:
468    - Valid
469    Prio:
470    - Valid
471    Tasks:
472    - Avail
473    TLS:
474    - Enough
475    Stack:
476    - Enough
477    Ext:
478    - Err
479    Preempt: all
480- enabled-by: RTEMS_SMP
481  post-conditions:
482    Status: Unsatisfied
483  pre-conditions:
484    Id:
485    - Id
486    Name:
487    - Valid
488    Prio:
489    - Valid
490    Tasks:
491    - Avail
492    TLS:
493    - Enough
494    Stack:
495    - Enough
496    Ext:
497    - Ok
498    Preempt:
499    - 'No'
500type: requirement
Note: See TracBrowser for help on using the repository browser.