[rtems-central commit] spec: Improve timer order test

Sebastian Huber sebh at rtems.org
Wed Sep 8 11:49:44 UTC 2021


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Sep  7 08:24:54 2021 +0200

spec: Improve timer order test

---

 spec/rtems/timer/val/timer.yml | 38 +++++++++++++++++++++++++++-----------
 1 file changed, 27 insertions(+), 11 deletions(-)

diff --git a/spec/rtems/timer/val/timer.yml b/spec/rtems/timer/val/timer.yml
index 6dad995..015c771 100644
--- a/spec/rtems/timer/val/timer.yml
+++ b/spec/rtems/timer/val/timer.yml
@@ -10,6 +10,8 @@ test-actions:
     rtems_status_code sc;
     size_t            i;
 
+    T_assert_eq_sz( TEST_MAXIMUM_TIMERS, 10 );
+
     _Atomic_Init_uint( &ctx->counter, 0 );
 
     for ( i = 0; i < TEST_MAXIMUM_TIMERS ; ++i ) {
@@ -21,18 +23,18 @@ test-actions:
     }
   checks:
   - brief: |
-      Schedule the timers at the same time point.
+      Schedule some 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 );
-      }
+      Fire( ctx, 3, 2 );
+      Fire( ctx, 0, 1 );
+      Fire( ctx, 7, 3 );
+      Fire( ctx, 4, 2 );
+      Fire( ctx, 5, 2 );
+      Fire( ctx, 8, 3 );
+      Fire( ctx, 9, 3 );
+      Fire( ctx, 1, 1 );
+      Fire( ctx, 2, 1 );
+      Fire( ctx, 6, 2 );
     links: []
   - brief: |
       Fire the timers and check that they fired in the expected order.
@@ -99,6 +101,20 @@ test-support: |
       ATOMIC_ORDER_RELAXED
     ) + 1;
   }
+
+  static void Fire( Context *ctx, size_t i, rtems_interval ticks )
+  {
+    rtems_status_code sc;
+
+    ctx->counter_snapshots[ i ] = 0;
+    sc = rtems_timer_fire_after(
+      ctx->timer_ids[ i ],
+      ticks,
+      Timer,
+      &ctx->counter_snapshots[ i ]
+    );
+    T_rsc_success( sc );
+  }
 test-target: testsuites/validation/tc-timer.c
 test-teardown: null
 type: test-case



More information about the vc mailing list