summaryrefslogtreecommitdiffstats
path: root/testsuites/sptests
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-02-18 08:36:26 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-03-04 13:36:10 +0100
commit03b900d3ed120ea919ea3eded7edbece3488cff3 (patch)
tree182781fc14fe15fd67caeb80e46f1c58495839c2 /testsuites/sptests
parentscore: Distribute clock tick to all online CPUs (diff)
downloadrtems-03b900d3ed120ea919ea3eded7edbece3488cff3.tar.bz2
score: Replace watchdog handler implementation
Use a red-black tree instead of delta chains. Close #2344. Update #2554. Update #2555. Close #2606.
Diffstat (limited to 'testsuites/sptests')
-rw-r--r--testsuites/sptests/Makefile.am3
-rw-r--r--testsuites/sptests/configure.ac2
-rw-r--r--testsuites/sptests/sp31/task1.c22
-rw-r--r--testsuites/sptests/spintrcritical08/init.c26
-rw-r--r--testsuites/sptests/spintrcritical09/init.c27
-rw-r--r--testsuites/sptests/spintrcritical10/init.c6
-rw-r--r--testsuites/sptests/spintrcritical16/init.c2
-rw-r--r--testsuites/sptests/spintrcritical17/Makefile.am25
-rw-r--r--testsuites/sptests/spintrcritical17/init.c118
-rw-r--r--testsuites/sptests/spintrcritical17/spintrcritical17.doc18
-rw-r--r--testsuites/sptests/spintrcritical17/spintrcritical17.scn2
-rw-r--r--testsuites/sptests/spintrcritical20/init.c2
-rw-r--r--testsuites/sptests/spsize/size.c2
-rw-r--r--testsuites/sptests/sptimecounter01/init.c3
-rw-r--r--testsuites/sptests/sptimerserver01/Makefile.am19
-rw-r--r--testsuites/sptests/sptimerserver01/init.c129
-rw-r--r--testsuites/sptests/sptimerserver01/sptimerserver01.doc12
-rw-r--r--testsuites/sptests/sptimerserver01/sptimerserver01.scn2
-rw-r--r--testsuites/sptests/spwatchdog/init.c381
19 files changed, 360 insertions, 441 deletions
diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index c5210a5ab9..43f3d82794 100644
--- a/testsuites/sptests/Makefile.am
+++ b/testsuites/sptests/Makefile.am
@@ -25,7 +25,7 @@ _SUBDIRS = \
spintrcritical05 spintrcritical06 spintrcritical07 spintrcritical08 \
spintrcritical09 spintrcritical10 spintrcritical11 spintrcritical12 \
spintrcritical13 spintrcritical14 spintrcritical15 spintrcritical16 \
- spintrcritical17 spintrcritical18 spmkdir spmountmgr01 spheapprot \
+ spintrcritical18 spmkdir spmountmgr01 spheapprot \
sppagesize spsem01 spsem02 spsimplesched01 spsimplesched02 \
spsimplesched03 spnsext01 spedfsched01 spedfsched02 spedfsched03 \
spcbssched01 spcbssched02 spcbssched03 spqreslib sptimespec01 \
@@ -77,6 +77,7 @@ _SUBDIRS += speventsystem01
_SUBDIRS += spinternalerror01
_SUBDIRS += spinternalerror02
_SUBDIRS += sptimer_err01 sptimer_err02
+_SUBDIRS += sptimerserver01
_SUBDIRS += spclock_err02
if HAS_CPUSET
diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac
index e46f6fa5a5..eeebc91171 100644
--- a/testsuites/sptests/configure.ac
+++ b/testsuites/sptests/configure.ac
@@ -46,6 +46,7 @@ AM_CONDITIONAL(HAS_SMP,test "$rtems_cv_RTEMS_SMP" = "yes")
# Explicitly list all Makefiles here
AC_CONFIG_FILES([Makefile
+sptimerserver01/Makefile
spsysinit01/Makefile
splinkersets01/Makefile
spstdthreads01/Makefile
@@ -216,7 +217,6 @@ spintrcritical13/Makefile
spintrcritical14/Makefile
spintrcritical15/Makefile
spintrcritical16/Makefile
-spintrcritical17/Makefile
spheapprot/Makefile
spmkdir/Makefile
spmountmgr01/Makefile
diff --git a/testsuites/sptests/sp31/task1.c b/testsuites/sptests/sp31/task1.c
index f4e526a027..c3f0ae13fc 100644
--- a/testsuites/sptests/sp31/task1.c
+++ b/testsuites/sptests/sp31/task1.c
@@ -40,14 +40,6 @@ static rtems_timer_service_routine Do_nothing(
/* Do nothing */
}
-static Watchdog_Interval schedule_time( void )
-{
- const Watchdog_Control *watchdog =
- &_Timer_server->Interval_watchdogs.System_watchdog;
-
- return watchdog->initial + watchdog->start_time;
-}
-
rtems_task Task_1(
rtems_task_argument argument
)
@@ -119,10 +111,6 @@ rtems_task Task_1(
"Timer 1 scheduled for %" PRIdWatchdog_Interval " ticks since boot\n",
info.start_time + info.initial
);
- printf(
- "Timer Server scheduled for %" PRIdWatchdog_Interval " ticks since boot\n",
- schedule_time()
- );
puts( "TA1 - rtems_task_wake_after - 1 second" );
status = rtems_task_wake_after( 1 * rtems_clock_get_ticks_per_second() );
@@ -139,11 +127,6 @@ rtems_task Task_1(
"Timer 1 scheduled for %" PRIdWatchdog_Interval " ticks since boot\n",
info.start_time + info.initial
);
- printf(
- "Timer Server scheduled for %" PRIdWatchdog_Interval " ticks since boot\n",
- schedule_time()
- );
- rtems_test_assert( (info.start_time + info.initial) == schedule_time() );
puts( "TA1 - rtems_task_wake_after - 1 second" );
status = rtems_task_wake_after( 1 * rtems_clock_get_ticks_per_second() );
@@ -160,11 +143,6 @@ rtems_task Task_1(
"Timer 1 scheduled for %" PRIdWatchdog_Interval " ticks since boot\n",
info.start_time + info.initial
);
- printf(
- "Timer Server scheduled for %" PRIdWatchdog_Interval " ticks since boot\n",
- schedule_time()
- );
- rtems_test_assert( (info.start_time + info.initial) == schedule_time() );
puts( "TA1 - rtems_timer_cancel - timer 1" );
status = rtems_timer_cancel( tmid );
diff --git a/testsuites/sptests/spintrcritical08/init.c b/testsuites/sptests/spintrcritical08/init.c
index f375cd49f3..3610e65b96 100644
--- a/testsuites/sptests/spintrcritical08/init.c
+++ b/testsuites/sptests/spintrcritical08/init.c
@@ -46,23 +46,21 @@ static rtems_timer_service_routine test_release_from_isr(
void *arg
)
{
- Watchdog_Header *header = &_Watchdog_Ticks_header;
+ Per_CPU_Control *cpu = _Per_CPU_Get();
+ Watchdog_Header *header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ];
+ Watchdog_Control *watchdog = (Watchdog_Control *) header->first;
- if ( !_Watchdog_Is_empty( header ) ) {
- Watchdog_Control *watchdog = _Watchdog_First( header );
+ if (
+ watchdog != NULL
+ && watchdog->expire == cpu->Watchdog.ticks
+ && watchdog->routine == _Rate_monotonic_Timeout
+ ) {
+ _Watchdog_Per_CPU_remove_relative( watchdog );
- if (
- watchdog->delta_interval == 0
- && watchdog->routine == _Rate_monotonic_Timeout
- ) {
- Watchdog_States state = _Watchdog_Remove_ticks( watchdog );
+ (*watchdog->routine)( watchdog );
- rtems_test_assert( state == WATCHDOG_ACTIVE );
- (*watchdog->routine)( watchdog->id, watchdog->user_data );
-
- if ( getState() == RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING ) {
- case_hit = true;
- }
+ if ( getState() == RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING ) {
+ case_hit = true;
}
}
}
diff --git a/testsuites/sptests/spintrcritical09/init.c b/testsuites/sptests/spintrcritical09/init.c
index cc119e88c1..44eccc7821 100644
--- a/testsuites/sptests/spintrcritical09/init.c
+++ b/testsuites/sptests/spintrcritical09/init.c
@@ -15,6 +15,7 @@
#include <intrcritical.h>
#include <rtems/score/threadimpl.h>
+#include <rtems/score/threadimpl.h>
#include <rtems/score/watchdogimpl.h>
const char rtems_test_name[] = "SPINTRCRITICAL 9";
@@ -37,23 +38,21 @@ static rtems_timer_service_routine test_release_from_isr(
void *arg
)
{
- Watchdog_Header *header = &_Watchdog_Ticks_header;
-
- if ( !_Watchdog_Is_empty( header ) ) {
- Watchdog_Control *watchdog = _Watchdog_First( header );
+ Per_CPU_Control *cpu_self = _Per_CPU_Get();
+ Watchdog_Header *header = &cpu_self->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ];
+ Watchdog_Control *watchdog = (Watchdog_Control *) header->first;
- if (
- watchdog->delta_interval == 0
- && watchdog->routine == _Thread_Timeout
- ) {
- Watchdog_States state = _Watchdog_Remove_ticks( watchdog );
+ if (
+ watchdog != NULL
+ && watchdog->expire == cpu_self->Watchdog.ticks
+ && watchdog->routine == _Thread_Timeout
+ ) {
+ _Watchdog_Per_CPU_remove( watchdog, cpu_self, header );
- rtems_test_assert( state == WATCHDOG_ACTIVE );
- (*watchdog->routine)( watchdog->id, watchdog->user_data );
+ (*watchdog->routine)( watchdog );
- if ( is_interrupt_timeout() ) {
- case_hit = true;
- }
+ if ( is_interrupt_timeout() ) {
+ case_hit = true;
}
}
}
diff --git a/testsuites/sptests/spintrcritical10/init.c b/testsuites/sptests/spintrcritical10/init.c
index e4a2a940a6..25be23a852 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);
- _Thread_Timeout(0, thread);
+ _Thread_Timeout(&thread->Timer.Watchdog);
rtems_test_assert(
*(rtems_event_set *) thread->Wait.return_argument == GREEN
@@ -175,7 +175,7 @@ static void all_satisfy_before_timeout(rtems_id timer, void *arg)
);
rtems_test_assert(thread->Wait.return_code == RTEMS_SUCCESSFUL);
- _Thread_Timeout(0, thread);
+ _Thread_Timeout(&thread->Timer.Watchdog);
rtems_test_assert(
*(rtems_event_set *) thread->Wait.return_argument == EVENTS
@@ -251,7 +251,7 @@ static void timeout_before_satisfied(rtems_id timer, void *arg)
);
rtems_test_assert(thread->Wait.return_code == RTEMS_SUCCESSFUL);
- _Thread_Timeout(0, thread);
+ _Thread_Timeout(&thread->Timer.Watchdog);
rtems_test_assert(
*(rtems_event_set *) thread->Wait.return_argument == DEADBEEF
diff --git a/testsuites/sptests/spintrcritical16/init.c b/testsuites/sptests/spintrcritical16/init.c
index a094b419b3..3657c0607f 100644
--- a/testsuites/sptests/spintrcritical16/init.c
+++ b/testsuites/sptests/spintrcritical16/init.c
@@ -43,7 +43,7 @@ static rtems_timer_service_routine test_release_from_isr(
}
if ( Main_TCB->Wait.queue != NULL ) {
- _Thread_Timeout( 0, Main_TCB );
+ _Thread_Timeout( &Main_TCB->Timer.Watchdog );
}
}
diff --git a/testsuites/sptests/spintrcritical17/Makefile.am b/testsuites/sptests/spintrcritical17/Makefile.am
deleted file mode 100644
index 20b372cf48..0000000000
--- a/testsuites/sptests/spintrcritical17/Makefile.am
+++ /dev/null
@@ -1,25 +0,0 @@
-
-rtems_tests_PROGRAMS = spintrcritical17
-spintrcritical17_SOURCES = init.c \
- ../spintrcritical_support/intrcritical.c
-spintrcritical17_SOURCES += ../spintrcritical_support/intrcritical.h
-
-dist_rtems_tests_DATA = spintrcritical17.scn
-dist_rtems_tests_DATA += spintrcritical17.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
-AM_CPPFLAGS += -I$(top_srcdir)/spintrcritical_support
-
-LINK_OBJS = $(spintrcritical17_OBJECTS)
-LINK_LIBS = $(spintrcritical17_LDLIBS)
-
-spintrcritical17$(EXEEXT): $(spintrcritical17_OBJECTS) $(spintrcritical17_DEPENDENCIES)
- @rm -f spintrcritical17$(EXEEXT)
- $(make-exe)
-
-include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/spintrcritical17/init.c b/testsuites/sptests/spintrcritical17/init.c
deleted file mode 100644
index 238493e71a..0000000000
--- a/testsuites/sptests/spintrcritical17/init.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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
- * http://www.rtems.org/license/LICENSE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <tmacros.h>
-#include <intrcritical.h>
-
-#include <rtems/rtems/timerimpl.h>
-
-const char rtems_test_name[] = "SPINTRCRITICAL 17";
-
-typedef struct {
- rtems_id timer1;
- rtems_id timer2;
- bool done;
-} test_context;
-
-static test_context ctx_instance;
-
-static void never(rtems_id timer_id, void *arg)
-{
- rtems_test_assert(0);
-}
-
-static void fire(rtems_id timer_id, void *arg)
-{
- /* 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 bool test_body(void *arg)
-{
- test_context *ctx = arg;
- rtems_status_code sc;
-
- sc = rtems_timer_reset(ctx->timer1);
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
-
- return ctx->done;
-}
-
-static void Init(rtems_task_argument ignored)
-{
- test_context *ctx = &ctx_instance;
- rtems_status_code sc;
-
- TEST_BEGIN();
-
- sc = rtems_timer_create(
- rtems_build_name('T', 'I', 'M', '1'),
- &ctx->timer1
- );
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
-
- 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
- );
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
-
- sc = rtems_timer_server_fire_after(ctx->timer1, 1000, never, NULL);
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
-
- interrupt_critical_section_test(test_body, ctx, fire);
- rtems_test_assert(ctx->done);
-
- TEST_END();
- rtems_test_exit(0);
-}
-
-#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
-#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
-
-#define CONFIGURE_MICROSECONDS_PER_TICK 1000
-
-#define CONFIGURE_MAXIMUM_TASKS 2
-#define CONFIGURE_MAXIMUM_TIMERS 3
-#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
-
-#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
-
-#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
-
-#define CONFIGURE_INIT
-
-#include <rtems/confdefs.h>
diff --git a/testsuites/sptests/spintrcritical17/spintrcritical17.doc b/testsuites/sptests/spintrcritical17/spintrcritical17.doc
deleted file mode 100644
index 809a9669d6..0000000000
--- a/testsuites/sptests/spintrcritical17/spintrcritical17.doc
+++ /dev/null
@@ -1,18 +0,0 @@
-# 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
-# http://www.rtems.org/license/LICENSE.
-#
-
-This file describes the directives and concepts tested by this test set.
-
-test set name: spintrcritical17
-
-directives:
-
- _Timer_server_Update_system_watchdog
-
-concepts:
-
-+ Test critical sections which are only accessible through an interrupt.
diff --git a/testsuites/sptests/spintrcritical17/spintrcritical17.scn b/testsuites/sptests/spintrcritical17/spintrcritical17.scn
deleted file mode 100644
index 14566dfb3d..0000000000
--- a/testsuites/sptests/spintrcritical17/spintrcritical17.scn
+++ /dev/null
@@ -1,2 +0,0 @@
-*** TEST INTERRUPT CRITICAL SECTION 17 ***
-*** END OF INTERRUPT CRITICAL SECTION 17 ***
diff --git a/testsuites/sptests/spintrcritical20/init.c b/testsuites/sptests/spintrcritical20/init.c
index 7e52211742..85c1645b5c 100644
--- a/testsuites/sptests/spintrcritical20/init.c
+++ b/testsuites/sptests/spintrcritical20/init.c
@@ -91,7 +91,7 @@ static bool test_body(void *arg)
ctx->thread_queue_was_null = true;
}
- _Thread_Timeout(0, ctx->semaphore_task_tcb);
+ _Thread_Timeout(&ctx->semaphore_task_tcb->Timer.Watchdog);
switch (ctx->semaphore_task_tcb->Wait.return_code) {
case CORE_SEMAPHORE_STATUS_SUCCESSFUL:
diff --git a/testsuites/sptests/spsize/size.c b/testsuites/sptests/spsize/size.c
index e9470e384d..e19ca99606 100644
--- a/testsuites/sptests/spsize/size.c
+++ b/testsuites/sptests/spsize/size.c
@@ -391,8 +391,6 @@ uninitialized =
/*userext.h*/ (sizeof _User_extensions_List) +
/*watchdog.h*/ (sizeof _Watchdog_Ticks_since_boot) +
- (sizeof _Watchdog_Ticks_header) +
- (sizeof _Watchdog_Seconds_header) +
/*wkspace.h*/ (sizeof _Workspace_Area);
diff --git a/testsuites/sptests/sptimecounter01/init.c b/testsuites/sptests/sptimecounter01/init.c
index 7b31064f54..d87ffec460 100644
--- a/testsuites/sptests/sptimecounter01/init.c
+++ b/testsuites/sptests/sptimecounter01/init.c
@@ -24,7 +24,6 @@
#include <rtems/score/timecounterimpl.h>
#include <rtems/score/todimpl.h>
-#include <rtems/score/watchdogimpl.h>
#include <rtems/timecounter.h>
#include <rtems/bsd.h>
@@ -57,8 +56,6 @@ void boot_card(const char *cmdline)
rtems_test_begink();
- _Watchdog_Handler_initialization();
-
assert(time(NULL) == TOD_SECONDS_1970_THROUGH_1988);
rtems_bsd_bintime(&bt);
diff --git a/testsuites/sptests/sptimerserver01/Makefile.am b/testsuites/sptests/sptimerserver01/Makefile.am
new file mode 100644
index 0000000000..2e5048d4e3
--- /dev/null
+++ b/testsuites/sptests/sptimerserver01/Makefile.am
@@ -0,0 +1,19 @@
+rtems_tests_PROGRAMS = sptimerserver01
+sptimerserver01_SOURCES = init.c
+
+dist_rtems_tests_DATA = sptimerserver01.scn sptimerserver01.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 = $(sptimerserver01_OBJECTS)
+LINK_LIBS = $(sptimerserver01_LDLIBS)
+
+sptimerserver01$(EXEEXT): $(sptimerserver01_OBJECTS) $(sptimerserver01_DEPENDENCIES)
+ @rm -f sptimerserver01$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/sptimerserver01/init.c b/testsuites/sptests/sptimerserver01/init.c
new file mode 100644
index 0000000000..88f1fb3cf3
--- /dev/null
+++ b/testsuites/sptests/sptimerserver01/init.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2016 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 "tmacros.h"
+
+const char rtems_test_name[] = "SPTIMERSERVER 1";
+
+#define TIMER_COUNT 2
+
+typedef struct {
+ rtems_id timer[TIMER_COUNT];
+ rtems_id master;
+} test_context;
+
+static test_context ctx_instance;
+
+static const rtems_time_of_day start = {
+ .year = 2016,
+ .month = 3,
+ .day = 1,
+ .hour = 12,
+ .minute = 5,
+ .second = 17
+};
+
+static void cancel(rtems_id id, void *arg)
+{
+ test_context *ctx = arg;
+ rtems_status_code sc;
+
+ sc = rtems_timer_cancel(ctx->timer[1]);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ sc = rtems_event_transient_send(ctx->master);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+}
+
+static void never(rtems_id id, void *arg)
+{
+ rtems_test_assert(0);
+}
+
+static void test(void)
+{
+ test_context *ctx = &ctx_instance;
+ rtems_status_code sc;
+ size_t i;
+ rtems_time_of_day later;
+
+ ctx->master = rtems_task_self();
+
+ sc = rtems_timer_initiate_server(
+ RTEMS_MINIMUM_PRIORITY,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_ATTRIBUTES
+ );
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ for (i = 0; i < TIMER_COUNT; ++i) {
+ sc = rtems_timer_create(
+ rtems_build_name('T', 'M', 'R', '0' + i),
+ &ctx->timer[i]
+ );
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+ }
+
+ sc = rtems_timer_server_fire_after(ctx->timer[0], 10, cancel, ctx);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ sc = rtems_timer_server_fire_after(ctx->timer[1], 10, never, NULL);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ sc = rtems_event_transient_receive(RTEMS_WAIT, RTEMS_NO_TIMEOUT);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ sc = rtems_clock_set(&start);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ later = start;
+ ++later.second;
+
+ sc = rtems_timer_server_fire_when(ctx->timer[0], &later, cancel, ctx);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ sc = rtems_timer_server_fire_when(ctx->timer[1], &later, never, NULL);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ sc = rtems_event_transient_receive(RTEMS_WAIT, RTEMS_NO_TIMEOUT);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+}
+
+static void Init(rtems_task_argument arg)
+{
+ TEST_BEGIN();
+
+ test();
+
+ TEST_END();
+ rtems_test_exit(0);
+}
+
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_MAXIMUM_TASKS 2
+#define CONFIGURE_MAXIMUM_TIMERS TIMER_COUNT
+
+#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_INIT
+
+#include <rtems/confdefs.h>
diff --git a/testsuites/sptests/sptimerserver01/sptimerserver01.doc b/testsuites/sptests/sptimerserver01/sptimerserver01.doc
new file mode 100644
index 0000000000..c0dc4ef578
--- /dev/null
+++ b/testsuites/sptests/sptimerserver01/sptimerserver01.doc
@@ -0,0 +1,12 @@
+This file describes the directives and concepts tested by this test set.
+
+test set name: sptimerserver01
+
+directives:
+
+ - rtems_timer_cancel()
+
+concepts:
+
+ - Ensure that pending timer server timers are cancelled via
+ rtems_timer_cancel().
diff --git a/testsuites/sptests/sptimerserver01/sptimerserver01.scn b/testsuites/sptests/sptimerserver01/sptimerserver01.scn
new file mode 100644
index 0000000000..315f030c94
--- /dev/null
+++ b/testsuites/sptests/sptimerserver01/sptimerserver01.scn
@@ -0,0 +1,2 @@
+*** BEGIN OF TEST SPTIMERSERVER 1 ***
+*** END OF TEST SPTIMERSERVER 1 ***
diff --git a/testsuites/sptests/spwatchdog/init.c b/testsuites/sptests/spwatchdog/init.c
index 025295b45b..3b08fb57e5 100644
--- a/testsuites/sptests/spwatchdog/init.c
+++ b/testsuites/sptests/spwatchdog/init.c
@@ -26,241 +26,192 @@
const char rtems_test_name[] = "SPWATCHDOG";
-static void test_watchdog_routine( Objects_Id id, void *arg )
-{
- (void) id;
- (void) arg;
-
- rtems_test_assert( 0 );
-}
+typedef struct {
+ Watchdog_Control Base;
+ int counter;
+} test_watchdog;
-static void init_watchdogs(
- Watchdog_Header *header,
- Watchdog_Control watchdogs[4]
-)
+static void test_watchdog_routine( Watchdog_Control *base )
{
- 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_Preinitialize( c );
- 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_Preinitialize( a );
- a->initial = 2;
- _Watchdog_Insert( header, a );
- rtems_test_assert( a->delta_interval == 2 );
- rtems_test_assert( c->delta_interval == 4 );
-
- _Watchdog_Preinitialize( b );
- 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_Preinitialize( d );
-}
+ test_watchdog *watchdog = (test_watchdog *) base;
-static void destroy_watchdogs(
- Watchdog_Header *header
-)
-{
- _ISR_lock_Destroy( &header->Lock );
+ ++watchdog->counter;
}
-static void add_iterator(
- Watchdog_Header *header,
- Watchdog_Iterator *i,
- Watchdog_Control *w
-)
+static void test_watchdog_static_init( void )
{
- _Chain_Append_unprotected( &header->Iterators, &i->Node );
- i->delta_interval = 2;
- i->current = &w->Node;
-}
+ static Watchdog_Control a = WATCHDOG_INITIALIZER(
+ test_watchdog_routine
+ );
+ Watchdog_Control b;
-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 == 4 );
- 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 == 6 );
- rtems_test_assert( i.current == &b->Node );
-
- /* Remove current (= last) watchdog of iterator */
- _Watchdog_Remove( &header, b );
- rtems_test_assert( i.delta_interval == 6 );
- 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 == 6 );
- 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 == 2 );
- rtems_test_assert( i.current == &d->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 );
+ memset( &b, 0, sizeof( b ) );
+ _Watchdog_Preinitialize( &b, _Per_CPU_Get_by_index( 0 ) );
+ _Watchdog_Initialize(
+ &b,
+ test_watchdog_routine
+ );
+
+ rtems_test_assert( memcmp( &a, &b, sizeof( a ) ) == 0 );
}
-static void init_watchdogs_remove_second_and_insert_first(
- Watchdog_Header *header,
- Watchdog_Control watchdogs[3]
-)
+static bool test_watchdog_is_inactive( test_watchdog *watchdog )
{
- Watchdog_Control *a = &watchdogs[0];
- Watchdog_Control *b = &watchdogs[1];
- Watchdog_Control *c = &watchdogs[2];
-
- _Watchdog_Preinitialize( a );
- _Watchdog_Preinitialize( b );
- _Watchdog_Preinitialize( c );
-
- _Watchdog_Header_initialize( header );
-
- a->initial = 6;
- _Watchdog_Insert( header, a );
- rtems_test_assert( a->delta_interval == 6 );
-
- b->initial = 8;
- _Watchdog_Insert( header, b );
- rtems_test_assert( a->delta_interval == 6 );
- rtems_test_assert( b->delta_interval == 2 );
+ return _Watchdog_Get_state( &watchdog->Base ) == WATCHDOG_INACTIVE;
}
-static void test_watchdog_remove_second_and_insert_first( void )
+static void test_watchdog_init( test_watchdog *watchdog, int counter )
{
- Watchdog_Header header;
- Watchdog_Control watchdogs[3];
- Watchdog_Control *a = &watchdogs[0];
- Watchdog_Control *b = &watchdogs[1];
- Watchdog_Control *c = &watchdogs[2];
- Watchdog_Iterator i;
-
- init_watchdogs_remove_second_and_insert_first( &header, watchdogs );
- add_iterator( &header, &i, b );
-
- _Watchdog_Remove( &header, b );
- rtems_test_assert( i.delta_interval == 8 );
- rtems_test_assert( i.current == &a->Node );
-
- c->initial = 4;
- _Watchdog_Insert( &header, c );
- rtems_test_assert( a->delta_interval == 2 );
- rtems_test_assert( c->delta_interval == 4 );
- rtems_test_assert( i.delta_interval == 8 );
- rtems_test_assert( i.current == &c->Node );
-
- destroy_watchdogs( &header );
+ _Watchdog_Preinitialize( &watchdog->Base, _Per_CPU_Get_snapshot() );
+ _Watchdog_Initialize( &watchdog->Base, test_watchdog_routine );
+ rtems_test_assert( test_watchdog_is_inactive( watchdog ) ) ;
+ watchdog->counter = counter;
}
-static void init_watchdogs_insert_with_iterator(
- Watchdog_Header *header,
- Watchdog_Control watchdogs[2]
-)
+static uint64_t test_watchdog_tick( Watchdog_Header *header, uint64_t now )
{
- Watchdog_Control *a = &watchdogs[0];
- Watchdog_Control *b = &watchdogs[1];
+ ISR_LOCK_DEFINE( , lock, "Test" )
+ ISR_lock_Context lock_context;
- _Watchdog_Preinitialize( a );
- _Watchdog_Preinitialize( b );
+ _ISR_lock_ISR_disable_and_acquire( &lock, &lock_context );
+ ++now;
+ _Watchdog_Tickle( header, now, &lock, &lock_context );
+ _ISR_lock_Destroy( &lock );
- _Watchdog_Header_initialize( header );
-
- a->initial = 6;
- _Watchdog_Insert( header, a );
- rtems_test_assert( a->delta_interval == 6 );
+ return now;
}
-static void test_watchdog_insert_with_iterator( void )
+static void test_watchdog_operations( void )
{
Watchdog_Header header;
- Watchdog_Control watchdogs[2];
- Watchdog_Control *a = &watchdogs[0];
- Watchdog_Control *b = &watchdogs[1];
- Watchdog_Iterator i;
-
- init_watchdogs_insert_with_iterator( &header, watchdogs );
- add_iterator( &header, &i, a );
-
- b->initial = 4;
- _Watchdog_Insert( &header, b );
- rtems_test_assert( a->delta_interval == 2 );
- rtems_test_assert( b->delta_interval == 4 );
- 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)
- #define JUNK_ID 0x1234
- #else
- #define JUNK_ID 0x12345678
- #endif
-
- static Watchdog_Control a = WATCHDOG_INITIALIZER(
- test_watchdog_routine,
- JUNK_ID,
- (void *) 0xdeadbeef
- );
- Watchdog_Control b;
-
- memset( &b, 0, sizeof( b ) );
- _Watchdog_Initialize(
- &b,
- test_watchdog_routine,
- JUNK_ID,
- (void *) 0xdeadbeef
- );
-
- rtems_test_assert( memcmp( &a, &b, sizeof( a ) ) == 0 );
+ uint64_t now;
+ test_watchdog a;
+ test_watchdog b;
+ test_watchdog c;
+
+ _Watchdog_Header_initialize( &header );
+ rtems_test_assert( _RBTree_Is_empty( &header.Watchdogs ) );
+ rtems_test_assert( header.first == NULL );
+
+ test_watchdog_init( &a, 10 );
+ test_watchdog_init( &b, 20 );
+ test_watchdog_init( &c, 30 );
+
+ now = 0;
+ now = test_watchdog_tick( &header, now );
+
+ _Watchdog_Insert( &header, &a.Base, now + 1 );
+ rtems_test_assert( header.first == &a.Base.Node.RBTree );
+ rtems_test_assert( !test_watchdog_is_inactive( &a ) ) ;
+ rtems_test_assert( a.Base.expire == 2 );
+ rtems_test_assert( a.counter == 10 );
+
+ _Watchdog_Remove( &header, &a.Base );
+ rtems_test_assert( header.first == NULL );
+ rtems_test_assert( test_watchdog_is_inactive( &a ) ) ;
+ rtems_test_assert( a.Base.expire == 2 );
+ rtems_test_assert( a.counter == 10 );
+
+ _Watchdog_Remove( &header, &a.Base );
+ rtems_test_assert( header.first == NULL );
+ rtems_test_assert( test_watchdog_is_inactive( &a ) ) ;
+ rtems_test_assert( a.Base.expire == 2 );
+ rtems_test_assert( a.counter == 10 );
+
+ _Watchdog_Insert( &header, &a.Base, now + 1 );
+ rtems_test_assert( header.first == &a.Base.Node.RBTree );
+ rtems_test_assert( !test_watchdog_is_inactive( &a ) ) ;
+ rtems_test_assert( a.Base.expire == 2 );
+ rtems_test_assert( a.counter == 10 );
+
+ _Watchdog_Insert( &header, &b.Base, now + 1 );
+ rtems_test_assert( header.first == &a.Base.Node.RBTree );
+ rtems_test_assert( !test_watchdog_is_inactive( &b ) ) ;
+ rtems_test_assert( b.Base.expire == 2 );
+ rtems_test_assert( b.counter == 20 );
+
+ _Watchdog_Insert( &header, &c.Base, now + 2 );
+ rtems_test_assert( header.first == &a.Base.Node.RBTree );
+ rtems_test_assert( !test_watchdog_is_inactive( &c ) ) ;
+ rtems_test_assert( c.Base.expire == 3 );
+ rtems_test_assert( c.counter == 30 );
+
+ _Watchdog_Remove( &header, &a.Base );
+ rtems_test_assert( header.first == &b.Base.Node.RBTree );
+ rtems_test_assert( test_watchdog_is_inactive( &a ) ) ;
+ rtems_test_assert( a.Base.expire == 2 );
+ rtems_test_assert( a.counter == 10 );
+
+ _Watchdog_Remove( &header, &b.Base );
+ rtems_test_assert( header.first == &c.Base.Node.RBTree );
+ rtems_test_assert( test_watchdog_is_inactive( &b ) ) ;
+ rtems_test_assert( b.Base.expire == 2 );
+ rtems_test_assert( b.counter == 20 );
+
+ _Watchdog_Remove( &header, &c.Base );
+ rtems_test_assert( header.first == NULL );
+ rtems_test_assert( test_watchdog_is_inactive( &c ) ) ;
+ rtems_test_assert( c.Base.expire == 3 );
+ rtems_test_assert( c.counter == 30 );
+
+ _Watchdog_Insert( &header, &a.Base, now + 2 );
+ rtems_test_assert( header.first == &a.Base.Node.RBTree );
+ rtems_test_assert( !test_watchdog_is_inactive( &a ) ) ;
+ rtems_test_assert( a.Base.expire == 3 );
+ rtems_test_assert( a.counter == 10 );
+
+ _Watchdog_Insert( &header, &b.Base, now + 2 );
+ rtems_test_assert( header.first == &a.Base.Node.RBTree );
+ rtems_test_assert( !test_watchdog_is_inactive( &b ) ) ;
+ rtems_test_assert( b.Base.expire == 3 );
+ rtems_test_assert( b.counter == 20 );
+
+ _Watchdog_Insert( &header, &c.Base, now + 3 );
+ rtems_test_assert( header.first == &a.Base.Node.RBTree );
+ rtems_test_assert( !test_watchdog_is_inactive( &c ) ) ;
+ rtems_test_assert( c.Base.expire == 4 );
+ rtems_test_assert( c.counter == 30 );
+
+ now = test_watchdog_tick( &header, now );
+ rtems_test_assert( !_RBTree_Is_empty( &header.Watchdogs ) );
+ rtems_test_assert( header.first == &a.Base.Node.RBTree );
+ rtems_test_assert( !test_watchdog_is_inactive( &a ) ) ;
+ rtems_test_assert( a.Base.expire == 3 );
+ rtems_test_assert( a.counter == 10 );
+ rtems_test_assert( !test_watchdog_is_inactive( &b ) ) ;
+ rtems_test_assert( b.Base.expire == 3 );
+ rtems_test_assert( b.counter == 20 );
+ rtems_test_assert( !test_watchdog_is_inactive( &c ) ) ;
+ rtems_test_assert( c.Base.expire == 4 );
+ rtems_test_assert( c.counter == 30 );
+
+ now = test_watchdog_tick( &header, now );
+ rtems_test_assert( !_RBTree_Is_empty( &header.Watchdogs ) );
+ rtems_test_assert( header.first == &c.Base.Node.RBTree );
+ rtems_test_assert( test_watchdog_is_inactive( &a ) ) ;
+ rtems_test_assert( a.Base.expire == 3 );
+ rtems_test_assert( a.counter == 11 );
+ rtems_test_assert( test_watchdog_is_inactive( &b ) ) ;
+ rtems_test_assert( b.Base.expire == 3 );
+ rtems_test_assert( b.counter == 21 );
+ rtems_test_assert( !test_watchdog_is_inactive( &c ) ) ;
+ rtems_test_assert( c.Base.expire == 4 );
+ rtems_test_assert( c.counter == 30 );
+
+ now = test_watchdog_tick( &header, now );
+ rtems_test_assert( _RBTree_Is_empty( &header.Watchdogs ) );
+ rtems_test_assert( header.first == NULL );
+ rtems_test_assert( test_watchdog_is_inactive( &a ) ) ;
+ rtems_test_assert( a.Base.expire == 3 );
+ rtems_test_assert( a.counter == 11 );
+ rtems_test_assert( test_watchdog_is_inactive( &b ) ) ;
+ rtems_test_assert( b.Base.expire == 3 );
+ rtems_test_assert( b.counter == 21 );
+ rtems_test_assert( test_watchdog_is_inactive( &c ) ) ;
+ rtems_test_assert( c.Base.expire == 4 );
+ rtems_test_assert( c.counter == 31 );
+
+ _Watchdog_Header_destroy( &header );
}
rtems_task Init(
@@ -272,10 +223,8 @@ rtems_task Init(
TEST_BEGIN();
+ test_watchdog_operations();
test_watchdog_static_init();
- test_watchdog_insert_and_remove();
- test_watchdog_remove_second_and_insert_first();
- test_watchdog_insert_with_iterator();
build_time( &time, 12, 31, 1988, 9, 0, 0, 0 );