source: rtems-central/spec/rtems/timer/req/reset.yml

Last change on this file was 6ea50c8, checked in by Sebastian Huber <sebastian.huber@…>, on 07/21/23 at 07:09:37

spec: Remove superfluous ';'

  • Property mode set to 100644
File size: 19.7 KB
Line 
1SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
2copyrights:
3- Copyright (C) 2021 embedded brains GmbH & Co. KG
4enabled-by: true
5functional-type: action
6links:
7- role: interface-function
8  uid: ../if/reset
9post-conditions:
10- name: Status
11  states:
12  - name: Ok
13    test-code: |
14      T_rsc_success( ctx->status );
15    text: |
16      The return status of ${../if/reset:/name} shall be
17      ${../../status/if/successful:/name}.
18  - name: InvId
19    test-code: |
20      T_rsc( ctx->status, RTEMS_INVALID_ID );
21    text: |
22      The return status of ${../if/reset:/name} shall be
23      ${../../status/if/invalid-id:/name}.
24  - name: NotDef
25    test-code: |
26      T_rsc( ctx->status, RTEMS_NOT_DEFINED );
27    text: |
28      The return status of ${../if/reset:/name} shall be
29      ${../../status/if/not-defined:/name}
30  test-epilogue: null
31  test-prologue: null
32- name: Context
33  states:
34  - name: None
35    test-code: |
36      T_eq_int( class, TIMER_DORMANT );
37    text: |
38      The timer shall have never been ${../glossary/scheduled:/term}.
39      See also ${../glossary/none:/term}.
40  - name: Interrupt
41    test-code: |
42      T_eq_int( class & TIMER_CLASS_BIT_ON_TASK, 0 );
43    text: |
44      The timer shall be in ${../glossary/interruptcontext:/term}.
45  - name: Server
46    test-code: |
47      T_eq_int( class & TIMER_CLASS_BIT_ON_TASK, TIMER_CLASS_BIT_ON_TASK );
48    text: |
49      The timer shall be in ${../glossary/servercontext:/term}.
50  - name: Nop
51    test-code: |
52      T_eq_int( class, ctx->pre_class );
53    text: |
54      Objects referenced by the ${../if/reset:/params[0]/name}
55      parameter in past call to ${../if/reset:/name} shall not be
56      accessed by the ${../if/reset:/name} call.
57      See also ${../glossary/nop:/term}.
58  test-epilogue: null
59  test-prologue: |
60    Timer_Classes class;
61    class = GetTimerClass( ctx->timer_id );
62- name: Clock
63  states:
64  - name: None
65    test-code: |
66      T_eq_int( class, TIMER_DORMANT );
67    text: |
68      The timer shall have never been ${../glossary/scheduled:/term}.
69  - name: Ticks
70    test-code: |
71      T_eq_int( class & TIMER_CLASS_BIT_TIME_OF_DAY, 0 );
72    text: |
73      The timer shall use the ${../glossary/ticksbasedclock:/term}.
74  - name: Realtime
75    test-code: |
76      T_eq_int(
77        class & TIMER_CLASS_BIT_TIME_OF_DAY,
78        TIMER_CLASS_BIT_TIME_OF_DAY
79      );
80    text: |
81      The timer shall use the ${../glossary/realtimeclock:/term}.
82  - name: Nop
83    test-code: |
84      T_eq_int( class, ctx->pre_class );
85    text: |
86      Objects referenced by the ${../if/reset:/params[0]/name}
87      parameter in past call to ${../if/reset:/name} shall not be
88      accessed by the ${../if/reset:/name} call.
89  test-epilogue: null
90  test-prologue: |
91    Timer_Classes class;
92    class = GetTimerClass( ctx->timer_id );
93- name: State
94  states:
95  - name: Scheduled
96    test-code: |
97      ctx->ticks_till_fire = TriggerTimer( ctx );
98      T_eq_int( ctx->invocations_a + ctx->invocations_b, 1 );
99    text: |
100      The timer shall be in ${../glossary/scheduled:/term}
101      ${../glossary/state:/term}.
102  - name: Nop
103    test-code: |
104      T_eq_int( ctx->post_state, ctx->pre_state );
105    text: |
106      Objects referenced by the ${../if/reset:/params[0]/name}
107      parameter in past call to ${../if/reset:/name} shall not be
108      accessed by the ${../if/reset:/name} call.
109  test-epilogue: null
110  test-prologue: null
111- name: Interval
112  states:
113  - name: Last
114    test-code: |
115      T_eq_int( ctx->ticks_till_fire, ctx->scheduled_ticks_till_fire );
116    text: |
117      The ${../glossary/timerserviceroutine:/term} shall be invoked the same
118      number of ticks (see ${/glossary/tick:/term}), as defined by
119      the last ${../glossary/scheduled:/term} interval, after a point in time
120      during the execution of the ${../if/reset:/name} call.
121  - name: Nop
122    test-code: |
123      /*
124       * Whether the timer is scheduled has already been tested by the
125       * "Nop" "State" post-condition above.
126       */
127      T_eq_u32(
128        ctx->post_scheduling_data.interval,
129        ctx->pre_scheduling_data.interval
130      );
131    text: |
132      If and when the ${../glossary/timerserviceroutine:/term} will be invoked
133      shall not be changed by the past call to ${../if/reset:/name}.
134  test-epilogue: null
135  test-prologue: null
136- name: Routine
137  states:
138  - name: Last
139    test-code: |
140      T_eq_int( ctx->invocations_a, ctx->scheduled_invocations_a );
141      T_eq_int( ctx->invocations_b, ctx->scheduled_invocations_b );
142    text: |
143      The function reference used to invoke the
144      ${../glossary/timerserviceroutine:/term} when the timer will
145      ${../glossary/fire:/term} shall be the same one as the last one
146      ${../glossary/scheduled:/term}.
147  - name: Nop
148    test-code: |
149      T_eq_ptr(
150        ctx->post_scheduling_data.routine,
151        ctx->pre_scheduling_data.routine
152      );
153    text: |
154      The function reference used for any invocation of the
155      ${../glossary/timerserviceroutine:/term} shall not be changed
156      by the past call to ${../if/reset:/name}.
157  test-epilogue: null
158  test-prologue: null
159- name: UserData
160  states:
161  - name: Last
162    test-code: |
163      T_eq_ptr( ctx->routine_user_data, ctx->scheduled_user_data);
164    text: |
165      The user data argument for invoking the
166      ${../glossary/timerserviceroutine:/term} when the timer will
167      ${../glossary/fire:/term} shall be the same as the last
168      ${../glossary/scheduled:/term} user data argument.
169  - name: Nop
170    test-code: |
171      T_eq_ptr(
172        ctx->post_scheduling_data.user_data,
173        ctx->pre_scheduling_data.user_data
174      );
175    text: |
176      The user data argument used for any invocation of the
177      ${../glossary/timerserviceroutine:/term} shall not be changed
178      by the past call to ${../if/reset:/name}.
179  test-epilogue: null
180  test-prologue: null
181pre-conditions:
182- name: Id
183  states:
184  - name: Valid
185    test-code: |
186      ctx->id_param = ctx->timer_id;
187    text: |
188      While the ${../if/reset:/params[0]/name} parameter is valid.
189  - name: Invalid
190    test-code: |
191      ctx->id_param = RTEMS_ID_NONE;
192    text: |
193      While the ${../if/reset:/params[0]/name} parameter is invalid.
194  test-epilogue: null
195  test-prologue: null
196- name: Context
197  states:
198  - name: None
199    test-code: |
200      ctx->pre_cond_contex = PRE_NONE;
201    text: |
202      While the ${../glossary/timerserviceroutine:/term} has never been
203      ${../glossary/scheduled:/term} since creation of the timer.
204      See also ${../glossary/none:/term}.
205  - name: Interrupt
206    test-code: |
207      ctx->pre_cond_contex = PRE_INTERRUPT;
208    text: |
209      While the timer is in ${../glossary/interruptcontext:/term}.
210  - name: Server
211    test-code: |
212      ctx->pre_cond_contex = PRE_SERVER;
213    text: |
214      While the timer is in ${../glossary/servercontext:/term}.
215  test-epilogue: null
216  test-prologue: null
217- name: Clock
218  states:
219  - name: None
220    test-code: |
221      T_eq_int( ctx->pre_cond_contex, PRE_NONE );
222    text: |
223      While the timer has never been ${../glossary/scheduled:/term}
224      since creation of the timer.
225  - name: Ticks
226    test-code: |
227      rtems_status_code status;
228
229      if ( ctx->pre_cond_contex == PRE_INTERRUPT ) {
230        ctx->scheduled_ticks_till_fire = SCHEDULE_SOON;
231        ctx->scheduled_invocations_a = 1;
232        ctx->scheduled_user_data = &ctx->data_a;
233        status = rtems_timer_fire_after(
234          ctx->timer_id,
235          ctx->scheduled_ticks_till_fire,
236          TimerServiceRoutineA,
237          ctx->scheduled_user_data
238        );
239      } else {
240        ctx->scheduled_ticks_till_fire = SCHEDULE_LATER;
241        ctx->scheduled_invocations_b = 1;
242        ctx->scheduled_user_data = &ctx->data_b;
243         status = rtems_timer_server_fire_after(
244          ctx->timer_id,
245          ctx->scheduled_ticks_till_fire,
246          TimerServiceRoutineB,
247          ctx->scheduled_user_data
248        );
249      }
250      T_rsc_success( status );
251    text: |
252      While the ${../glossary/clock:/term} used to determine when the timer
253      will ${../glossary/fire:/term} is the
254      ${../glossary/ticksbasedclock:/term}.
255  - name: Realtime
256    test-code: |
257      rtems_status_code status;
258
259      if ( ctx->pre_cond_contex == PRE_INTERRUPT ) {
260        status = rtems_timer_fire_when(
261          ctx->timer_id,
262          &tod_schedule,
263          TimerServiceRoutineA,
264          &ctx->data_a
265        );
266      } else {
267        status = rtems_timer_server_fire_when(
268          ctx->timer_id,
269          &tod_schedule,
270          TimerServiceRoutineB,
271          &ctx->data_b
272        );
273      }
274      T_rsc_success( status );
275    text: |
276      While the ${../glossary/clock:/term} used to determine when the timer
277      will ${../glossary/fire:/term} is the ${../glossary/realtimeclock:/term}.
278  test-epilogue: null
279  test-prologue: null
280- name: State
281  states:
282  - name: Inactive
283    test-code: |
284      TriggerTimer( ctx );
285      T_eq_int(
286        ctx->invocations_a + ctx->invocations_b,
287        ( ctx->pre_cond_contex == PRE_NONE ) ? 0 : 1
288      );
289      ctx->invocations_a = 0;
290      ctx->invocations_b = 0;
291      ctx->pre_state = TIMER_INACTIVE;
292    text: |
293      While the timer is in ${../glossary/inactive:/term}
294      ${../glossary/state:/term}.
295  - name: Scheduled
296    test-code: |
297      /* The timer was already scheduled in the "Clock" pre-conditions. */
298      ctx->pre_state = TIMER_SCHEDULED;
299    text: |
300      While the timer is in ${../glossary/scheduled:/term}
301      ${../glossary/state:/term}.
302  - name: Pending
303    test-code: |
304      T_rsc_success( rtems_task_suspend( GetTimerServerTaskId() ) );
305      TriggerTimer( ctx );
306      T_eq_int( ctx->invocations_a + ctx->invocations_b, 0 );
307      ctx->pre_state = TIMER_PENDING;
308    text: |
309      While the timer is in ${../glossary/pending:/term}
310      ${../glossary/state:/term}.
311  test-epilogue: null
312  test-prologue: null
313rationale: null
314references: []
315requirement-type: functional
316skip-reasons:
317  NotExist: |
318    The pre-condition combination of ${../glossary/context:/term},
319    ${../glossary/clock:/term} and ${../glossary/state:/term} cannot be
320    produced and does therefore not exist.
321test-action: |
322  GetTimerSchedulingData( ctx->timer_id, &ctx->pre_scheduling_data );
323  ctx->pre_class = GetTimerClass( ctx->timer_id );
324  ctx->status = rtems_timer_reset( ctx->id_param );
325  ctx->post_state = GetTimerState( ctx->timer_id );
326  GetTimerSchedulingData( ctx->timer_id, &ctx->post_scheduling_data );
327  /* Ignoring return status: the timer server task may be suspended or not. */
328  rtems_task_resume( GetTimerServerTaskId() );
329test-brief: null
330test-cleanup: |
331  T_rsc_success( rtems_timer_delete( ctx->timer_id ) );
332test-context:
333- brief: |
334    This member contains a valid id of a timer.
335  description: null
336  member: |
337    rtems_id timer_id
338- brief: |
339    This member specifies the ${../if/reset:/params[0]/name} parameter for the
340    action.
341  description: null
342  member: |
343    rtems_id id_param
344- brief: |
345    This member contains the returned ${/glossary/statuscode:/term} of the action.
346  description: null
347  member: |
348    rtems_status_code status
349- brief: |
350    This member contains the user data for
351    ${../glossary/timerserviceroutine:/term} "A".
352  description: null
353  member: |
354    void *data_a
355- brief: |
356    This member contains the user data for
357    ${../glossary/timerserviceroutine:/term} "B".
358  description: null
359  member: |
360    void *data_b
361- brief: |
362    This member contains the counter for invocations of
363    ${../glossary/timerserviceroutine:/term} "A".
364  description: null
365  member: |
366    int invocations_a
367- brief: |
368    This member contains the counter for invocations of
369    ${../glossary/timerserviceroutine:/term} "B".
370  description: null
371  member: |
372    int invocations_b
373- brief: |
374    This member contains the number of ticks needed to
375    ${../glossary/fire:/term} the ${../glossary/timerserviceroutine:/term}.
376  description: null
377  member: |
378    Scheduling_Ticks ticks_till_fire
379- brief: |
380    This member identifier the user data given to the
381    ${../glossary/timerserviceroutine:/term} when called. It either the
382    address of member data_a or data_b.
383  description: null
384  member: |
385    void **routine_user_data
386- brief: |
387    This member contains a reference to the user data to be used
388    in the next call to the ${../glossary/timerserviceroutine:/term}.
389  description: null
390  member: |
391    void **scheduled_user_data
392- brief: |
393    This member contains 1 if the ${../glossary/timerserviceroutine:/term}
394    "A" has been ${../glossary/scheduled:/term} otherwise 0.
395  description: null
396  member: |
397    int scheduled_invocations_a
398- brief: |
399    This member contains 1 if the ${../glossary/timerserviceroutine:/term}
400    "B" has been ${../glossary/scheduled:/term} otherwise 0.
401  description: null
402  member: |
403    int scheduled_invocations_b
404- brief: |
405    This member specifies the number of ticks till the
406    ${../glossary/scheduled:/term} ${../glossary/timerserviceroutine:/term}
407    should ${../glossary/fire:/term}.
408  description: null
409  member: |
410    Scheduling_Ticks scheduled_ticks_till_fire
411- brief: |
412    This member specifies which pre-condition ${../glossary/context:/term}
413    (${../glossary/none:/term}, ${../glossary/interruptcontext:/term},
414    ${../glossary/servercontext:/term}) must be created before the
415    ${../if/reset:/name} action gets executed.
416  description: null
417  member: |
418    PreConditionContext pre_cond_contex
419- brief: |
420    This member stores internal ${../glossary/clock:/term} and
421    ${../glossary/context:/term} settings of the timer before
422    the execution of the test action.
423  description: null
424  member: |
425    Timer_Classes pre_class
426- brief: |
427    This member stores the ${../glossary/state:/term} of the timer before
428    the execution of the test action.
429  description: null
430  member: |
431    Timer_States pre_state
432- brief: |
433    This member stores the ${../glossary/state:/term} of the timer after
434    the execution of the test action.
435  description: null
436  member: |
437    Timer_States post_state
438- brief: |
439    This member stores the scheduling data of the timer before
440    the execution of the test action.
441  description: null
442  member: |
443    Timer_Scheduling_Data pre_scheduling_data
444- brief: |
445    This member stores the scheduling data of the timer after
446    the execution of the test action.
447  description: null
448  member: |
449    Timer_Scheduling_Data post_scheduling_data
450test-context-support: |
451  typedef enum {
452    PRE_NONE      = 0,
453    PRE_INTERRUPT = 1,
454    PRE_SERVER    = 2
455  } PreConditionContext;
456
457  typedef enum {
458    SCHEDULE_NONE  = 0,
459    SCHEDULE_SOON  = 1,
460    SCHEDULE_LATER = 2,
461    SCHEDULE_MAX   = 5
462  } Scheduling_Ticks;
463test-description: null
464test-header: null
465test-includes:
466- rtems.h
467test-local-includes:
468- tx-support.h
469test-prepare: |
470  rtems_status_code status;
471  status = rtems_timer_create(
472    rtems_build_name( 'T', 'I', 'M', 'E' ),
473    &ctx->timer_id
474  );
475  T_rsc_success( status );
476
477  ctx->data_a                    = ctx;
478  ctx->data_b                    = ctx;
479  ctx->invocations_a             = 0;
480  ctx->invocations_b             = 0;
481  ctx->ticks_till_fire           = SCHEDULE_NONE;
482  ctx->routine_user_data         = NULL;
483  ctx->scheduled_invocations_a   = 0;
484  ctx->scheduled_invocations_b   = 0;
485  ctx->scheduled_ticks_till_fire = SCHEDULE_NONE;
486  T_rsc_success( rtems_clock_set( &tod_now ) );
487test-setup:
488  brief: null
489  code: |
490    rtems_status_code status;
491    status = rtems_timer_initiate_server(
492      RTEMS_TIMER_SERVER_DEFAULT_PRIORITY,
493      RTEMS_MINIMUM_STACK_SIZE,
494      RTEMS_DEFAULT_ATTRIBUTES
495    );
496    T_rsc_success( status );
497  description: null
498test-stop: null
499test-support: |
500  static const rtems_time_of_day tod_now      = { 2000, 1, 1, 0, 0, 0, 0 };
501  static const rtems_time_of_day tod_schedule = { 2000, 1, 1, 1, 0, 0, 0 };
502  static const rtems_time_of_day tod_fire     = { 2000, 1, 2, 0, 0, 0, 0 };
503
504  static Scheduling_Ticks TriggerTimer( const RtemsTimerReqReset_Context *ctx )
505  {
506    int ticks_fired = SCHEDULE_NONE;
507    int invocations_old = ctx->invocations_a + ctx->invocations_b;
508
509    /* Fire the timer service routine for ticks and realtime clock */
510    int i;
511    for ( i = 1; i <= SCHEDULE_MAX; ++i ) {
512      ClockTick();
513      if ( ctx->invocations_a + ctx->invocations_b > invocations_old ) {
514        ticks_fired = i;
515        break;
516      }
517    }
518
519    T_rsc_success( rtems_clock_set( &tod_fire ) );
520
521    return ticks_fired;
522  }
523
524  static void TimerServiceRoutineA(
525    rtems_id timer_id,
526    void *user_data
527  )
528  {
529    RtemsTimerReqReset_Context *ctx =
530      *(RtemsTimerReqReset_Context **) user_data;
531    ++( ctx->invocations_a );
532    ctx->routine_user_data = user_data;
533  }
534
535  static void TimerServiceRoutineB(
536    rtems_id timer_id,
537    void *user_data
538  )
539  {
540    RtemsTimerReqReset_Context *ctx =
541      *(RtemsTimerReqReset_Context **) user_data;
542    ++( ctx->invocations_b );
543    ctx->routine_user_data = user_data;
544  }
545test-target: testsuites/validation/tc-timer-reset.c
546test-teardown:
547  brief: Make sure the timer server is not running and the realtime clock
548    is not set after this test.
549  code: |
550    DeleteTimerServer();
551    UnsetClock();
552  description: null
553text: ${.:text-template}
554transition-map:
555- enabled-by: true
556  post-conditions:
557    Status: NotDef
558    Context: Nop
559    Clock: Nop
560    State: Nop
561    Interval: Nop
562    Routine: Nop
563    UserData: Nop
564  pre-conditions:
565    Id:
566    - Valid
567    Context:
568    - None
569    Clock:
570    - None
571    State:
572    - Inactive
573- enabled-by: true
574  post-conditions:
575    Status: Ok
576    Context: Server
577    Clock: Ticks
578    State: Scheduled
579    Interval: Last
580    Routine: Last
581    UserData: Last
582  pre-conditions:
583    Id:
584    - Valid
585    Context:
586    - Server
587    Clock:
588    - Ticks
589    State: all
590- enabled-by: true
591  post-conditions:
592    Status: NotDef
593    Context: Nop
594    Clock: Nop
595    State: Nop
596    Interval: Nop
597    Routine: Nop
598    UserData: Nop
599  pre-conditions:
600    Id:
601    - Valid
602    Context:
603    - Server
604    Clock:
605    - Realtime
606    State: all
607- enabled-by: true
608  post-conditions:
609    Status: Ok
610    Context: Interrupt
611    Clock: Ticks
612    State: Scheduled
613    Interval: Last
614    Routine: Last
615    UserData: Last
616  pre-conditions:
617    Id:
618    - Valid
619    Context:
620    - Interrupt
621    Clock:
622    - Ticks
623    State:
624    - Inactive
625    - Scheduled
626- enabled-by: true
627  post-conditions:
628    Status: NotDef
629    Context: Nop
630    Clock: Nop
631    State: Nop
632    Interval: Nop
633    Routine: Nop
634    UserData: Nop
635  pre-conditions:
636    Id:
637    - Valid
638    Context:
639    - Interrupt
640    Clock:
641    - Realtime
642    State:
643    - Inactive
644    - Scheduled
645- enabled-by: true
646  post-conditions: NotExist
647  pre-conditions:
648    Id: all
649    Context:
650    - None
651    Clock:
652    - None
653    State:
654    - Scheduled
655    - Pending
656- enabled-by: true
657  post-conditions: NotExist
658  pre-conditions:
659    Id: all
660    Context:
661    - None
662    Clock:
663    - Ticks
664    - Realtime
665    State: all
666- enabled-by: true
667  post-conditions: NotExist
668  pre-conditions:
669    Id: all
670    Context:
671    - Interrupt
672    - Server
673    Clock:
674    - None
675    State: all
676- enabled-by: true
677  post-conditions: NotExist
678  pre-conditions:
679    Id: all
680    Context:
681    - Interrupt
682    Clock:
683    - Ticks
684    - Realtime
685    State:
686    - Pending
687- enabled-by: true
688  post-conditions:
689    Status: InvId
690    Context: Nop
691    Clock: Nop
692    State: Nop
693    Interval: Nop
694    Routine: Nop
695    UserData: Nop
696  pre-conditions:
697    Id:
698    - Invalid
699    Context:
700    - None
701    Clock:
702    - None
703    State:
704    - Inactive
705- enabled-by: true
706  post-conditions:
707    Status: InvId
708    Context: Nop
709    Clock: Nop
710    State: Nop
711    Interval: Nop
712    Routine: Nop
713    UserData: Nop
714  pre-conditions:
715    Id:
716    - Invalid
717    Context:
718    - Server
719    Clock:
720    - Ticks
721    - Realtime
722    State: all
723- enabled-by: true
724  post-conditions:
725    Status: InvId
726    Context: Nop
727    Clock: Nop
728    State: Nop
729    Interval: Nop
730    Routine: Nop
731    UserData: Nop
732  pre-conditions:
733    Id:
734    - Invalid
735    Context:
736    - Interrupt
737    Clock:
738    - Ticks
739    - Realtime
740    State:
741    - Inactive
742    - Scheduled
743type: requirement
Note: See TracBrowser for help on using the repository browser.