diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-05-07 10:14:55 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-05-10 12:10:14 +0200 |
commit | 39993d6d7693b9fd26d729efd199cc605cd2ae65 (patch) | |
tree | d06b29ef4cd1d68223c25e9de9069b445bf4aed1 /testsuites | |
parent | arm: Add FUNCTION_THUMB_ENTRY(), etc. (diff) | |
download | rtems-39993d6d7693b9fd26d729efd199cc605cd2ae65.tar.bz2 |
score: Add CPU context validation
Diffstat (limited to 'testsuites')
-rw-r--r-- | testsuites/sptests/Makefile.am | 1 | ||||
-rw-r--r-- | testsuites/sptests/configure.ac | 1 | ||||
-rw-r--r-- | testsuites/sptests/spcontext01/Makefile.am | 19 | ||||
-rw-r--r-- | testsuites/sptests/spcontext01/init.c | 188 | ||||
-rw-r--r-- | testsuites/sptests/spcontext01/spcontext01.doc | 11 | ||||
-rw-r--r-- | testsuites/sptests/spcontext01/spcontext01.scn | 2 |
6 files changed, 222 insertions, 0 deletions
diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am index c9d20dd5ab..4b0fff68fd 100644 --- a/testsuites/sptests/Makefile.am +++ b/testsuites/sptests/Makefile.am @@ -30,6 +30,7 @@ SUBDIRS = \ spcbssched01 spcbssched02 spcbssched03 spqreslib sptimespec01 \ spatomic01 spatomic02 spatomic03 spatomic04 spatomic05 \ spatomic06 spatomic07 +SUBDIRS += spcontext01 SUBDIRS += spfatal26 SUBDIRS += speventtransient01 SUBDIRS += speventsystem01 diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac index a43a1ad2c7..ba3aa920aa 100644 --- a/testsuites/sptests/configure.ac +++ b/testsuites/sptests/configure.ac @@ -27,6 +27,7 @@ AC_CHECK_SIZEOF([time_t]) # Explicitly list all Makefiles here AC_CONFIG_FILES([Makefile +spcontext01/Makefile spfatal26/Makefile spinternalerror02/Makefile spinternalerror01/Makefile diff --git a/testsuites/sptests/spcontext01/Makefile.am b/testsuites/sptests/spcontext01/Makefile.am new file mode 100644 index 0000000000..b1c7de2e6c --- /dev/null +++ b/testsuites/sptests/spcontext01/Makefile.am @@ -0,0 +1,19 @@ +rtems_tests_PROGRAMS = spcontext01 +spcontext01_SOURCES = init.c + +dist_rtems_tests_DATA = spcontext01.scn spcontext01.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 = $(spcontext01_OBJECTS) +LINK_LIBS = $(spcontext01_LDLIBS) + +spcontext01$(EXEEXT): $(spcontext01_OBJECTS) $(spcontext01_DEPENDENCIES) + @rm -f spcontext01$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/sptests/spcontext01/init.c b/testsuites/sptests/spcontext01/init.c new file mode 100644 index 0000000000..f9c1803b30 --- /dev/null +++ b/testsuites/sptests/spcontext01/init.c @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2013 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.com/license/LICENSE. + */ + +#ifdef HAVE_CONFIG_H + #include "config.h" +#endif + +#include "tmacros.h" + +#define ITERATION_COUNT 2000 + +#define PRIORITY_HIGH 2 + +#define PRIORITY_LOW 3 + +#define FINISH_EVENT RTEMS_EVENT_0 + +typedef struct { + rtems_id control_task; + rtems_id validate_tasks[2]; + size_t task_index; + int iteration_counter; +} test_context; + +static test_context test_instance; + +static void validate_task(rtems_task_argument arg) +{ + _CPU_Context_validate(arg); + rtems_test_assert(0); +} + +static void start_validate_task( + rtems_id *id, + uintptr_t pattern, + rtems_task_priority priority +) +{ + rtems_status_code sc; + + sc = rtems_task_create( + rtems_build_name('V', 'A', 'L', 'I'), + priority, + RTEMS_MINIMUM_STACK_SIZE, + RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, + id + ); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + + sc = rtems_task_start(*id, validate_task, pattern); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); +} + +static void reset_timer_or_finish(test_context *self, rtems_id timer) +{ + rtems_status_code sc; + int i = self->iteration_counter; + + if (i < ITERATION_COUNT) { + self->iteration_counter = i + 1; + + sc = rtems_timer_reset(timer); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + } else { + sc = rtems_event_send(self->control_task, FINISH_EVENT); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + } +} + +static void switch_priorities(test_context *self) +{ + rtems_status_code sc; + size_t index = self->task_index; + size_t next = (index + 1) & 0x1; + size_t task_high = index; + size_t task_low = next; + rtems_task_priority priority; + + self->task_index = next; + + sc = rtems_task_set_priority( + self->validate_tasks[task_high], + PRIORITY_HIGH, + &priority + ); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + + sc = rtems_task_set_priority( + self->validate_tasks[task_low], + PRIORITY_LOW, + &priority + ); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); +} + +static void clobber_and_switch_timer(rtems_id timer, void *arg) +{ + uintptr_t pattern = (uintptr_t) 0xffffffffffffffffU; + test_context *self = arg; + + reset_timer_or_finish(self, timer); + switch_priorities(self); + + _CPU_Context_volatile_clobber(pattern); +} + +static void start_timer(test_context *self) +{ + rtems_status_code sc; + rtems_id timer; + + sc = rtems_timer_create(rtems_build_name('C', 'L', 'S', 'W'), &timer); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + + sc = rtems_timer_fire_after(timer, 2, clobber_and_switch_timer, self); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); +} + +static void wait_for_finish(void) +{ + rtems_status_code sc; + rtems_event_set out; + + sc = rtems_event_receive( + FINISH_EVENT, + RTEMS_WAIT | RTEMS_EVENT_ALL, + RTEMS_NO_TIMEOUT, + &out + ); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + rtems_test_assert(out == FINISH_EVENT); +} + +static void test(test_context *self) +{ + uintptr_t pattern_0 = (uintptr_t) 0xaaaaaaaaaaaaaaaaU; + uintptr_t pattern_1 = (uintptr_t) 0x5555555555555555U; + + memset(self, 0, sizeof(*self)); + + self->control_task = rtems_task_self(); + + start_validate_task(&self->validate_tasks[0], pattern_0, PRIORITY_LOW); + start_validate_task(&self->validate_tasks[1], pattern_1, PRIORITY_HIGH); + start_timer(self); + wait_for_finish(); +} + +static void Init(rtems_task_argument arg) +{ + test_context *self = &test_instance; + + puts("\n\n*** TEST SPCONTEXT 1 ***"); + + test(self); + + puts("*** END OF TEST SPCONTEXT 1 ***"); + + rtems_test_exit(0); +} + +#define CONFIGURE_MICROSECONDS_PER_TICK 1000 + +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER + +#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM + +#define CONFIGURE_MAXIMUM_TASKS 3 +#define CONFIGURE_MAXIMUM_TIMERS 1 + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INIT + +#include <rtems/confdefs.h> diff --git a/testsuites/sptests/spcontext01/spcontext01.doc b/testsuites/sptests/spcontext01/spcontext01.doc new file mode 100644 index 0000000000..2c2c4cfb5d --- /dev/null +++ b/testsuites/sptests/spcontext01/spcontext01.doc @@ -0,0 +1,11 @@ +This file describes the directives and concepts tested by this test set. + +test set name: spcontext01 + +directives: + + TBD + +concepts: + + - Ensure the context switching and interrupt processing works diff --git a/testsuites/sptests/spcontext01/spcontext01.scn b/testsuites/sptests/spcontext01/spcontext01.scn new file mode 100644 index 0000000000..b7b823b5a0 --- /dev/null +++ b/testsuites/sptests/spcontext01/spcontext01.scn @@ -0,0 +1,2 @@ +*** TEST SPCONTEXT 1 *** +*** END OF TEST SPCONTEXT 1 *** |