summaryrefslogtreecommitdiffstats
path: root/spec/score/thread/val/idle-body-no-return.yml
blob: 6cee6ef3e6dab6b36f8895286c8f28c1c689bdcf (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
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
copyrights:
- Copyright (C) 2022 embedded brains GmbH & Co. KG
enabled-by: true
links: []
test-actions:
- action-brief: |
    Create threads which execute an thread idle body.  Check that the thread
    idle body does not return.  If it would return, then an
    ${/score/interr/if/thread-exitted:/name} fatal error would occur.
  action-code: |
    SetSelfPriority( PRIO_NORMAL );
  checks:
  - brief: |
      Check that the CPU port thread idle body does not return.
    code: |
      CheckIdleBody( ctx, CPUThreadIdleBody );
    links:
    - role: validation
      uid: ../req/idle-body-no-return
  - brief: |
      Where the BSP provides an idle thread body, check that it does not
      return.
    code: |
      #if defined(BSP_IDLE_TASK_BODY)
      CheckIdleBody( ctx, BSPIdleTaskBody );
      #endif
    links:
    - role: validation
      uid: ../req/idle-body-no-return
  - brief: |
      Clean up all used resources.
    code: |
      RestoreRunnerPriority();
    links: []
  links: []
test-brief: |
  Tests thread idle body behaviour.
test-context:
- brief: |
    This member contains a counter.
  description: null
  member: |
    uint32_t counter;
test-context-support: null
test-description: null
test-header: null
test-includes:
- bsp.h
test-local-includes:
- tx-support.h
test-setup: null
test-stop: null
test-support: |
  typedef ${.:/test-context-type} Context;

  static void CheckIdleBody( Context *ctx, rtems_task_entry entry )
  {
    rtems_id id;

    ctx->counter = 0;
    id = CreateTask( "WORK", PRIO_LOW );
    StartTask( id, entry, ctx );

    while ( ctx->counter == 0 ) {
      rtems_status_code sc;

      sc = rtems_task_wake_after( 1 );
      T_rsc_success( sc );
    }

    T_eq_u32( ctx->counter, 1 );
    DeleteTask( id );
  }

  static void CPUThreadIdleBody( rtems_task_argument arg )
  {
    Context *ctx;

    ctx = (Context *) arg;
    ++ctx->counter;

    (void) _CPU_Thread_Idle_body( 0 );
  }

  #if defined(BSP_IDLE_TASK_BODY)
  static void BSPIdleTaskBody( rtems_task_argument arg )
  {
    Context *ctx;

    ctx = (Context *) arg;
    ++ctx->counter;

    (void) BSP_IDLE_TASK_BODY( 0 );
  }
  #endif
test-target: testsuites/validation/tc-thread-idle-body-no-return.c
test-teardown: null
type: test-case