[rtems commit] sptests/spcpucounter01: Adjust test

Sebastian Huber sebh at rtems.org
Mon Feb 24 11:44:10 UTC 2014


Module:    rtems
Branch:    master
Commit:    07dc9709a42b41e542ce955f0c4fc02967f901e5
Changeset: http://git.rtems.org/rtems/commit/?id=07dc9709a42b41e542ce955f0c4fc02967f901e5

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Feb 24 09:53:16 2014 +0100

sptests/spcpucounter01: Adjust test

Adjust test to work with clock driver based CPU counters.  They have a
period equal to the clock tick interval.

---

 testsuites/sptests/spcpucounter01/init.c           |   14 ++++++++++-
 .../sptests/spcpucounter01/spcpucounter01.scn      |   24 ++++++++++++++-----
 2 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/testsuites/sptests/spcpucounter01/init.c b/testsuites/sptests/spcpucounter01/init.c
index 1ed8a58..c9f856d 100644
--- a/testsuites/sptests/spcpucounter01/init.c
+++ b/testsuites/sptests/spcpucounter01/init.c
@@ -56,7 +56,7 @@ static void test_delay_nanoseconds(void)
   rtems_counter_ticks end;
   rtems_counter_ticks delta;
   double ns_per_tick = NS_PER_TICK;
-  double ns_delta;
+  uint64_t ns_delta;
   rtems_interval tick;
   int n = 10;
   int i;
@@ -75,10 +75,20 @@ static void test_delay_nanoseconds(void)
     delta = rtems_counter_difference(end, start);
     ns_delta = rtems_counter_ticks_to_nanoseconds(delta);
 
-    rtems_test_assert(ns_delta >= ns_per_tick);
+    /* Special case for CPU counters using the clock driver counter */
+    if (ns_delta < rtems_configuration_get_nanoseconds_per_tick()) {
+      printf(
+        "warning: the RTEMS counter seems to be unable to\n"
+        "  measure intervals greater than the clock tick interval\n"
+      );
+
+      ns_delta += rtems_configuration_get_nanoseconds_per_tick();
+    }
 
     printf(
+      "busy wait duration: %" PRIu64 "ns\n"
       "busy wait relative to clock tick: %f\n",
+      ns_delta,
       (ns_delta - ns_per_tick) / ns_per_tick
     );
   }
diff --git a/testsuites/sptests/spcpucounter01/spcpucounter01.scn b/testsuites/sptests/spcpucounter01/spcpucounter01.scn
index fc8e849..62f86d7 100644
--- a/testsuites/sptests/spcpucounter01/spcpucounter01.scn
+++ b/testsuites/sptests/spcpucounter01/spcpucounter01.scn
@@ -2,14 +2,24 @@
 CPU counter frequency: 25000000Hz
 nanoseconds for frequency count ticks: 1000000000
 test delay nanoseconds (10 times)
-busy wait relative to clock tick: 0.001320
-busy wait relative to clock tick: 0.001640
-busy wait relative to clock tick: 0.001320
-busy wait relative to clock tick: 0.001160
+busy wait duration: 1000840ns
+busy wait relative to clock tick: 0.000840
+busy wait duration: 1001200ns
+busy wait relative to clock tick: 0.001200
+busy wait duration: 1001480ns
+busy wait relative to clock tick: 0.001480
+busy wait duration: 1001200ns
+busy wait relative to clock tick: 0.001200
+busy wait duration: 1001120ns
+busy wait relative to clock tick: 0.001120
+busy wait duration: 1001280ns
 busy wait relative to clock tick: 0.001280
+busy wait duration: 1001120ns
+busy wait relative to clock tick: 0.001120
+busy wait duration: 1001240ns
 busy wait relative to clock tick: 0.001240
-busy wait relative to clock tick: 0.001280
-busy wait relative to clock tick: 0.001280
-busy wait relative to clock tick: 0.001320
+busy wait duration: 1001120ns
+busy wait relative to clock tick: 0.001120
+busy wait duration: 1001280ns
 busy wait relative to clock tick: 0.001280
 *** END OF TEST SPCPUCOUNTER 1 ***




More information about the vc mailing list