summaryrefslogtreecommitdiffstats
path: root/spec/rtems/mode/val/modes.yml
blob: e201fa5b66e67139ccbcfad63389cfc0b70bcd81 (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
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
copyrights:
- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
enabled-by: true
links: []
test-actions:
- action-brief: |
    Validate the non-default task mode constants.
  action-code: |
    /* No action */
  checks:
  - brief: |
      Check that RTEMS_NO_ASR is a power of two representable as an integer of
      type rtems_mode.
    code: |
      T_step_true( ${.:/step}, IsPowerOfTwo( RTEMS_NO_ASR ) );
    links:
    - role: validation
      uid: ../req/bit-set
    - role: validation
      uid: ../if/no-asr
  - brief: |
      Check that RTEMS_NO_PREEMPT is a power of two representable as an integer
      of type rtems_mode.
    code: |
      T_step_true( ${.:/step}, IsPowerOfTwo( RTEMS_NO_PREEMPT ) );
    links:
    - role: validation
      uid: ../req/bit-set
    - role: validation
      uid: ../if/no-preempt
  - brief: |
      Check that RTEMS_TIMESLICE is a power of two representable as an integer
      of type rtems_mode.
    code: |
      T_step_true( ${.:/step}, IsPowerOfTwo( RTEMS_TIMESLICE ) );
    links:
    - role: validation
      uid: ../req/bit-set
    - role: validation
      uid: ../if/timeslice
  links: []
- action-brief: |
    Validate the default task mode constants.
  action-code: |
    /* No action */
  checks:
  - brief: |
      Check that RTEMS_ASR is equal to zero.
    code: |
      T_step_eq_u32( ${.:/step}, RTEMS_ASR, 0 );
    links:
    - role: validation
      uid: ../req/default
    - role: validation
      uid: ../if/asr
  - brief: |
      Check that RTEMS_DEFAULT_MODES is equal to zero.
    code: |
      T_step_eq_u32( ${.:/step}, RTEMS_DEFAULT_MODES, 0 );
    links:
    - role: validation
      uid: ../req/default
    - role: validation
      uid: ../if/default
  - brief: |
      Check that RTEMS_NO_TIMESLICE is equal to zero.
    code: |
      T_step_eq_u32( ${.:/step}, RTEMS_NO_TIMESLICE, 0 );
    links:
    - role: validation
      uid: ../req/default
    - role: validation
      uid: ../if/no-timeslice
  - brief: |
      Check that RTEMS_PREEMPT is equal to zero.
    code: |
      T_step_eq_u32( ${.:/step}, RTEMS_PREEMPT, 0 );
    links:
    - role: validation
      uid: ../req/default
    - role: validation
      uid: ../if/preempt
  links: []
- action-brief: |
    Validate RTEMS_ALL_MODE_MASKS.
  action-code: |
    /* No action */
  checks:
  - brief: |
      Check that the bitwise and of RTEMS_ASR_MASK and RTEMS_ALL_MODE_MASKS is
      equal to RTEMS_ASR_MASK.
    code: |
      T_step_eq_u32(
        ${.:/step},
        RTEMS_ASR_MASK & RTEMS_ALL_MODE_MASKS,
        RTEMS_ASR_MASK
      );
    links:
    - role: validation
      uid: ../req/masks-all
    - role: validation
      uid: ../if/asr-mask
  - brief: |
      Check that the bitwise and of RTEMS_PREEMPT_MASK and RTEMS_ALL_MODE_MASKS
      is equal to RTEMS_PREEMPT_MASK.
    code: |
      T_step_eq_u32(
        ${.:/step},
        RTEMS_PREEMPT_MASK & RTEMS_ALL_MODE_MASKS,
        RTEMS_PREEMPT_MASK
      );
    links:
    - role: validation
      uid: ../req/masks-all
    - role: validation
      uid: ../if/preempt-mask
  - brief: |
      Check that the bitwise and of RTEMS_TIMESLICE_MASK and
      RTEMS_ALL_MODE_MASKS is equal to RTEMS_TIMESLICE_MASK.
    code: |
      T_step_eq_u32(
        ${.:/step},
        RTEMS_TIMESLICE_MASK & RTEMS_ALL_MODE_MASKS,
        RTEMS_TIMESLICE_MASK
      );
    links:
    - role: validation
      uid: ../req/masks-all
    - role: validation
      uid: ../if/timeslice-mask
  - brief: |
      Check that the bitwise and of RTEMS_INTERRUPT_MASK and
      RTEMS_ALL_MODE_MASKS is equal to RTEMS_INTERRUPT_MASK.
    code: |
      T_step_eq_u32(
        ${.:/step},
        RTEMS_INTERRUPT_MASK & RTEMS_ALL_MODE_MASKS,
        RTEMS_INTERRUPT_MASK
      );
    links:
    - role: validation
      uid: ../req/masks-all
    - role: validation
      uid: ../if/interrupt-mask
  links: []
- action-brief: |
    Validate the task mode mask constants except RTEMS_INTERRUPT_MASK.
  action-code: |
    /* No action */
  checks:
  - brief: |
      Check that RTEMS_ASR_MASK is a power of two representable as an integer
      of type rtems_mode.
    code: |
      T_step_true( ${.:/step}, IsPowerOfTwo( RTEMS_ASR_MASK ) );
    links:
    - role: validation
      uid: ../req/masks
    - role: validation
      uid: ../if/asr-mask
  - brief: |
      Check that RTEMS_PREEMPT_MASK is a power of two representable as an
      integer of type rtems_mode.
    code: |
      T_step_true( ${.:/step}, IsPowerOfTwo( RTEMS_PREEMPT_MASK ) );
    links:
    - role: validation
      uid: ../req/masks
    - role: validation
      uid: ../if/preempt-mask
  - brief: |
      Check that RTEMS_TIMESLICE_MASK is a power of two representable as an
      integer of type rtems_mode.
    code: |
      T_step_true( ${.:/step}, IsPowerOfTwo( RTEMS_TIMESLICE_MASK ) );
    links:
    - role: validation
      uid: ../req/masks
    - role: validation
      uid: ../if/timeslice-mask
  links: []
- action-brief: |
    Calculate the bitwise or of all task mode mask constants and 0xff.
  action-code: |
    rtems_mode modes;

    modes = 0;
    modes |= 0xff;
    modes |= RTEMS_ASR_MASK;
    modes |= RTEMS_PREEMPT_MASK;
    modes |= RTEMS_TIMESLICE_MASK;
  checks:
  - brief: |
      Check that the count of set bits in the calculated value is equal to the
      count of task mode mask constants except RTEMS_INTERRUPT_MASK plus eight.
      Since each task mode mask constants except RTEMS_INTERRUPT_MASK is a
      power of two and the bitwise and of 0xff and RTEMS_INTERRUPT_MASK is
      equal to RTEMS_INTERRUPT_MASK this proves that each constant and 0xff has
      a unique value.
    code: |
      T_step_eq_int( ${.:/step}, PopCount( modes ), 11 );
    links:
    - role: validation
      uid: ../req/masks-unique
    - role: validation
      uid: ../if/asr-mask
    - role: validation
      uid: ../if/preempt-mask
    - role: validation
      uid: ../if/timeslice-mask
  links: []
- action-brief: |
    Calculate the bitwise or of all non-default task mode constants.
  action-code: |
    rtems_mode modes;

    modes = 0;
    modes |= RTEMS_NO_ASR;
    modes |= RTEMS_NO_PREEMPT;
    modes |= RTEMS_TIMESLICE;
  checks:
  - brief: |
      Check that the count of set bits in the calculated value is equal to the
      count of non-default task mode constants.  Since each non-default task
      mode constants except is a power of this proves that each constant has a
      unique value.
    code: |
      T_step_eq_int( ${.:/step}, PopCount( modes ), 3 );
    links:
    - role: validation
      uid: ../req/unique
    - role: validation
      uid: ../if/no-asr
    - role: validation
      uid: ../if/no-preempt
    - role: validation
      uid: ../if/timeslice
  links: []
- action-brief: |
    Validate ${../if/interrupt-level:/name}.
  action-code: |
    /* Nothing to do */
  checks:
  - brief: |
      Check the result of ${../if/interrupt-level:/name} for a sample value.
    code: |
      T_step_eq_u32(
        ${.:/step},
        RTEMS_INTERRUPT_LEVEL( UINT32_MAX ),
        RTEMS_INTERRUPT_MASK
      );
    links:
    - role: validation
      uid: ../req/interrupt-level
  links: []
test-brief: |
  Tests the task mode constants and function-like macros of the Classic API.
test-context: []
test-context-support: null
test-description: null
test-header: null
test-includes:
- rtems.h
test-local-includes: []
test-setup: null
test-stop: null
test-support: |
  static bool IsPowerOfTwo( rtems_mode mode )
  {
    return mode != 0 && ( mode & ( mode - 1 ) ) == 0;
  }

  static int PopCount( rtems_mode modes )
  {
    int count;

    count = 0;

    while ( modes != 0 ) {
      ++count;
      modes &= modes - 1;
    }

    return count;
  }
test-target: testsuites/validation/tc-modes.c
test-teardown: null
type: test-case