[rtems commit] tests: Fix rtems_test_spin_until_next_tick()
Sebastian Huber
sebh at rtems.org
Fri Dec 7 13:33:23 UTC 2018
Module: rtems
Branch: master
Commit: 03e86553d2839c123fa79ed382ea3ee10bede78c
Changeset: http://git.rtems.org/rtems/commit/?id=03e86553d2839c123fa79ed382ea3ee10bede78c
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Wed Dec 5 08:05:54 2018 +0100
tests: Fix rtems_test_spin_until_next_tick()
This bug surfaced due to sporadic failures in sptimecounter02. Adjust
rtems_test_spin_for_ticks() to include the partial tick in the argument
value.
---
testsuites/sptests/spedfsched04/init.c | 2 ++
testsuites/support/include/test_support.h | 6 ++++--
testsuites/support/src/spin.c | 20 +++++++-------------
3 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/testsuites/sptests/spedfsched04/init.c b/testsuites/sptests/spedfsched04/init.c
index e751e24..8625f85 100644
--- a/testsuites/sptests/spedfsched04/init.c
+++ b/testsuites/sptests/spedfsched04/init.c
@@ -65,6 +65,8 @@ static rtems_task Task(
status = rtems_rate_monotonic_create( Task_name[ argument ], &RM_period );
directive_failed( status, "rtems_rate_monotonic_create" );
+ rtems_test_spin_until_next_tick();
+
while ( FOREVER ) {
status = rtems_rate_monotonic_period( RM_period, Periods[ argument ] );
diff --git a/testsuites/support/include/test_support.h b/testsuites/support/include/test_support.h
index 017444c..9c30b39 100644
--- a/testsuites/support/include/test_support.h
+++ b/testsuites/support/include/test_support.h
@@ -11,6 +11,7 @@
#define __TEST_SUPPORT_h
#include <stdarg.h>
+#include <rtems.h>
#ifdef __cplusplus
extern "C" {
@@ -28,9 +29,10 @@ const char *Get_Too_Long_Name(void);
const char *Get_Longest_Name(void);
/*
- * Spin for specified number of ticks.
+ * Spin for specified number of ticks. The first tick we spin through is a
+ * partial one.
*/
-void rtems_test_spin_for_ticks(int ticks);
+void rtems_test_spin_for_ticks(rtems_interval ticks);
/*
* Spin until the next clock tick
diff --git a/testsuites/support/src/spin.c b/testsuites/support/src/spin.c
index 5b6d3d4..57c4e32 100644
--- a/testsuites/support/src/spin.c
+++ b/testsuites/support/src/spin.c
@@ -17,21 +17,15 @@
/*
* Burn CPU for specified number of ticks
*/
-void rtems_test_spin_for_ticks(int ticks)
+void rtems_test_spin_for_ticks(rtems_interval ticks)
{
- rtems_interval start;
- rtems_interval now;
+ rtems_interval start;
+ rtems_interval now;
start = rtems_clock_get_ticks_since_boot();
do {
now = rtems_clock_get_ticks_since_boot();
- /*
- * Spin for <= ticks so we spin >= number of ticks.
- * The first tick we spin through is a partial one.
- * So you sping "ticks" number of ticks plus a partial
- * one.
- */
- } while ( (now-start) <= ticks );
+ } while ( now - start < ticks );
}
/*
@@ -39,11 +33,11 @@ void rtems_test_spin_for_ticks(int ticks)
*/
void rtems_test_spin_until_next_tick( void )
{
- rtems_interval start;
- rtems_interval now;
+ rtems_interval start;
+ rtems_interval now;
start = rtems_clock_get_ticks_since_boot();
do {
now = rtems_clock_get_ticks_since_boot();
- } while ( now != start );
+ } while ( now == start );
}
More information about the vc
mailing list