source: rtems-central/spec/score/interr/val/terminate.yml @ f048c15

Last change on this file since f048c15 was f048c15, checked in by Sebastian Huber <sebastian.huber@…>, on 07/04/22 at 06:34:33

spec: Update due to API changes

Update #4670.

  • Property mode set to 100644
File size: 10.3 KB
Line 
1SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
2copyrights:
3- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
4enabled-by: true
5links: []
6test-actions:
7- action-brief: |
8    Create five dynamic extensions.  Call the system termination procedure.
9    Delete three dynamic extension during the fatal extension invocation.
10    Delete the two remaining dynamic extensions.
11  action-code: |
12    rtems_status_code      sc;
13    rtems_extensions_table table;
14    bool                   shutdown_ok;
15
16    #if defined(RTEMS_SMP)
17    shutdown_ok =
18      ( _Per_CPU_Get_state( _Per_CPU_Get_snapshot() ) == PER_CPU_STATE_UP );
19    #else
20    shutdown_ok = true;
21    #endif
22
23    memset( &table, 0, sizeof( table ) );
24
25    table.fatal = FatalExtension2;
26    sc = rtems_extension_create(
27      rtems_build_name( ' ', ' ', ' ', '2' ),
28      &table,
29      &extension_ids[ 2 ]
30    );
31    T_step_rsc_success( ${step}, sc );
32
33    table.fatal = FatalExtension3;
34    sc = rtems_extension_create(
35      rtems_build_name( ' ', ' ', ' ', '3' ),
36      &table,
37      &extension_ids[ 3 ]
38    );
39    T_step_rsc_success( ${step}, sc );
40
41    table.fatal = FatalExtension4;
42    sc = rtems_extension_create(
43      rtems_build_name( ' ', ' ', ' ', '4' ),
44      &table,
45      &extension_ids[ 4 ]
46    );
47    T_step_rsc_success( ${step}, sc );
48
49    table.fatal = FatalExtension5;
50    sc = rtems_extension_create(
51      rtems_build_name( ' ', ' ', ' ', '5' ),
52      &table,
53      &extension_ids[ 5 ]
54    );
55    T_step_rsc_success( ${step}, sc );
56
57    table.fatal = FatalExtension6;
58    sc = rtems_extension_create(
59      rtems_build_name( ' ', ' ', ' ', '6' ),
60      &table,
61      &extension_ids[ 6 ]
62    );
63    T_step_rsc_success( ${step}, sc );
64
65    test_case_active = true;
66
67    if ( setjmp( before_terminate ) == 0 ) {
68      _Terminate( RTEMS_FATAL_SOURCE_APPLICATION, 123456 );
69    }
70
71    test_case_active = false;
72  checks:
73  - brief: |
74      Where the system was built with SMP support enabled, check that a
75      shutdown request was issued.
76    code: |
77      #if defined(RTEMS_SMP)
78      shutdown_ok = ( shutdown_ok && _ISR_Get_level() != 0 &&
79        _Per_CPU_Get_state( _Per_CPU_Get() ) == PER_CPU_STATE_SHUTDOWN );
80      _ISR_Set_level( 0 );
81      #endif
82      T_step_true( ${step}, shutdown_ok );
83    links:
84    - role: validation
85      uid: ../req/terminate-shutdown
86  - brief: |
87      Delete the dynamic extension sets.
88    code: |
89      sc = rtems_extension_delete( extension_ids[ 2 ] );
90      T_step_rsc_success( ${step}, sc );
91
92      sc = rtems_extension_delete( extension_ids[ 6 ] );
93      T_step_rsc_success( ${step}, sc );
94    links: []
95  - brief: |
96      Check that the fatal extensions were invoked with the expected source.
97    code: |
98      T_step_eq_int(
99        ${step},
100        info[ 0 ].source,
101        RTEMS_FATAL_SOURCE_APPLICATION
102      );
103      T_step_eq_int(
104        ${step},
105        info[ 1 ].source,
106        RTEMS_FATAL_SOURCE_APPLICATION
107      );
108      T_step_eq_int(
109        ${step},
110        info[ 2 ].source,
111        RTEMS_FATAL_SOURCE_APPLICATION
112      );
113      T_step_eq_int(
114        ${step},
115        info[ 4 ].source,
116        RTEMS_FATAL_SOURCE_APPLICATION
117      );
118      T_step_eq_int(
119        ${step},
120        info[ 5 ].source,
121        RTEMS_FATAL_SOURCE_APPLICATION
122      );
123      T_step_eq_int(
124        ${step},
125        info[ 6 ].source,
126        RTEMS_FATAL_SOURCE_APPLICATION
127      );
128    links:
129    - role: validation
130      uid: ../req/terminate-userext
131  - brief: |
132      Check that the fatal extensions were invoked with the expected always set
133      to false argument.
134    code: |
135      T_step_false( ${step}, info[ 0 ].always_set_to_false );
136      T_step_false( ${step}, info[ 1 ].always_set_to_false );
137      T_step_false( ${step}, info[ 2 ].always_set_to_false );
138      T_step_false( ${step}, info[ 4 ].always_set_to_false );
139      T_step_false( ${step}, info[ 5 ].always_set_to_false );
140      T_step_false( ${step}, info[ 6 ].always_set_to_false );
141    links:
142    - role: validation
143      uid: ../req/terminate-userext
144  - brief: |
145      Check that the fatal extensions were invoked with the expected code.
146    code: |
147      T_step_eq_ulong( ${step}, info[ 0 ].code, 123456 );
148      T_step_eq_ulong( ${step}, info[ 1 ].code, 123456 );
149      T_step_eq_ulong( ${step}, info[ 2 ].code, 123456 );
150      T_step_eq_ulong( ${step}, info[ 4 ].code, 123456 );
151      T_step_eq_ulong( ${step}, info[ 5 ].code, 123456 );
152      T_step_eq_ulong( ${step}, info[ 6 ].code, 123456 );
153    links:
154    - role: validation
155      uid: ../req/terminate-userext
156  - brief: |
157      Check that the fatal extensions were invoked in forward order.
158    code: |
159      T_step_eq_uint( ${step}, info[ 0 ].counter, 1 );
160      T_step_eq_uint( ${step}, info[ 1 ].counter, 2 );
161      T_step_eq_uint( ${step}, info[ 2 ].counter, 3 );
162      T_step_eq_uint( ${step}, info[ 4 ].counter, 4 );
163      T_step_eq_uint( ${step}, info[ 5 ].counter, 5 );
164      T_step_eq_uint( ${step}, info[ 6 ].counter, 6 );
165    links:
166    - role: validation
167      uid: /rtems/userext/req/fatal-order
168  - brief: |
169      Check that the fatal extension in the deleted extension set was not
170      invoked.
171    code: |
172      T_step_eq_int( ${step}, info[ 3 ].source, 0 );
173      T_step_false( ${step}, info[ 3 ].always_set_to_false );
174      T_step_eq_ulong( ${step}, info[ 3 ].code, 0 );
175      T_step_eq_uint( ${step}, info[ 3 ].counter, 0 );
176    links:
177    - role: validation
178      uid: /rtems/userext/req/fatal-iterate-remove
179  - brief: |
180      Check that the system state is terminated.
181    code: |
182      T_step_eq_int( ${step}, _System_state_Get(), SYSTEM_STATE_TERMINATED );
183    links:
184    - role: validation
185      uid: ../req/terminate-state
186  - brief: |
187      Check that the system was halted with the expected fatal source.
188    code: |
189      T_step_eq_int( ${step}, halt_source, RTEMS_FATAL_SOURCE_APPLICATION );
190    links:
191    - role: validation
192      uid: ../req/terminate-halt
193    - role: validation
194      uid: ../req/terminate-shutdown-halt
195  - brief: |
196      Check that the system was halted with the expected fatal code.
197    code: |
198      T_step_eq_ulong( ${step}, halt_code, 123456 );
199    links:
200    - role: validation
201      uid: ../req/terminate-halt
202    - role: validation
203      uid: ../req/terminate-shutdown-halt
204  - brief: |
205      Check that the system was finally halted.
206    code: |
207      T_step_eq_uint( ${step}, counter, 7 );
208    links:
209    - role: validation
210      uid: ../req/terminate-halt
211    - role: validation
212      uid: ../req/terminate-shutdown-halt
213  links:
214  - role: validation
215    uid: ../req/terminate
216test-brief: |
217  Tests system termination procedure.
218test-context: []
219test-context-support: null
220test-description: null
221test-header: null
222test-includes:
223- bsp.h
224- rtems/bspIo.h
225- rtems/test-info.h
226- rtems/score/atomic.h
227- rtems/score/io.h
228- rtems/score/percpu.h
229- rtems/score/sysstate.h
230- setjmp.h
231- string.h
232test-local-includes:
233- tc-userext.h
234test-setup: null
235test-stop: null
236test-support: |
237  typedef struct {
238    unsigned int       counter;
239    rtems_fatal_source source;
240    bool               always_set_to_false;
241    rtems_fatal_code   code;
242  } FatalInfo;
243
244  static Atomic_Uint counter;
245
246  static FatalInfo info[ 7 ];
247
248  static bool test_case_active;
249
250  static const rtems_extensions_table bsp = BSP_INITIAL_EXTENSION;
251
252  static jmp_buf before_terminate;
253
254  static unsigned int halt_counter;
255
256  static rtems_fatal_source halt_source;
257
258  static rtems_fatal_code halt_code;
259
260  static rtems_id extension_ids[ 7 ];
261
262  static unsigned int GetCounter( void )
263  {
264    return _Atomic_Fetch_add_uint( &counter, 1, ATOMIC_ORDER_RELAXED ) + 1;
265  }
266
267  void __real__CPU_Fatal_halt( uint32_t source, CPU_Uint32ptr code );
268
269  void __wrap__CPU_Fatal_halt( uint32_t source, CPU_Uint32ptr code );
270
271  void __wrap__CPU_Fatal_halt( uint32_t source, CPU_Uint32ptr code )
272  {
273    if ( test_case_active ) {
274      halt_counter = GetCounter();
275      halt_source = source;
276      halt_code = code;
277      longjmp( before_terminate, 1 );
278    } else {
279  #if defined(RTEMS_GCOV_COVERAGE)
280      rtems_test_gcov_dump_info();
281  #endif
282      __real__CPU_Fatal_halt( source, code );
283    }
284  }
285
286  static void FatalExtension(
287    rtems_fatal_source source,
288    bool               always_set_to_false,
289    rtems_fatal_code   code,
290    size_t             index
291  )
292  {
293    if ( test_case_active ) {
294      info[ index ].counter = GetCounter();
295      info[ index ].source = source;
296      info[ index ].always_set_to_false = always_set_to_false;
297      info[ index ].code = code;
298    } else {
299      ( *bsp.fatal )( source, always_set_to_false, code );
300    }
301  }
302
303  void FatalExtension0(
304    rtems_fatal_source source,
305    bool               always_set_to_false,
306    rtems_fatal_code   code
307  )
308  {
309    FatalExtension( source, always_set_to_false, code, 0 );
310  }
311
312  void FatalExtension1(
313    rtems_fatal_source source,
314    bool               always_set_to_false,
315    rtems_fatal_code   code
316  )
317  {
318    FatalExtension( source, always_set_to_false, code, 1 );
319  }
320
321  static void FatalExtension2(
322    rtems_fatal_source source,
323    bool               always_set_to_false,
324    rtems_fatal_code   code
325  )
326  {
327    rtems_status_code sc;
328
329    FatalExtension( source, always_set_to_false, code, 2 );
330
331    sc = rtems_extension_delete( extension_ids[ 3 ] );
332    T_quiet_rsc_success( sc );
333  }
334
335  static void FatalExtension3(
336    rtems_fatal_source source,
337    bool               always_set_to_false,
338    rtems_fatal_code   code
339  )
340  {
341    FatalExtension( source, always_set_to_false, code, 3 );
342  }
343
344  static void FatalExtension4(
345    rtems_fatal_source source,
346    bool               always_set_to_false,
347    rtems_fatal_code   code
348  )
349  {
350    FatalExtension( source, always_set_to_false, code, 4 );
351  }
352
353  static void FatalExtension5(
354    rtems_fatal_source source,
355    bool               always_set_to_false,
356    rtems_fatal_code   code
357  )
358  {
359    rtems_status_code sc;
360
361    FatalExtension( source, always_set_to_false, code, 5 );
362
363    sc = rtems_extension_delete( extension_ids[ 5 ] );
364    T_quiet_rsc_success( sc );
365  }
366
367  static void FatalExtension6(
368    rtems_fatal_source source,
369    bool               always_set_to_false,
370    rtems_fatal_code   code
371  )
372  {
373    rtems_status_code sc;
374
375    FatalExtension( source, always_set_to_false, code, 6 );
376
377    sc = rtems_extension_delete( extension_ids[ 4 ] );
378    T_quiet_rsc_success( sc );
379  }
380test-target: testsuites/validation/tc-terminate.c
381test-teardown: null
382type: test-case
Note: See TracBrowser for help on using the repository browser.