diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-09-06 15:38:28 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-09-06 15:38:28 +0200 |
commit | 44cf7af5860962a5e2962e4dbda6a62b969d2b73 (patch) | |
tree | 9f60dfcc4dc70977ceab696b0a030f6fe5116bed | |
parent | modules: Update rtems (diff) | |
download | rtems-central-44cf7af5860962a5e2962e4dbda6a62b969d2b73.tar.bz2 |
spec: Specifiy timer fire order
-rw-r--r-- | spec/rtems/timer/req/fire-order.yml | 16 | ||||
-rw-r--r-- | spec/rtems/timer/val/timer.yml | 104 |
2 files changed, 120 insertions, 0 deletions
diff --git a/spec/rtems/timer/req/fire-order.yml b/spec/rtems/timer/req/fire-order.yml new file mode 100644 index 00000000..b96fe184 --- /dev/null +++ b/spec/rtems/timer/req/fire-order.yml @@ -0,0 +1,16 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 +copyrights: +- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +links: +- role: requirement-refinement + uid: ../if/group +functional-type: function +rationale: null +references: [] +requirement-type: functional +text: | + The timer ${../glossary/scheduled:/term} at the same processor with the same + expiration time point shall ${../glossary/fire:/term} in + ${/glossary/fifo:/term} order. +type: requirement diff --git a/spec/rtems/timer/val/timer.yml b/spec/rtems/timer/val/timer.yml new file mode 100644 index 00000000..6dad9953 --- /dev/null +++ b/spec/rtems/timer/val/timer.yml @@ -0,0 +1,104 @@ +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 +links: [] +test-actions: +- action-brief: | + Create a couple of timers. + action-code: | + rtems_status_code sc; + size_t i; + + _Atomic_Init_uint( &ctx->counter, 0 ); + + for ( i = 0; i < TEST_MAXIMUM_TIMERS ; ++i ) { + sc = rtems_timer_create( + rtems_build_name( 'T', 'E', 'S', 'T' ), + &ctx->timer_ids[ i ] + ); + T_rsc_success( sc ); + } + checks: + - brief: | + Schedule the timers at the same time point. + code: | + for ( i = 0; i < TEST_MAXIMUM_TIMERS ; ++i ) { + ctx->counter_snapshots[ i ] = 0; + sc = rtems_timer_fire_after( + ctx->timer_ids[ i ], + 1, + Timer, + &ctx->counter_snapshots[ i ] + ); + T_rsc_success( sc ); + } + links: [] + - brief: | + Fire the timers and check that they fired in the expected order. + code: | + FinalClockTick(); + + for ( i = 0; i < TEST_MAXIMUM_TIMERS ; ++i ) { + T_eq_sz( ctx->counter_snapshots[ i ], i + 1 ); + } + links: + - role: validation + uid: ../req/fire-order + - brief: | + Clean up all used resources. + code: | + for ( i = 0; i < TEST_MAXIMUM_TIMERS ; ++i ) { + sc = rtems_timer_delete( ctx->timer_ids[ i ] ); + T_rsc_success( sc ); + } + links: [] + links: [] +test-brief: | + Tests general timer behaviour. +test-context: +- brief: | + This member contains the timer identifiers. + description: null + member: | + rtems_id timer_ids[ TEST_MAXIMUM_TIMERS ] +- brief: | + This member contains the counter. + description: null + member: | + Atomic_Uint counter +- brief: | + This member contains the timer counter snapshots. + description: null + member: | + unsigned int counter_snapshots[ TEST_MAXIMUM_TIMERS ] +test-context-support: null +test-description: null +test-header: null +test-includes: +- rtems.h +- rtems/score/atomic.h +test-local-includes: +- ts-config.h +- tx-support.h +test-setup: null +test-stop: null +test-support: | + typedef ${.:/test-context-type} Context; + + static void Timer( rtems_id timer, void *arg ) + { + Context *ctx; + unsigned int *counter; + + ctx = T_fixture_context(); + counter = arg; + *counter = _Atomic_Fetch_add_uint( + &ctx->counter, + 1, + ATOMIC_ORDER_RELAXED + ) + 1; + } +test-target: testsuites/validation/tc-timer.c +test-teardown: null +type: test-case |