diff options
Diffstat (limited to 'testsuites/sptests')
25 files changed, 787 insertions, 228 deletions
diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am index 9025ff3535..c3fc443da0 100644 --- a/testsuites/sptests/Makefile.am +++ b/testsuites/sptests/Makefile.am @@ -38,6 +38,8 @@ else _SUBDIRS += sp29 endif _SUBDIRS += spintrcritical23 +_SUBDIRS += sptimecounter01 +_SUBDIRS += sptimecounter02 _SUBDIRS += spatomic01 _SUBDIRS += spintrcritical22 _SUBDIRS += spsem03 diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac index ae3c763848..b8287a4ea7 100644 --- a/testsuites/sptests/configure.ac +++ b/testsuites/sptests/configure.ac @@ -41,6 +41,8 @@ AM_CONDITIONAL(HAS_SMP,test "$rtems_cv_RTEMS_SMP" = "yes") # Explicitly list all Makefiles here AC_CONFIG_FILES([Makefile spintrcritical23/Makefile +sptimecounter01/Makefile +sptimecounter02/Makefile spatomic01/Makefile spglobalcon01/Makefile spintrcritical22/Makefile diff --git a/testsuites/sptests/sp37/init.c b/testsuites/sptests/sp37/init.c index aaaf68426b..647485e555 100644 --- a/testsuites/sptests/sp37/init.c +++ b/testsuites/sptests/sp37/init.c @@ -431,11 +431,7 @@ rtems_timer_service_routine test_unblock_task( _Thread_Disable_dispatch(); status = rtems_task_resume( blocked_task_id ); _Thread_Unnest_dispatch(); -#if defined( RTEMS_SMP ) - directive_failed_with_level( status, "rtems_task_resume", 1 ); -#else directive_failed( status, "rtems_task_resume" ); -#endif } rtems_task Init( diff --git a/testsuites/sptests/spclock_err01/init.c b/testsuites/sptests/spclock_err01/init.c index ab5c00ab1e..087c8d4a05 100644 --- a/testsuites/sptests/spclock_err01/init.c +++ b/testsuites/sptests/spclock_err01/init.c @@ -115,14 +115,6 @@ rtems_task Init( puts( "TA1 - rtems_clock_get_tod_timeval - RTEMS_NOT_DEFINED" ); } - puts( "TA1 - rtems_clock_set_nanoseconds_extension - RTEMS_INVALID_ADDRESS" ); - status = rtems_clock_set_nanoseconds_extension( NULL ); - fatal_directive_status( - status, - RTEMS_INVALID_ADDRESS, - "rtems_clock_set_nanoseconds_extension NULL param" - ); - /* NULL parameter */ status = rtems_clock_set( NULL ); fatal_directive_status( diff --git a/testsuites/sptests/spintrcritical01/init.c b/testsuites/sptests/spintrcritical01/init.c index dc36aee4fd..b7cfee42f8 100644 --- a/testsuites/sptests/spintrcritical01/init.c +++ b/testsuites/sptests/spintrcritical01/init.c @@ -14,12 +14,7 @@ #include <tmacros.h> #include <intrcritical.h> -#include <rtems/rtems/semimpl.h> - -/* forward declarations to avoid warnings */ -rtems_task Init(rtems_task_argument argument); -rtems_timer_service_routine test_release_from_isr(rtems_id timer, void *arg); -Thread_blocking_operation_States getState(void); +#include <rtems/score/threadimpl.h> #if defined(FIFO_NO_TIMEOUT) #define TEST_NAME "1" @@ -58,33 +53,28 @@ Thread_blocking_operation_States getState(void); const char rtems_test_name[] = "SPINTRCRITICAL " TEST_NAME; -rtems_id Semaphore; -volatile bool case_hit = false; +static Thread_Control *thread; + +static rtems_id Semaphore; + +static bool case_hit; -Thread_blocking_operation_States getState(void) +static bool interrupts_blocking_op(void) { - Objects_Locations location; - Semaphore_Control *sem; - - sem = (Semaphore_Control *)_Objects_Get( - &_Semaphore_Information, Semaphore, &location ); - if ( location != OBJECTS_LOCAL ) { - puts( "Bad object lookup" ); - rtems_test_exit(0); - } - _Thread_Unnest_dispatch(); + Thread_Wait_flags flags = _Thread_Wait_flags_get( thread ); - return sem->Core_control.semaphore.Wait_queue.sync_state; + return + flags == ( THREAD_WAIT_CLASS_OBJECT | THREAD_WAIT_STATE_INTEND_TO_BLOCK ); } -rtems_timer_service_routine test_release_from_isr( +static rtems_timer_service_routine test_release_from_isr( rtems_id timer, void *arg ) { rtems_status_code status; - if ( getState() == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED ) { + if ( interrupts_blocking_op() ) { case_hit = true; } @@ -109,7 +99,7 @@ static bool test_body( void *arg ) return case_hit; } -rtems_task Init( +static rtems_task Init( rtems_task_argument ignored ) { @@ -117,6 +107,8 @@ rtems_task Init( TEST_BEGIN(); + thread = _Thread_Get_executing(); + puts( "Init - Trying to generate semaphore release from ISR while blocking" ); puts( "Init - Variation is: " TEST_STRING ); status = rtems_semaphore_create( diff --git a/testsuites/sptests/spintrcritical08/init.c b/testsuites/sptests/spintrcritical08/init.c index 13544b24c7..f375cd49f3 100644 --- a/testsuites/sptests/spintrcritical08/init.c +++ b/testsuites/sptests/spintrcritical08/init.c @@ -55,7 +55,7 @@ static rtems_timer_service_routine test_release_from_isr( watchdog->delta_interval == 0 && watchdog->routine == _Rate_monotonic_Timeout ) { - Watchdog_States state = _Watchdog_Remove( watchdog ); + Watchdog_States state = _Watchdog_Remove_ticks( watchdog ); rtems_test_assert( state == WATCHDOG_ACTIVE ); (*watchdog->routine)( watchdog->id, watchdog->user_data ); diff --git a/testsuites/sptests/spintrcritical09/init.c b/testsuites/sptests/spintrcritical09/init.c index 2f9caa5ad6..cc119e88c1 100644 --- a/testsuites/sptests/spintrcritical09/init.c +++ b/testsuites/sptests/spintrcritical09/init.c @@ -14,28 +14,22 @@ #include <tmacros.h> #include <intrcritical.h> -#include <rtems/rtems/semimpl.h> +#include <rtems/score/threadimpl.h> #include <rtems/score/watchdogimpl.h> const char rtems_test_name[] = "SPINTRCRITICAL 9"; +static Thread_Control *thread; + static rtems_id Semaphore; -static bool case_hit = false; -static Thread_blocking_operation_States getState(void) +static bool case_hit; + +static bool is_interrupt_timeout(void) { - Objects_Locations location; - Semaphore_Control *sem; - - sem = (Semaphore_Control *)_Objects_Get( - &_Semaphore_Information, Semaphore, &location ); - if ( location != OBJECTS_LOCAL ) { - puts( "Bad object lookup" ); - rtems_test_exit(0); - } - _Thread_Unnest_dispatch(); + Thread_Wait_flags flags = _Thread_Wait_flags_get( thread ); - return sem->Core_control.semaphore.Wait_queue.sync_state; + return flags == ( THREAD_WAIT_CLASS_OBJECT | THREAD_WAIT_STATE_READY_AGAIN ); } static rtems_timer_service_routine test_release_from_isr( @@ -50,14 +44,14 @@ static rtems_timer_service_routine test_release_from_isr( if ( watchdog->delta_interval == 0 - && watchdog->routine == _Thread_queue_Timeout + && watchdog->routine == _Thread_Timeout ) { - Watchdog_States state = _Watchdog_Remove( watchdog ); + Watchdog_States state = _Watchdog_Remove_ticks( watchdog ); rtems_test_assert( state == WATCHDOG_ACTIVE ); (*watchdog->routine)( watchdog->id, watchdog->user_data ); - if ( getState() == THREAD_BLOCKING_OPERATION_TIMEOUT ) { + if ( is_interrupt_timeout() ) { case_hit = true; } } @@ -81,6 +75,8 @@ static rtems_task Init( TEST_BEGIN(); + thread = _Thread_Get_executing(); + puts( "Init - Test may not be able to detect case is hit reliably" ); puts( "Init - Trying to generate timeout from ISR while blocking" ); sc = rtems_semaphore_create( diff --git a/testsuites/sptests/spintrcritical10/init.c b/testsuites/sptests/spintrcritical10/init.c index 441b161b5b..e4a2a940a6 100644 --- a/testsuites/sptests/spintrcritical10/init.c +++ b/testsuites/sptests/spintrcritical10/init.c @@ -78,7 +78,7 @@ static void any_satisfy_before_timeout(rtems_id timer, void *arg) ); rtems_test_assert(thread->Wait.return_code == RTEMS_SUCCESSFUL); - _Event_Timeout(0, thread); + _Thread_Timeout(0, thread); rtems_test_assert( *(rtems_event_set *) thread->Wait.return_argument == GREEN @@ -88,7 +88,7 @@ static void any_satisfy_before_timeout(rtems_id timer, void *arg) if (ctx->hit) { rtems_test_assert( _Thread_Wait_flags_get(thread) - == (THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_INTERRUPT_SATISFIED) + == (THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_READY_AGAIN) ); } @@ -175,7 +175,7 @@ static void all_satisfy_before_timeout(rtems_id timer, void *arg) ); rtems_test_assert(thread->Wait.return_code == RTEMS_SUCCESSFUL); - _Event_Timeout(0, thread); + _Thread_Timeout(0, thread); rtems_test_assert( *(rtems_event_set *) thread->Wait.return_argument == EVENTS @@ -185,7 +185,7 @@ static void all_satisfy_before_timeout(rtems_id timer, void *arg) if (ctx->hit) { rtems_test_assert( _Thread_Wait_flags_get(thread) - == (THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_INTERRUPT_SATISFIED) + == (THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_READY_AGAIN) ); } @@ -251,7 +251,7 @@ static void timeout_before_satisfied(rtems_id timer, void *arg) ); rtems_test_assert(thread->Wait.return_code == RTEMS_SUCCESSFUL); - _Event_Timeout(0, thread); + _Thread_Timeout(0, thread); rtems_test_assert( *(rtems_event_set *) thread->Wait.return_argument == DEADBEEF @@ -269,7 +269,7 @@ static void timeout_before_satisfied(rtems_id timer, void *arg) if (ctx->hit) { rtems_test_assert( _Thread_Wait_flags_get(thread) - == (THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_INTERRUPT_TIMEOUT) + == (THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_READY_AGAIN) ); } diff --git a/testsuites/sptests/spintrcritical16/init.c b/testsuites/sptests/spintrcritical16/init.c index 08eeb8b9b4..a094b419b3 100644 --- a/testsuites/sptests/spintrcritical16/init.c +++ b/testsuites/sptests/spintrcritical16/init.c @@ -14,47 +14,36 @@ #include <tmacros.h> #include <intrcritical.h> -#include <rtems/rtems/semimpl.h> +#include <rtems/score/threadimpl.h> const char rtems_test_name[] = "SPINTRCRITICAL 16"; -/* forward declarations to avoid warnings */ -rtems_task Init(rtems_task_argument argument); -rtems_timer_service_routine test_release_from_isr(rtems_id timer, void *arg); -Thread_blocking_operation_States getState(void); +static Thread_Control *Main_TCB; -Thread_Control *Main_TCB; -rtems_id Semaphore; -volatile bool case_hit = false; +static rtems_id Semaphore; -Thread_blocking_operation_States getState(void) +static bool case_hit; + +static bool interrupts_blocking_op(void) { - Objects_Locations location; - Semaphore_Control *sem; - - sem = (Semaphore_Control *)_Objects_Get( - &_Semaphore_Information, Semaphore, &location ); - if ( location != OBJECTS_LOCAL ) { - puts( "Bad object lookup" ); - rtems_test_exit(0); - } - _Thread_Unnest_dispatch(); + Thread_Wait_flags flags = _Thread_Wait_flags_get( Main_TCB ); - return sem->Core_control.semaphore.Wait_queue.sync_state; + return + flags == ( THREAD_WAIT_CLASS_OBJECT | THREAD_WAIT_STATE_INTEND_TO_BLOCK ); } -rtems_timer_service_routine test_release_from_isr( +static rtems_timer_service_routine test_release_from_isr( rtems_id timer, void *arg ) { - if ( getState() == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED ) { + if ( interrupts_blocking_op() ) { case_hit = true; (void) rtems_semaphore_release( Semaphore ); } if ( Main_TCB->Wait.queue != NULL ) { - _Thread_queue_Process_timeout( Main_TCB ); + _Thread_Timeout( 0, Main_TCB ); } } @@ -70,7 +59,7 @@ static bool test_body( void *arg ) return case_hit; } -rtems_task Init( +static rtems_task Init( rtems_task_argument ignored ) { diff --git a/testsuites/sptests/spintrcritical17/init.c b/testsuites/sptests/spintrcritical17/init.c index 9dde48a06b..238493e71a 100644 --- a/testsuites/sptests/spintrcritical17/init.c +++ b/testsuites/sptests/spintrcritical17/init.c @@ -1,10 +1,11 @@ /* - * Copyright (c) 2009 - * embedded brains GmbH - * Obere Lagerstr. 30 - * D-82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * Copyright (c) 2009-2014 embedded brains GmbH. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at @@ -22,141 +23,91 @@ const char rtems_test_name[] = "SPINTRCRITICAL 17"; -/* forward declarations to avoid warnings */ -rtems_task Init(rtems_task_argument argument); - -#define TIMER_COUNT 4 - -#define TIMER_TRIGGER 0 -#define TIMER_RESET 1 -#define TIMER_NEVER_INTERVAL 2 -#define TIMER_NEVER_TOD 3 - -static rtems_id timer [TIMER_COUNT]; +typedef struct { + rtems_id timer1; + rtems_id timer2; + bool done; +} test_context; -static rtems_time_of_day tod; - -static volatile bool case_hit; - -static void never_callback(rtems_id timer, void *arg) -{ - rtems_test_assert(false); -} +static test_context ctx_instance; -static void reset_tod_timer(void) +static void never(rtems_id timer_id, void *arg) { - rtems_status_code sc = RTEMS_SUCCESSFUL; - - sc = rtems_timer_server_fire_when( - timer [TIMER_NEVER_TOD], - &tod, - never_callback, - NULL - ); - directive_failed_with_level(sc, "rtems_timer_server_fire_after", -1); + rtems_test_assert(0); } -static void reset_callback(rtems_id timer_id, void *arg) +static void fire(rtems_id timer_id, void *arg) { - rtems_status_code sc = RTEMS_SUCCESSFUL; - - sc = rtems_timer_reset(timer [TIMER_RESET]); - directive_failed_with_level(sc, "rtems_timer_reset", -1); - - sc = rtems_timer_reset(timer [TIMER_NEVER_INTERVAL]); - directive_failed_with_level(sc, "rtems_timer_reset", -1); - - reset_tod_timer(); - - if (!case_hit) { - case_hit = _Timer_server->insert_chain != NULL; + /* The arg is NULL */ + test_context *ctx = &ctx_instance; + rtems_status_code sc; + + if (!ctx->done) { + ctx->done = + _Timer_server->Interval_watchdogs.system_watchdog_helper != NULL; + + if (ctx->done) { + sc = rtems_timer_server_fire_after(ctx->timer2, 100, never, NULL); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + } } } -static void trigger_callback(rtems_id timer_id, void *arg) +static bool test_body(void *arg) { - rtems_status_code sc = RTEMS_SUCCESSFUL; + test_context *ctx = arg; + rtems_status_code sc; - if (case_hit) { - TEST_END(); + sc = rtems_timer_reset(ctx->timer1); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); - rtems_test_exit(0); - } else if (interrupt_critical_section_test_support_delay()) { - puts("test case not hit, give up"); - - rtems_test_exit(0); - } - - sc = rtems_timer_reset(timer [TIMER_TRIGGER]); - directive_failed(sc, "rtems_timer_reset"); + return ctx->done; } -rtems_task Init( rtems_task_argument ignored ) +static void Init(rtems_task_argument ignored) { - rtems_status_code sc = RTEMS_SUCCESSFUL; - size_t i = 0; + test_context *ctx = &ctx_instance; + rtems_status_code sc; TEST_BEGIN(); - build_time(&tod, 4, 12, 2009, 9, 34, 11, 0); - sc = rtems_clock_set(&tod); - directive_failed(sc, "rtems_clock_set"); - - ++tod.year; + sc = rtems_timer_create( + rtems_build_name('T', 'I', 'M', '1'), + &ctx->timer1 + ); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); - for (i = 0; i < TIMER_COUNT; ++i) { - sc = rtems_timer_create( - rtems_build_name('T', 'I', 'M', '0' + i), - &timer [i] - ); - directive_failed(sc, "rtems_timer_create"); - } + sc = rtems_timer_create( + rtems_build_name('T', 'I', 'M', '2'), + &ctx->timer2 + ); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); sc = rtems_timer_initiate_server( RTEMS_MINIMUM_PRIORITY, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_ATTRIBUTES ); - directive_failed(sc, "rtems_timer_initiate_server"); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); - sc = rtems_timer_server_fire_after( - timer [TIMER_NEVER_INTERVAL], - 2, - never_callback, - NULL - ); - directive_failed(sc, "rtems_timer_server_fire_after"); - - reset_tod_timer(); - - sc = rtems_timer_fire_after( - timer [TIMER_RESET], - 1, - reset_callback, - NULL - ); - directive_failed(sc, "rtems_timer_fire_after"); - - sc = rtems_timer_server_fire_after( - timer [TIMER_TRIGGER], - 1, - trigger_callback, - NULL - ); - directive_failed(sc, "rtems_timer_server_fire_after"); + sc = rtems_timer_server_fire_after(ctx->timer1, 1000, never, NULL); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); - interrupt_critical_section_test_support_initialize(NULL); + interrupt_critical_section_test(test_body, ctx, fire); + rtems_test_assert(ctx->done); - rtems_task_delete(RTEMS_SELF); + TEST_END(); + rtems_test_exit(0); } #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER -#define CONFIGURE_MICROSECONDS_PER_TICK 2000 +#define CONFIGURE_MICROSECONDS_PER_TICK 1000 #define CONFIGURE_MAXIMUM_TASKS 2 -#define CONFIGURE_MAXIMUM_TIMERS 4 +#define CONFIGURE_MAXIMUM_TIMERS 3 +#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION diff --git a/testsuites/sptests/spintrcritical17/spintrcritical17.doc b/testsuites/sptests/spintrcritical17/spintrcritical17.doc index 3be8e60c52..809a9669d6 100644 --- a/testsuites/sptests/spintrcritical17/spintrcritical17.doc +++ b/testsuites/sptests/spintrcritical17/spintrcritical17.doc @@ -1,4 +1,4 @@ -# Copyright (c) 2009 embedded brains GmbH. +# Copyright (c) 2009-2015 embedded brains GmbH. # # The license and distribution terms for this file may be # found in the file LICENSE in this distribution or at @@ -11,9 +11,7 @@ test set name: spintrcritical17 directives: - _Timer_server_Get_watchdogs_that_fire_now - _Timer_server_Schedule_operation_method - _Timer_server_Process_insertions + _Timer_server_Update_system_watchdog concepts: diff --git a/testsuites/sptests/spintrcritical20/init.c b/testsuites/sptests/spintrcritical20/init.c index daa8ac7f7e..7e52211742 100644 --- a/testsuites/sptests/spintrcritical20/init.c +++ b/testsuites/sptests/spintrcritical20/init.c @@ -44,6 +44,10 @@ static void semaphore_task(rtems_task_argument arg) test_context *ctx = (test_context *) arg; ctx->semaphore_task_tcb = _Thread_Get_executing(); + _Thread_Wait_set_timeout_code( + ctx->semaphore_task_tcb, + CORE_SEMAPHORE_TIMEOUT + ); while (true) { rtems_status_code sc = rtems_semaphore_obtain( @@ -87,7 +91,7 @@ static bool test_body(void *arg) ctx->thread_queue_was_null = true; } - _Thread_queue_Process_timeout(ctx->semaphore_task_tcb); + _Thread_Timeout(0, ctx->semaphore_task_tcb); switch (ctx->semaphore_task_tcb->Wait.return_code) { case CORE_SEMAPHORE_STATUS_SUCCESSFUL: @@ -103,7 +107,9 @@ static bool test_body(void *arg) _Thread_Enable_dispatch(); - return false; + return ctx->thread_queue_was_null + && ctx->status_was_successful + && ctx->status_was_timeout; } static void Init(rtems_task_argument ignored) diff --git a/testsuites/sptests/spintrcritical22/init.c b/testsuites/sptests/spintrcritical22/init.c index 93946c39c5..1a377f7838 100644 --- a/testsuites/sptests/spintrcritical22/init.c +++ b/testsuites/sptests/spintrcritical22/init.c @@ -52,14 +52,18 @@ static void release_semaphore(rtems_id timer, void *arg) rtems_status_code sc; CORE_mutex_Control *mtx = &ctx->semaphore_control->Core_control.mutex; - if (mtx->Wait_queue.sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED) { + if ( + _Thread_Wait_flags_get(ctx->main_task_control) + == (THREAD_WAIT_CLASS_OBJECT | THREAD_WAIT_STATE_INTEND_TO_BLOCK) + ) { ctx->done = true; sc = rtems_semaphore_release(ctx->semaphore_id); rtems_test_assert(sc == RTEMS_SUCCESSFUL); rtems_test_assert( - mtx->Wait_queue.sync_state == THREAD_BLOCKING_OPERATION_SATISFIED + _Thread_Wait_flags_get(ctx->main_task_control) + == (THREAD_WAIT_CLASS_OBJECT | THREAD_WAIT_STATE_READY_AGAIN) ); rtems_test_assert(mtx->nest_count == 1); rtems_test_assert(mtx->holder == ctx->main_task_control); diff --git a/testsuites/sptests/spintrcritical23/init.c b/testsuites/sptests/spintrcritical23/init.c index 8536489f5d..89fea25a12 100644 --- a/testsuites/sptests/spintrcritical23/init.c +++ b/testsuites/sptests/spintrcritical23/init.c @@ -70,7 +70,7 @@ static void change_priority(rtems_id timer, void *arg) rtems_interrupt_lock_acquire(&ctx->lock, &lock_context); if ( - ctx->priority_generation != ctx->tcb->Priority.generation + ctx->priority_generation != ctx->tcb->priority_generation && scheduler_node_unchanged(ctx) ) { rtems_task_priority priority_interrupt; @@ -113,7 +113,7 @@ static bool test_body(void *arg) priority_interrupt = 1 + (priority_task + 1) % 3; ctx->priority_task = priority_task; ctx->priority_interrupt = priority_interrupt; - ctx->priority_generation = ctx->tcb->Priority.generation; + ctx->priority_generation = ctx->tcb->priority_generation; memcpy( &ctx->scheduler_node, ctx->tcb->Scheduler.node, diff --git a/testsuites/sptests/spsize/size.c b/testsuites/sptests/spsize/size.c index f00da0d465..657fa425de 100644 --- a/testsuites/sptests/spsize/size.c +++ b/testsuites/sptests/spsize/size.c @@ -390,18 +390,13 @@ uninitialized = /*timerimpl.h*/ (sizeof _Timer_Information) + -/*tod.h*/ (sizeof _TOD.now) + - (sizeof _TOD.uptime) + - /*tqdata.h*/ 0 + /*types.h*/ 0 + /*userext.h*/ (sizeof _User_extensions_List) + -/*watchdog.h*/ (sizeof _Watchdog_Sync_level) + - (sizeof _Watchdog_Sync_count) + - (sizeof _Watchdog_Ticks_since_boot) + +/*watchdog.h*/ (sizeof _Watchdog_Ticks_since_boot) + (sizeof _Watchdog_Ticks_header) + (sizeof _Watchdog_Seconds_header) + diff --git a/testsuites/sptests/spthreadq01/init.c b/testsuites/sptests/spthreadq01/init.c index 240cd1a9e8..ce47760e2d 100644 --- a/testsuites/sptests/spthreadq01/init.c +++ b/testsuites/sptests/spthreadq01/init.c @@ -18,38 +18,31 @@ const char rtems_test_name[] = "SPTHREADQ 1"; -/* forward declarations to avoid warnings */ -rtems_task Init(rtems_task_argument argument); -void threadq_first_empty( - const char *discipline_string, - Thread_queue_Disciplines discipline -); - -void threadq_first_empty( - const char *discipline_string, - Thread_queue_Disciplines discipline +static Thread_queue_Control fifo_queue = + THREAD_QUEUE_FIFO_INITIALIZER( fifo_queue, "FIFO" ); + +static Thread_queue_Control prio_queue = + THREAD_QUEUE_PRIORIY_INITIALIZER( prio_queue, "Prio" ); + +static rtems_task Init( + rtems_task_argument ignored ) { - Thread_queue_Control tq; - - printf( "Init - initialize thread queue for %s\n", discipline_string ); - _Thread_queue_Initialize( &tq, discipline, 3 ); + TEST_BEGIN(); puts( "Init - _Thread_queue_Extract - thread not blocked on a thread queue" ); _Thread_Disable_dispatch(); - _Thread_queue_Extract( &tq, _Thread_Executing ); + _Thread_queue_Extract( _Thread_Executing ); _Thread_Enable_dispatch(); /* is there more to check? */ -} -rtems_task Init( - rtems_task_argument ignored -) -{ - TEST_BEGIN(); + rtems_test_assert( _Chain_Is_empty( &fifo_queue.Queues.Fifo ) ); + rtems_test_assert( fifo_queue.operations == &_Thread_queue_Operations_FIFO ); - threadq_first_empty( "FIFO", THREAD_QUEUE_DISCIPLINE_FIFO ); - threadq_first_empty( "Priority", THREAD_QUEUE_DISCIPLINE_PRIORITY ); + rtems_test_assert( _RBTree_Is_empty( &fifo_queue.Queues.Priority ) ); + rtems_test_assert( + prio_queue.operations == &_Thread_queue_Operations_priority + ); TEST_END(); rtems_test_exit(0); diff --git a/testsuites/sptests/sptimecounter01/Makefile.am b/testsuites/sptests/sptimecounter01/Makefile.am new file mode 100644 index 0000000000..b2310886fc --- /dev/null +++ b/testsuites/sptests/sptimecounter01/Makefile.am @@ -0,0 +1,19 @@ +rtems_tests_PROGRAMS = sptimecounter01 +sptimecounter01_SOURCES = init.c + +dist_rtems_tests_DATA = sptimecounter01.scn sptimecounter01.doc + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../automake/compile.am +include $(top_srcdir)/../automake/leaf.am + +AM_CPPFLAGS += -I$(top_srcdir)/../support/include + +LINK_OBJS = $(sptimecounter01_OBJECTS) +LINK_LIBS = $(sptimecounter01_LDLIBS) + +sptimecounter01$(EXEEXT): $(sptimecounter01_OBJECTS) $(sptimecounter01_DEPENDENCIES) + @rm -f sptimecounter01$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/sptests/sptimecounter01/init.c b/testsuites/sptests/sptimecounter01/init.c new file mode 100644 index 0000000000..47ebb2722c --- /dev/null +++ b/testsuites/sptests/sptimecounter01/init.c @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2015 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifdef HAVE_CONFIG_H + #include "config.h" +#endif + +#include <assert.h> + +#include <bsp/bootcard.h> + +#include <rtems/test.h> + +#include <rtems/score/timecounterimpl.h> +#include <rtems/score/watchdogimpl.h> +#include <rtems/timecounter.h> +#include <rtems/bsd.h> + +const char rtems_test_name[] = "SPTIMECOUNTER_1"; + +typedef struct { + struct timecounter tc_soft; + u_int tc_soft_counter; +} test_context; + +static test_context test_instance; + +static uint32_t test_get_timecount_soft(struct timecounter *tc) +{ + test_context *ctx = tc->tc_priv; + + ++ctx->tc_soft_counter; + + return ctx->tc_soft_counter; +} + +void boot_card(const char *cmdline) +{ + test_context *ctx = &test_instance; + struct timecounter *tc_soft = &ctx->tc_soft; + uint64_t soft_freq = 1000000; + struct bintime bt; + + rtems_test_begink(); + + _Timecounter_Initialize(); + _Watchdog_Handler_initialization(); + + rtems_bsd_binuptime(&bt); + assert(bt.sec == 1); + assert(bt.frac== 0); + + rtems_bsd_binuptime(&bt); + assert(bt.sec == 1); + assert(bt.frac == 0); + + rtems_timecounter_tick(); + rtems_bsd_binuptime(&bt); + assert(bt.sec == 1); + assert(bt.frac == 0); + + ctx->tc_soft_counter = 0; + tc_soft->tc_get_timecount = test_get_timecount_soft; + tc_soft->tc_counter_mask = 0x0fffffff; + tc_soft->tc_frequency = soft_freq; + tc_soft->tc_quality = 1234; + tc_soft->tc_priv = ctx; + _Timecounter_Install(tc_soft); + assert(ctx->tc_soft_counter == 3); + + rtems_bsd_binuptime(&bt); + assert(ctx->tc_soft_counter == 4); + + assert(bt.sec == 1); + assert(bt.frac == 18446744073708); + + ctx->tc_soft_counter = 0xf0000000 | 3; + rtems_bsd_binuptime(&bt); + assert(ctx->tc_soft_counter == (0xf0000000 | 4)); + + assert(bt.sec == 1); + assert(bt.frac == 18446744073708); + + /* Ensure that the fraction overflows and the second remains constant */ + ctx->tc_soft_counter = (0xf0000000 | 3) + soft_freq; + rtems_bsd_binuptime(&bt); + assert(ctx->tc_soft_counter == (0xf0000000 | 4) + soft_freq); + assert(bt.sec == 1); + assert(bt.frac == 18446742522092); + + rtems_test_endk(); + + _Terminate(RTEMS_FATAL_SOURCE_EXIT, false, 0); +} + +#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER + +#define CONFIGURE_APPLICATION_DISABLE_FILESYSTEM + +#define CONFIGURE_DISABLE_NEWLIB_REENTRANCY + +#define CONFIGURE_SCHEDULER_USER + +#define CONFIGURE_SCHEDULER_CONTEXT + +#define CONFIGURE_SCHEDULER_CONTROLS { } + +#define CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER 0 + +#define CONFIGURE_TASK_STACK_ALLOCATOR NULL + +#define CONFIGURE_TASK_STACK_DEALLOCATOR NULL + +#define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION + +#define CONFIGURE_IDLE_TASK_BODY NULL + +#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION + +#define CONFIGURE_INIT + +#include <rtems/confdefs.h> diff --git a/testsuites/sptests/sptimecounter01/sptimecounter01.doc b/testsuites/sptests/sptimecounter01/sptimecounter01.doc new file mode 100644 index 0000000000..4a7442c2e6 --- /dev/null +++ b/testsuites/sptests/sptimecounter01/sptimecounter01.doc @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2015 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +This file describes the directives and concepts tested by this test set. + +test set name: sptimecounter01 + +directives: + + _Timecounter_Initialize + rtems_timecounter_tick + _Timecounter_Install + rtems_bsd_bintime + +concepts: + + This test checks the correct functioning of the FreeBSD timecounter startup + process diff --git a/testsuites/sptests/sptimecounter01/sptimecounter01.scn b/testsuites/sptests/sptimecounter01/sptimecounter01.scn new file mode 100644 index 0000000000..5fa9c0f281 --- /dev/null +++ b/testsuites/sptests/sptimecounter01/sptimecounter01.scn @@ -0,0 +1,2 @@ +*** BEGIN OF TEST SPTIMECOUNTER_1 *** +*** END OF TEST SPTIMECOUNTER_1 *** diff --git a/testsuites/sptests/sptimecounter02/Makefile.am b/testsuites/sptests/sptimecounter02/Makefile.am new file mode 100644 index 0000000000..badb647a14 --- /dev/null +++ b/testsuites/sptests/sptimecounter02/Makefile.am @@ -0,0 +1,20 @@ +rtems_tests_PROGRAMS = sptimecounter02 +sptimecounter02_SOURCES = init.c +sptimecounter02_SOURCES += ../../support/src/spin.c + +dist_rtems_tests_DATA = sptimecounter02.scn sptimecounter02.doc + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../automake/compile.am +include $(top_srcdir)/../automake/leaf.am + +AM_CPPFLAGS += -I$(top_srcdir)/../support/include + +LINK_OBJS = $(sptimecounter02_OBJECTS) +LINK_LIBS = $(sptimecounter02_LDLIBS) + +sptimecounter02$(EXEEXT): $(sptimecounter02_OBJECTS) $(sptimecounter02_DEPENDENCIES) + @rm -f sptimecounter02$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/sptests/sptimecounter02/init.c b/testsuites/sptests/sptimecounter02/init.c new file mode 100644 index 0000000000..c7d72a8eb7 --- /dev/null +++ b/testsuites/sptests/sptimecounter02/init.c @@ -0,0 +1,268 @@ +/* + * Copyright (c) 2015 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifdef HAVE_CONFIG_H + #include "config.h" +#endif + +#define _KERNEL + +#include <sys/time.h> +#include <sys/timetc.h> + +#include <stdlib.h> +#include <stdio.h> +#include <inttypes.h> +#include <unistd.h> + +#include <rtems.h> +#include <rtems/counter.h> +#include <rtems/test.h> + +#include <rtems/score/timecounterimpl.h> +#include <rtems/timecounter.h> +#include <rtems/bsd.h> + +#include <test_support.h> + +#include "tmacros.h" + +const char rtems_test_name[] = "SPTIMECOUNTER 2"; + +#define CPU_COUNT 32 + +#define DURATION_IN_SECONDS 1 + +typedef struct { + rtems_test_parallel_context base; + struct timecounter tc_null; + uint32_t binuptime_per_job[CPU_COUNT]; + sbintime_t duration_per_job[CPU_COUNT]; + uint32_t rtemsuptime_per_job[CPU_COUNT]; +} timecounter_context; + +static timecounter_context test_instance; + +static rtems_interval test_duration(void) +{ + return DURATION_IN_SECONDS * rtems_clock_get_ticks_per_second(); +} + +static uint32_t test_get_timecount_null(struct timecounter *tc) +{ + return 0; +} + +static void install_tc_null(timecounter_context *ctx) +{ + struct timecounter *tc_cpu = &ctx->tc_null; + + tc_cpu->tc_get_timecount = test_get_timecount_null; + tc_cpu->tc_counter_mask = 0xffffffff; + tc_cpu->tc_frequency = rtems_counter_nanoseconds_to_ticks(1000000000); + tc_cpu->tc_quality = 2000; + rtems_timecounter_install(tc_cpu); +} + +static rtems_interval test_bintime_init( + rtems_test_parallel_context *base, + void *arg, + size_t active_workers +) +{ + rtems_test_spin_until_next_tick(); + + return test_duration(); +} + +static void test_bintime_body( + rtems_test_parallel_context *base, + void *arg, + size_t active_workers, + size_t worker_index +) +{ + timecounter_context *ctx = (timecounter_context *) base; + uint32_t counter = 1; + struct bintime start; + struct bintime end; + + rtems_bsd_binuptime(&start); + + do { + ++counter; + rtems_bsd_binuptime(&end); + } while (!rtems_test_parallel_stop_job(&ctx->base)); + + ctx->binuptime_per_job[worker_index] = counter; + ctx->duration_per_job[worker_index] = bttosbt(end) - bttosbt(start); +} + +static void test_bintime_fini( + rtems_test_parallel_context *base, + void *arg, + size_t active_workers +) +{ + timecounter_context *ctx = (timecounter_context *) base; + size_t i; + + printf(" <BinuptimeTest activeWorker=\"%zu\">\n", active_workers); + + for (i = 0; i < active_workers; ++i) { + sbintime_t error; + + printf( + " <Counter worker=\"%zu\">%" PRIu32 "</Counter>\n" + " <Duration worker=\"%zu\" unit=\"sbintime\">%" PRId64 "</Duration>\n", + i + 1, + ctx->binuptime_per_job[i], + i + 1, + ctx->duration_per_job[i] + ); + + error = DURATION_IN_SECONDS * SBT_1S - ctx->duration_per_job[i]; + rtems_test_assert(error * error < SBT_1MS * SBT_1MS); + } + + printf(" </BinuptimeTest>\n"); +} + +static rtems_interval test_bintime_null_init( + rtems_test_parallel_context *base, + void *arg, + size_t active_workers +) +{ + timecounter_context *ctx = &test_instance; + + install_tc_null(ctx); + + return test_duration(); +} + +static void test_bintime_null_body( + rtems_test_parallel_context *base, + void *arg, + size_t active_workers, + size_t worker_index +) +{ + timecounter_context *ctx = (timecounter_context *) base; + struct bintime bt; + uint32_t counter = 0; + + while (!rtems_test_parallel_stop_job(&ctx->base)) { + ++counter; + rtems_bsd_binuptime(&bt); + } + + ctx->binuptime_per_job[worker_index] = counter; +} + +static void test_bintime_null_fini( + rtems_test_parallel_context *base, + void *arg, + size_t active_workers +) +{ + timecounter_context *ctx = (timecounter_context *) base; + size_t i; + + printf(" <BinuptimeNullTest activeWorker=\"%zu\">\n", active_workers); + + for (i = 0; i < active_workers; ++i) { + printf( + " <Counter worker=\"%zu\">%" PRIu32 "</Counter>\n", + i + 1, + ctx->binuptime_per_job[i] + ); + } + + printf(" </BinuptimeNullTest>\n"); +} + +static const rtems_test_parallel_job timecounter_jobs[] = { + { + .init = test_bintime_init, + .body = test_bintime_body, + .fini = test_bintime_fini, + .cascade = true + },{ + .init = test_bintime_null_init, + .body = test_bintime_null_body, + .fini = test_bintime_null_fini, + .cascade = true + } +}; + +static void Init(rtems_task_argument arg) +{ + timecounter_context *ctx = &test_instance; + struct bintime bt; + struct timespec ts; + struct timeval tv; + + TEST_BEGIN(); + + printf("<SPTimecounter01>\n"); + + rtems_test_parallel( + &ctx->base, + NULL, + &timecounter_jobs[0], + RTEMS_ARRAY_SIZE(timecounter_jobs) + ); + + /* Check for all functions available in the bsd.h user space */ + + rtems_bsd_bintime(&bt); + rtems_bsd_microtime(&tv); + rtems_bsd_nanotime(&ts); + rtems_bsd_binuptime(&bt); + rtems_bsd_microuptime(&tv); + rtems_bsd_nanouptime(&ts); + rtems_bsd_getbintime(&bt); + rtems_bsd_getmicrotime(&tv); + rtems_bsd_getnanotime(&ts); + rtems_bsd_getbinuptime(&bt); + rtems_bsd_getmicrouptime(&tv); + rtems_bsd_getnanouptime(&ts); + + printf("</SPTimecounter01>\n"); + + TEST_END(); + rtems_test_exit(0); +} + +#define CONFIGURE_MICROSECONDS_PER_TICK 1000 + +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER + +#define CONFIGURE_MAXIMUM_TASKS (2 + CPU_COUNT - 1) +#define CONFIGURE_MAXIMUM_TIMERS 2 +#define CONFIGURE_MAXIMUM_PERIODS 1 + +#define CONFIGURE_SMP_APPLICATION + +#define CONFIGURE_SMP_MAXIMUM_PROCESSORS CPU_COUNT + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION + +#define CONFIGURE_INIT + +#include <rtems/confdefs.h> diff --git a/testsuites/sptests/sptimecounter02/sptimecounter02.doc b/testsuites/sptests/sptimecounter02/sptimecounter02.doc new file mode 100644 index 0000000000..9988ad067c --- /dev/null +++ b/testsuites/sptests/sptimecounter02/sptimecounter02.doc @@ -0,0 +1,12 @@ +This file describes the directives and concepts tested by this test set. + +test set name: sptimecounter02 + +directives: + + rtems_timecounter_install, rtems_bsd_binuptime. + +concepts: + + measurement of performance tests: how often per timeframe can FreeBSD time + routines be called in comparison to original rtems timing routines. diff --git a/testsuites/sptests/sptimecounter02/sptimecounter02.scn b/testsuites/sptests/sptimecounter02/sptimecounter02.scn new file mode 100644 index 0000000000..004c50e416 --- /dev/null +++ b/testsuites/sptests/sptimecounter02/sptimecounter02.scn @@ -0,0 +1,46 @@ +*** BEGIN OF TEST SPTIMECOUNTER_2 *** +<SPTimecounter01> + <BinuptimeTest activeWorker="1"> + <Counter worker="1">591457</Counter> + <Duration worker="1" unit="sbintime">4294787862</Duration> + <BinuptimeTest activeWorker="2"> + <Counter worker="1">587737</Counter> + <Duration worker="1" unit="sbintime">4294603178</Duration> + <Counter worker="2">587754</Counter> + <Duration worker="2" unit="sbintime">4294596307</Duration> + <BinuptimeTest activeWorker="3"> + <Counter worker="1">583602</Counter> + <Duration worker="1" unit="sbintime">4293605982</Duration> + <Counter worker="2">583643</Counter> + <Duration worker="2" unit="sbintime">4293602260</Duration> + <Counter worker="3">583659</Counter> + <Duration worker="3" unit="sbintime">4293604551</Duration> + <BinuptimeTest activeWorker="4"> + <Counter worker="1">583086</Counter> + <Duration worker="1" unit="sbintime">4291246232</Duration> + <Counter worker="2">583124</Counter> + <Duration worker="2" unit="sbintime">4291243178</Duration> + <Counter worker="3">583139</Counter> + <Duration worker="3" unit="sbintime">4291242796</Duration> + <Counter worker="4">565417</Counter> + <Duration worker="4" unit="sbintime">4291304930</Duration> + <BinuptimeNullTest activeWorker="1"> + <Counter worker="1">615571</Counter> + </BinuptimeNullTest> + <BinuptimeNullTest activeWorker="2"> + <Counter worker="1">615857</Counter> + <Counter worker="2">615856</Counter> + </BinuptimeNullTest> + <BinuptimeNullTest activeWorker="3"> + <Counter worker="1">615316</Counter> + <Counter worker="2">615328</Counter> + <Counter worker="3">615337</Counter> + </BinuptimeNullTest> + <BinuptimeNullTest activeWorker="4"> + <Counter worker="1">615495</Counter> + <Counter worker="2">615502</Counter> + <Counter worker="3">615509</Counter> + <Counter worker="4">597117</Counter> + </BinuptimeNullTest> +</SPTimecounter01> +*** END OF TEST SPTIMECOUNTER_2 *** diff --git a/testsuites/sptests/spwatchdog/init.c b/testsuites/sptests/spwatchdog/init.c index 1d3cb2f9dd..283f4c87a0 100644 --- a/testsuites/sptests/spwatchdog/init.c +++ b/testsuites/sptests/spwatchdog/init.c @@ -34,6 +34,119 @@ static void test_watchdog_routine( Objects_Id id, void *arg ) rtems_test_assert( 0 ); } +static void init_watchdogs( + Watchdog_Header *header, + Watchdog_Control watchdogs[3] +) +{ + Watchdog_Control *a = &watchdogs[0]; + Watchdog_Control *b = &watchdogs[1]; + Watchdog_Control *c = &watchdogs[2]; + Watchdog_Control *d = &watchdogs[3]; + + _Watchdog_Header_initialize( header ); + rtems_test_assert( _Watchdog_Is_empty( header ) ); + rtems_test_assert( _Chain_Is_empty( &header->Iterators ) ); + + _Watchdog_Initialize( c, NULL, 0, NULL ); + c->initial = 6; + _Watchdog_Insert( header, c ); + rtems_test_assert( c->delta_interval == 6 ); + + rtems_test_assert( !_Watchdog_Is_empty( header ) ); + rtems_test_assert( _Chain_Is_empty( &header->Iterators ) ); + + _Watchdog_Initialize( a, NULL, 0, NULL ); + a->initial = 2; + _Watchdog_Insert( header, a ); + rtems_test_assert( a->delta_interval == 2 ); + rtems_test_assert( c->delta_interval == 4 ); + + _Watchdog_Initialize( b, NULL, 0, NULL ); + b->initial = 4; + _Watchdog_Insert( header, b ); + rtems_test_assert( a->delta_interval == 2 ); + rtems_test_assert( b->delta_interval == 2 ); + rtems_test_assert( c->delta_interval == 2 ); + + _Watchdog_Initialize( d, NULL, 0, NULL ); +} + +static void destroy_watchdogs( + Watchdog_Header *header +) +{ + _ISR_lock_Destroy( &header->Lock ); +} + +static void add_iterator( + Watchdog_Header *header, + Watchdog_Iterator *i, + Watchdog_Control *w +) +{ + _Chain_Append_unprotected( &header->Iterators, &i->Node ); + i->delta_interval = 2; + i->current = &w->Node; +} + +static void test_watchdog_insert_and_remove( void ) +{ + Watchdog_Header header; + Watchdog_Control watchdogs[4]; + Watchdog_Control *a = &watchdogs[0]; + Watchdog_Control *b = &watchdogs[1]; + Watchdog_Control *c = &watchdogs[2]; + Watchdog_Control *d = &watchdogs[3]; + Watchdog_Iterator i; + + init_watchdogs( &header, watchdogs ); + add_iterator( &header, &i, c ); + + /* Remove next watchdog of iterator */ + _Watchdog_Remove( &header, c ); + rtems_test_assert( i.delta_interval == 2 ); + rtems_test_assert( i.current == &b->Node ); + + /* Remove watchdog before the current watchdog of iterator */ + _Watchdog_Remove( &header, a ); + rtems_test_assert( i.delta_interval == 4 ); + rtems_test_assert( i.current == &b->Node ); + + /* Remove current (= last) watchdog of iterator */ + _Watchdog_Remove( &header, b ); + rtems_test_assert( i.delta_interval == 4 ); + rtems_test_assert( i.current == _Chain_Head( &header.Watchdogs ) ); + + /* Insert first watchdog */ + a->initial = 1; + _Watchdog_Insert( &header, a ); + rtems_test_assert( i.delta_interval == 4 ); + rtems_test_assert( i.current == _Chain_Head( &header.Watchdogs ) ); + + destroy_watchdogs( &header ); + init_watchdogs( &header, watchdogs ); + add_iterator( &header, &i, b ); + + /* Insert right before current watchdog of iterator */ + d->initial = 3; + _Watchdog_Insert( &header, d ); + rtems_test_assert( i.delta_interval == 1 ); + rtems_test_assert( i.current == &b->Node ); + + destroy_watchdogs( &header ); + init_watchdogs( &header, watchdogs ); + add_iterator( &header, &i, b ); + + /* Insert right after current watchdog of iterator */ + d->initial = 5; + _Watchdog_Insert( &header, d ); + rtems_test_assert( i.delta_interval == 2 ); + rtems_test_assert( i.current == &b->Node ); + + destroy_watchdogs( &header ); +} + static void test_watchdog_static_init( void ) { #if defined(RTEMS_USE_16_BIT_OBJECT) @@ -70,6 +183,7 @@ rtems_task Init( TEST_BEGIN(); test_watchdog_static_init(); + test_watchdog_insert_and_remove(); build_time( &time, 12, 31, 1988, 9, 0, 0, 0 ); |