summaryrefslogtreecommitdiffstats
path: root/spec/rtems/task/val/task.yml
blob: 92f018d9e42b1ee6c8b0983a19e0c8d8a0cc5673 (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
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
copyrights:
- Copyright (C) 2021, 2022 embedded brains GmbH & Co. KG
enabled-by: true
links: []
test-actions:
- action-brief: |
    Call ${../if/self:/name} check the returned value.
  action-code: |
    rtems_id id;

    id = rtems_task_self();
  checks:
  - brief: |
      Check that the returned value is equal to the object identifier of the
      calling task.
    code: |
      T_step_eq_u32( ${.:/step}, id, 0x0a010001 );
    links: []
  links:
  - role: validation
    uid: ../req/self
- action-brief: |
    Call ${../if/iterate:/name} with a visitor which always returns
    ${/c/if/false:/name}.
  action-code: |
    TaskIterateContext ctx;
    uint32_t           task_count;

    task_count = rtems_scheduler_get_processor_maximum();

    if ( task_count > 4 ) {
      task_count = 4;
    }

    ++task_count;

    memset( &ctx, 0, sizeof( ctx ) );
    ctx.owner_before = _RTEMS_Allocator_is_owner();
    rtems_task_iterate( TaskVisitor, &ctx );
    ctx.owner_after = _RTEMS_Allocator_is_owner();
  checks:
  - brief: |
      Check that the all counter is equal to the count of tasks.  Check that
      the calling task was visited exacly once.  Firstly, this shows that
      ${../if/iterate:/name} used the parameters specified by
      ${../if/iterate:/params[0]/name} and ${../if/iterate:/params[1]/name}.
      Secondly, this shows that the iteration was done over all tasks.
    code: |
      T_step_eq_u32( ${.:/step}, ctx.counter_all, task_count );
      T_step_eq_u32( ${.:/step}, ctx.counter_self, 1 );
    links:
    - role: validation
      uid: ../req/iterate-visit
    - role: validation
      uid: ../req/iterate-done
  - brief: |
      Check that the object alloctor mutex was not owned before and after the
      call.  Check that the object alloctor mutex was owned during the
      iteration.
    code: |
      T_step_false( ${.:/step}, ctx.owner_before );
      T_step_true( ${.:/step}, ctx.owner_in_visitor );
      T_step_false( ${.:/step}, ctx.owner_after );
    links:
    - role: validation
      uid: ../req/iterate-start
    - role: validation
      uid: ../req/iterate-done
  links:
  - role: validation
    uid: ../req/iterate-start
- action-brief: |
    Call ${../if/iterate:/name} with a visitor which returns
    ${/c/if/true:/name}.
  action-code: |
    TaskIterateContext ctx;

    memset( &ctx, 0, sizeof( ctx ) );
    ctx.done = true;
    rtems_task_iterate( TaskVisitor, &ctx );
  checks:
  - brief: |
      Check that the all counter is equal to one.  This shows that the
      iteration stops when the visitor returns ${/c/if/true:/name}.
    code: |
      T_step_eq_u32( ${.:/step}, ctx.counter_all, 1 );
    links:
    - role: validation
      uid: ../req/iterate-stop
  links: []
- action-brief: |
    Assert that ${../if/storage-alignment:/name} is a constant expression which
    evaluates to the expected value.
  action-code: |
    RTEMS_STATIC_ASSERT(
      RTEMS_TASK_STORAGE_ALIGNMENT == CPU_STACK_ALIGNMENT,
      STORAGE_ALIGNMENT
    );
  checks: []
  links:
  - role: validation
    uid: ../req/storage-alignment
- action-brief: |
    Assert that ${../if/no-priority:/name} is a constant expression which
    evaluates to the expected value.
  action-code: |
    RTEMS_STATIC_ASSERT(
      RTEMS_NO_PRIORITY == RTEMS_CURRENT_PRIORITY,
      NO_PRIORITY
    );
  checks: []
  links:
  - role: validation
    uid: ../req/no-priority
- action-brief: |
    Assert that ${../if/minimum-stack-size:/name} is a constant expression which
    evaluates to the expected value.
  action-code: |
    RTEMS_STATIC_ASSERT(
      RTEMS_MINIMUM_STACK_SIZE == STACK_MINIMUM_SIZE,
      MINIMUM_STACK_SIZE
    );
  checks: []
  links:
  - role: validation
    uid: ../req/minimum-stack-size
- action-brief: |
    Assert that ${../if/configured-minimum-stack-size:/name} is a constant
    expression which evaluates to the expected value.
  action-code: |
    RTEMS_STATIC_ASSERT(
      RTEMS_CONFIGURED_MINIMUM_STACK_SIZE == 0,
      CONFIGURED_MINIMUM_STACK_SIZE
    );
  checks: []
  links:
  - role: validation
    uid: ../req/configured-minimum-stack-size
- action-brief: |
    Assert that ${../if/minimum-priority:/name} is a constant expression which
    evaluates to the expected value.
  action-code: |
    RTEMS_STATIC_ASSERT( RTEMS_MINIMUM_PRIORITY == 1, MINIMUM_PRIORITY );
  checks: []
  links:
  - role: validation
    uid: ../req/minimum-priority
- action-brief: |
    Validate ${../if/self-define:/name} using a sample directive call.
  action-code: |
    rtems_status_code sc;
  checks:
  - brief: |
      Check that ${../if/is-suspended:/name} returns the expected status if
      called with a task identifier parameter of ${../if/self-define:/name}.
    code: |
      sc = rtems_task_is_suspended( RTEMS_SELF );
      T_step_rsc_success( ${.:/step}, sc );
    links:
    - role: validation
      uid: ../req/self-define
  links: []
- action-brief: |
    Validate the home scheduler of tasks created by ${../if/create:/name} and
    constructed by ${../if/construct:/name}.
  action-code: |
    rtems_status_code sc;
    rtems_status_code id;
  checks:
  - brief: |
      Create a task.  Check that the home scheduler of the created task is
      scheduler A.
    code: |
      sc = rtems_task_create(
        OBJECT_NAME,
        1,
        TEST_MINIMUM_STACK_SIZE,
        RTEMS_DEFAULT_MODES,
        RTEMS_DEFAULT_ATTRIBUTES,
        &id
      );
      T_step_rsc_success( ${.:/step}, sc );

      T_step_eq_u32( ${.:/step}, GetScheduler( id ), SCHEDULER_A_ID );
      DeleteTask( id );
    links:
    - role: validation
      uid: ../req/create-home-scheduler
  - brief: |
      Construct a task.  Check that the home scheduler of the constructed task
      is scheduler A.
    code: |
      sc = rtems_task_construct( &DefaultTaskConfig, &id );
      T_step_rsc_success( ${.:/step}, sc );

      T_step_eq_u32( ${.:/step}, GetScheduler( id ), SCHEDULER_A_ID );
      DeleteTask( id );
    links:
    - role: validation
      uid: ../req/construct-home-scheduler
  links: []
test-brief: |
  This test case collection provides validation test cases for requirements of
  the ${../if/group:/name}.
test-context: []
test-context-support: null
test-description: null
test-header: null
test-includes:
- rtems.h
- string.h
- rtems/score/apimutex.h
test-local-includes:
- ts-config.h
- tx-support.h
test-setup: null
test-stop: null
test-support: |
  typedef struct {
    bool     owner_before;
    bool     owner_in_visitor;
    bool     owner_after;
    uint32_t counter_all;
    uint32_t counter_self;
    bool     done;
  } TaskIterateContext;

  static bool TaskVisitor( rtems_tcb *tcb, void *arg )
  {
    TaskIterateContext *ctx;

    ctx = arg;
    ++ctx->counter_all;

    if ( rtems_task_self() == tcb->Object.id ) {
      ++ctx->counter_self;
    }

    ctx->owner_in_visitor = _RTEMS_Allocator_is_owner();

    return ctx->done;
  }
test-target: testsuites/validation/tc-task.c
test-teardown: null
type: test-case