[rtems-central commit] spec: Specifiy timer fire order

Sebastian Huber sebh at rtems.org
Mon Sep 6 14:20:29 UTC 2021


Module:    rtems-central
Branch:    master
Commit:    44cf7af5860962a5e2962e4dbda6a62b969d2b73
Changeset: http://git.rtems.org/rtems-central/commit/?id=44cf7af5860962a5e2962e4dbda6a62b969d2b73

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Sep  6 15:38:28 2021 +0200

spec: Specifiy timer fire order

---

 spec/rtems/timer/req/fire-order.yml |  16 ++++++
 spec/rtems/timer/val/timer.yml      | 104 ++++++++++++++++++++++++++++++++++++
 2 files changed, 120 insertions(+)

diff --git a/spec/rtems/timer/req/fire-order.yml b/spec/rtems/timer/req/fire-order.yml
new file mode 100644
index 0000000..b96fe18
--- /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 0000000..6dad995
--- /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



More information about the vc mailing list