summaryrefslogtreecommitdiffstats
path: root/spec/score/tq/req/timeout-mrsp.yml
blob: 9d7865514f8c2636ab2254000c3c69d8859e5d02 (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
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
copyrights:
- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
enabled-by: true
functional-type: action
links:
- role: requirement-refinement
  uid: ../if/group
post-conditions:
- name: Status
  states:
  - name: Ok
    test-code: |
      T_eq_int(
        ctx->tq_ctx->status[ TQ_BLOCKER_A ],
        TQConvertStatus( ctx->tq_ctx, STATUS_SUCCESSFUL )
      );
    text: |
      The return status of the directive call shall be derived from
      ${../../status/if/successful:/name}.
  - name: Timeout
    test-code: |
      T_eq_int(
        ctx->tq_ctx->status[ TQ_BLOCKER_A ],
        TQConvertStatus( ctx->tq_ctx, STATUS_TIMEOUT )
      );
    text: |
      The return status of the directive call shall be derived from
      ${../../status/if/timeout:/name}.
  test-epilogue: null
  test-prologue: null
- name: Unblock
  states:
  - name: 'No'
    test-code: |
      T_eq_ptr( GetUnblock( ctx, &i ), NULL );
    text: |
      The thread of the timeout operation shall not be unblocked by the timeout
      operation.
  test-epilogue: null
  test-prologue: |
    size_t i;

    i = 0;
pre-conditions:
- name: Scheduler
  states:
  - name: Same
    test-code: |
      ctx->other_scheduler = false;

      TQSetScheduler(
        ctx->tq_ctx,
        TQ_BLOCKER_A,
        SCHEDULER_A_ID,
        PRIO_LOW
      );
      RemoveProcessor( SCHEDULER_B_ID, 1 );
      AddProcessor( SCHEDULER_A_ID, 1 );
      ctx->restore_scheduler = true;
    text: |
      While the ${/glossary/scheduler-home:/term} of the thread is equal to the
      ${/glossary/scheduler-home:/term} of the thread queue owner.
  - name: Other
    test-code: |
      ctx->other_scheduler = true;

      TQSetScheduler(
        ctx->tq_ctx,
        TQ_BLOCKER_A,
        SCHEDULER_B_ID,
        PRIO_NORMAL
      );
    text: |
      While the ${/glossary/scheduler-home:/term} of the thread is not equal to
      the ${/glossary/scheduler-home:/term} of the thread queue owner.
  test-epilogue: null
  test-prologue: null
- name: WaitState
  states:
  - name: IntendToBlock
    test-code: |
      Per_CPU_Control *cpu;

      TQEnqueuePrepare( ctx->tq_ctx );
      TQSendAndWaitForIntendToBlock(
        ctx->tq_ctx,
        TQ_BLOCKER_A,
        TQ_EVENT_ENQUEUE
      );
      cpu = _Thread_Get_CPU( ctx->tq_ctx->worker_tcb[ TQ_BLOCKER_A ] );

      /*
       * We have to make sure that the worker thread inserted its thread
       * timer.  Checking the intend to block wait state is not enough to
       * ensure this.
       */
      while ( cpu->thread_dispatch_disable_level != 0 ) {
        /* Wait */
      }

      Tick( ctx );
      WaitForExecutionStop( ctx->tq_ctx->worker_id[ TQ_BLOCKER_A ] );
      TQEnqueueDone( ctx->tq_ctx );
    text: |
      While the thread of the timeout operation is in the intend to block wait
      state.
  - name: ReadyAgain
    test-code: |
      TQEnqueuePrepare( ctx->tq_ctx );
      TQSendAndWaitForIntendToBlock(
        ctx->tq_ctx,
        TQ_BLOCKER_A,
        TQ_EVENT_ENQUEUE | TQ_EVENT_TIMEOUT | TQ_EVENT_SURRENDER |
          TQ_EVENT_SCHEDULER_RECORD_STOP
      );
      TQSchedulerRecordStart( ctx->tq_ctx );
      TQEnqueueDone( ctx->tq_ctx );
      WaitForExecutionStop( ctx->tq_ctx->worker_id[ TQ_BLOCKER_A ] );
    text: |
      While the thread of the timeout operation is in the ready again wait
      state.
  test-epilogue: null
  test-prologue: null
rationale: null
references: []
requirement-type: functional
skip-reasons: {}
test-action: |
  /*
   * The action is performed by the ``WaitState`` pre-condition preparation.
   */
test-brief: null
test-cleanup: |
  if ( ctx->restore_scheduler ) {
    RemoveProcessor( SCHEDULER_A_ID, 1 );
    AddProcessor( SCHEDULER_B_ID, 1 );
  }
test-context:
- brief: |
    If this member is true, then the enqueued thread shall use a home scheduler
    other than the home scheduler of the owner.
  description: null
  member: |
    bool other_scheduler
- brief: |
    If this member is true, then the processor set of the schedulers shall be
    restored.
  description: null
  member: |
    bool restore_scheduler
test-context-support: null
test-description: null
test-header:
  code: null
  freestanding: false
  includes: []
  local-includes:
  - tx-thread-queue.h
  run-params:
  - description: |
      is the thread queue test context.
    dir: inout
    name: tq_ctx
    specifier: TQContext *${.:name}
  target: testsuites/validation/tr-tq-timeout-mrsp.h
test-includes:
- rtems/score/smpimpl.h
- rtems/score/threadimpl.h
test-local-includes:
- tx-support.h
- tr-tq-timeout-mrsp.h
test-prepare: |
  ctx->restore_scheduler = false;
test-setup:
  brief: null
  code: |
    TQReset( ctx->tq_ctx );
  description: null
test-stop: null
test-support: |
  typedef ${.:/test-context-type} Context;

  static const rtems_tcb *GetUnblock( Context *ctx, size_t *index )
  {
    return TQGetNextUnblock( ctx->tq_ctx, index )->thread;
  }

  static void Tick( void *arg )
  {
    Context *ctx;

    ctx = arg;
    TQSchedulerRecordStart( ctx->tq_ctx );
    FinalClockTick();
    TQSchedulerRecordStop( ctx->tq_ctx );
  }
test-target: testsuites/validation/tr-tq-timeout-mrsp.c
test-teardown:
  brief: null
  code: |
    TQReset( ctx->tq_ctx );
  description: null
text: |
  When the thread queue enqueue operation timed out.
transition-map:
- enabled-by: true
  post-conditions:
    Status: Timeout
    Unblock: 'No'
  pre-conditions:
    Scheduler: all
    WaitState:
    - IntendToBlock
- enabled-by: true
  post-conditions:
    Status: Ok
    Unblock: 'No'
  pre-conditions:
    Scheduler: all
    WaitState:
    - ReadyAgain
type: requirement