summaryrefslogtreecommitdiffstats
path: root/testsuites/sptests/sp37
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-08-22 17:09:36 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-08-26 10:21:27 +0200
commit96ec8ee80a18502c2159497e821df3fcd0dc7411 (patch)
tree81bd5f826828e0f35330f279dd08f024cfbdeec1 /testsuites/sptests/sp37
parentor1k/Makefile.am: libbsp_a_CPPFLAGS was defined twice (diff)
downloadrtems-96ec8ee80a18502c2159497e821df3fcd0dc7411.tar.bz2
rtems: Add more clock tick functions
Add rtems_clock_tick_later(), rtems_clock_tick_later_usec() and rtems_clock_tick_before().
Diffstat (limited to 'testsuites/sptests/sp37')
-rw-r--r--testsuites/sptests/sp37/init.c55
-rw-r--r--testsuites/sptests/sp37/sp37.doc5
-rw-r--r--testsuites/sptests/sp37/system.h4
3 files changed, 64 insertions, 0 deletions
diff --git a/testsuites/sptests/sp37/init.c b/testsuites/sptests/sp37/init.c
index be0bd3225e..60ae01bf01 100644
--- a/testsuites/sptests/sp37/init.c
+++ b/testsuites/sptests/sp37/init.c
@@ -230,6 +230,59 @@ static void test_interrupt_locks( void )
rtems_interrupt_lock_destroy( &initialized );
}
+static void test_clock_tick_functions( void )
+{
+ rtems_interrupt_level level;
+ Watchdog_Interval saved_ticks;
+
+ _Thread_Disable_dispatch();
+ rtems_interrupt_disable( level );
+
+ saved_ticks = _Watchdog_Ticks_since_boot;
+
+ _Watchdog_Ticks_since_boot = 0xdeadbeef;
+ rtems_test_assert( rtems_clock_get_ticks_since_boot() == 0xdeadbeef );
+
+ rtems_test_assert( rtems_clock_tick_later( 0 ) == 0xdeadbeef );
+ rtems_test_assert( rtems_clock_tick_later( 0x8160311e ) == 0x600df00d );
+
+ _Watchdog_Ticks_since_boot = 0;
+ rtems_test_assert( rtems_clock_tick_later_usec( 0 ) == 1 );
+ rtems_test_assert( rtems_clock_tick_later_usec( 1 ) == 2 );
+ rtems_test_assert( rtems_clock_tick_later_usec( US_PER_TICK ) == 2 );
+ rtems_test_assert( rtems_clock_tick_later_usec( US_PER_TICK + 1 ) == 3 );
+
+ _Watchdog_Ticks_since_boot = 0;
+ rtems_test_assert( !rtems_clock_tick_before( 0xffffffff ) );
+ rtems_test_assert( !rtems_clock_tick_before( 0 ) );
+ rtems_test_assert( rtems_clock_tick_before( 1 ) );
+
+ _Watchdog_Ticks_since_boot = 1;
+ rtems_test_assert( !rtems_clock_tick_before( 0 ) );
+ rtems_test_assert( !rtems_clock_tick_before( 1 ) );
+ rtems_test_assert( rtems_clock_tick_before( 2 ) );
+
+ _Watchdog_Ticks_since_boot = 0x7fffffff;
+ rtems_test_assert( !rtems_clock_tick_before( 0x7ffffffe ) );
+ rtems_test_assert( !rtems_clock_tick_before( 0x7fffffff ) );
+ rtems_test_assert( rtems_clock_tick_before( 0x80000000 ) );
+
+ _Watchdog_Ticks_since_boot = 0x80000000;
+ rtems_test_assert( !rtems_clock_tick_before( 0x7fffffff ) );
+ rtems_test_assert( !rtems_clock_tick_before( 0x80000000 ) );
+ rtems_test_assert( rtems_clock_tick_before( 0x80000001 ) );
+
+ _Watchdog_Ticks_since_boot = 0xffffffff;
+ rtems_test_assert( !rtems_clock_tick_before( 0xfffffffe ) );
+ rtems_test_assert( !rtems_clock_tick_before( 0xffffffff ) );
+ rtems_test_assert( rtems_clock_tick_before( 0 ) );
+
+ _Watchdog_Ticks_since_boot = saved_ticks;
+
+ rtems_interrupt_enable( level );
+ _Thread_Enable_dispatch();
+}
+
void test_interrupt_inline(void)
{
rtems_interrupt_level level;
@@ -413,6 +466,8 @@ rtems_task Init(
directive_failed( status, "rtems_clock_tick" );
puts( "clock_tick from task level" );
+ test_clock_tick_functions();
+
/*
* Now do a dispatch directly out of a clock tick that is
* called from a task. We need to create a task that will
diff --git a/testsuites/sptests/sp37/sp37.doc b/testsuites/sptests/sp37/sp37.doc
index 9e814f2752..b98faa1caa 100644
--- a/testsuites/sptests/sp37/sp37.doc
+++ b/testsuites/sptests/sp37/sp37.doc
@@ -13,6 +13,9 @@ test set name: sp37
directives:
rtems_clock_tick
+ rtems_clock_tick_later()
+ rtems_clock_tick_later_usec()
+ rtems_clock_tick_before()
rtems_interrupt_disable (inline/body)
rtems_interrupt_enable (inline/body)
rtems_interrupt_flash (inline/body)
@@ -24,6 +27,8 @@ concepts:
+ Ensure that rtems_clock_tick operates properly when invoked from a task
rather than an ISR.
++ Ensure that clock tick counter functions work properly.
+
+ Ensure that the interrupt disable, enable, and flash directives operate
as expected.
diff --git a/testsuites/sptests/sp37/system.h b/testsuites/sptests/sp37/system.h
index 43bef8129e..6bb47ec11f 100644
--- a/testsuites/sptests/sp37/system.h
+++ b/testsuites/sptests/sp37/system.h
@@ -15,6 +15,8 @@
#include <tmacros.h>
+#define US_PER_TICK 10000
+
/* functions */
rtems_task Init(
@@ -28,6 +30,8 @@ rtems_task Init(
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
+#define CONFIGURE_MICROSECONDS_PER_TICK US_PER_TICK
+
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_INIT_TASK_PRIORITY 2
#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_PREEMPT