diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-03-17 10:12:14 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-03-31 08:29:43 +0200 |
commit | 5c731a83485ce3e7a6b6556e7a38b92d10a98cd6 (patch) | |
tree | bee44daeabdb237541a911283651f43c91b1c049 /testsuites/smptests | |
parent | score: Delete post-switch API extensions (diff) | |
download | rtems-5c731a83485ce3e7a6b6556e7a38b92d10a98cd6.tar.bz2 |
score: Use thread action for thread restart
The thread restart is now supported on SMP. New test
smptests/smpthreadlife01.
Diffstat (limited to 'testsuites/smptests')
-rw-r--r-- | testsuites/smptests/Makefile.am | 1 | ||||
-rw-r--r-- | testsuites/smptests/configure.ac | 1 | ||||
-rw-r--r-- | testsuites/smptests/smpthreadlife01/Makefile.am | 19 | ||||
-rw-r--r-- | testsuites/smptests/smpthreadlife01/init.c | 122 | ||||
-rw-r--r-- | testsuites/smptests/smpthreadlife01/smpthreadlife01.doc | 11 | ||||
-rw-r--r-- | testsuites/smptests/smpthreadlife01/smpthreadlife01.scn | 2 | ||||
-rw-r--r-- | testsuites/smptests/smpunsupported01/init.c | 25 |
7 files changed, 157 insertions, 24 deletions
diff --git a/testsuites/smptests/Makefile.am b/testsuites/smptests/Makefile.am index c7fa0286ab..dddd7abe3a 100644 --- a/testsuites/smptests/Makefile.am +++ b/testsuites/smptests/Makefile.am @@ -21,6 +21,7 @@ SUBDIRS += smpmigration01 SUBDIRS += smpschedule01 SUBDIRS += smpsignal01 SUBDIRS += smpswitchextension01 +SUBDIRS += smpthreadlife01 SUBDIRS += smpunsupported01 if HAS_POSIX SUBDIRS += smppsxaffinity01 diff --git a/testsuites/smptests/configure.ac b/testsuites/smptests/configure.ac index 0d08f0db1a..b7bd8d2259 100644 --- a/testsuites/smptests/configure.ac +++ b/testsuites/smptests/configure.ac @@ -78,6 +78,7 @@ smppsxsignal01/Makefile smpschedule01/Makefile smpsignal01/Makefile smpswitchextension01/Makefile +smpthreadlife01/Makefile smpunsupported01/Makefile ]) AC_OUTPUT diff --git a/testsuites/smptests/smpthreadlife01/Makefile.am b/testsuites/smptests/smpthreadlife01/Makefile.am new file mode 100644 index 0000000000..02b5bd542f --- /dev/null +++ b/testsuites/smptests/smpthreadlife01/Makefile.am @@ -0,0 +1,19 @@ +rtems_tests_PROGRAMS = smpthreadlife01 +smpthreadlife01_SOURCES = init.c + +dist_rtems_tests_DATA = smpthreadlife01.scn smpthreadlife01.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 = $(smpthreadlife01_OBJECTS) +LINK_LIBS = $(smpthreadlife01_LDLIBS) + +smpthreadlife01$(EXEEXT): $(smpthreadlife01_OBJECTS) $(smpthreadlife01_DEPENDENCIES) + @rm -f smpthreadlife01$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/smptests/smpthreadlife01/init.c b/testsuites/smptests/smpthreadlife01/init.c new file mode 100644 index 0000000000..ee36068c73 --- /dev/null +++ b/testsuites/smptests/smpthreadlife01/init.c @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2014 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" + +#include <rtems.h> +#include <rtems/score/smpbarrier.h> + +const char rtems_test_name[] = "SMPTHREADLIFE 1"; + +#define CPU_COUNT 2 + +typedef struct { + volatile rtems_task_argument main_arg; + volatile rtems_task_argument worker_arg; + SMP_barrier_Control barrier; + SMP_barrier_State worker_barrier_state; +} test_context; + +static test_context test_instance = { + .barrier = SMP_BARRIER_CONTROL_INITIALIZER, + .worker_barrier_state = SMP_BARRIER_STATE_INITIALIZER +}; + +static void worker_task(rtems_task_argument arg) +{ + test_context *ctx = &test_instance; + + rtems_test_assert(arg == ctx->main_arg); + + ctx->worker_arg = arg; + + _SMP_barrier_Wait(&ctx->barrier, &ctx->worker_barrier_state, CPU_COUNT); + + while (true) { + /* Do nothing */ + } +} + +static void test(void) +{ + test_context *ctx = &test_instance; + SMP_barrier_State barrier_state = SMP_BARRIER_STATE_INITIALIZER; + rtems_status_code sc; + rtems_id id; + rtems_task_argument arg; + + sc = rtems_task_create( + rtems_build_name('W', 'O', 'R', 'K'), + 1, + RTEMS_MINIMUM_STACK_SIZE, + RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, + &id + ); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + + sc = rtems_task_start(id, worker_task, 0); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + + _SMP_barrier_Wait( + &ctx->barrier, + &barrier_state, + CPU_COUNT + ); + + for (arg = 1; arg < 23; ++arg) { + ctx->main_arg = arg; + ctx->worker_arg = 0; + + sc = rtems_task_restart(id, arg); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + + _SMP_barrier_Wait(&ctx->barrier, &barrier_state, CPU_COUNT); + + rtems_test_assert(ctx->worker_arg == arg); + } +} + +static void Init(rtems_task_argument arg) +{ + TEST_BEGIN(); + + if (rtems_smp_get_processor_count() >= CPU_COUNT) { + test(); + } + + TEST_END(); + rtems_test_exit(0); +} + +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER + +#define CONFIGURE_SMP_APPLICATION + +#define CONFIGURE_SMP_MAXIMUM_PROCESSORS CPU_COUNT + +#define CONFIGURE_MAXIMUM_TASKS CPU_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/smptests/smpthreadlife01/smpthreadlife01.doc b/testsuites/smptests/smpthreadlife01/smpthreadlife01.doc new file mode 100644 index 0000000000..f6205677a4 --- /dev/null +++ b/testsuites/smptests/smpthreadlife01/smpthreadlife01.doc @@ -0,0 +1,11 @@ +This file describes the directives and concepts tested by this test set. + +test set name: smprestart01 + +directives: + + - rtems_task_restart() + +concepts: + + - Ensure that a restart of a task executing on another processor works. diff --git a/testsuites/smptests/smpthreadlife01/smpthreadlife01.scn b/testsuites/smptests/smpthreadlife01/smpthreadlife01.scn new file mode 100644 index 0000000000..7b4de1b8ec --- /dev/null +++ b/testsuites/smptests/smpthreadlife01/smpthreadlife01.scn @@ -0,0 +1,2 @@ +*** BEGIN OF TEST SMPTHREADLIFE 1 *** +*** END OF TEST SMPTHREADLIFE 1 *** diff --git a/testsuites/smptests/smpunsupported01/init.c b/testsuites/smptests/smpunsupported01/init.c index a2ffbed168..ffa40137aa 100644 --- a/testsuites/smptests/smpunsupported01/init.c +++ b/testsuites/smptests/smpunsupported01/init.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 embedded brains GmbH. All rights reserved. + * Copyright (c) 2013-2014 embedded brains GmbH. All rights reserved. * * embedded brains GmbH * Dornierstr. 4 @@ -20,13 +20,6 @@ const char rtems_test_name[] = "SMPUNSUPPORTED 1"; -static void some_task(rtems_task_argument arg) -{ - (void) arg; - - while (1); -} - static void test(void) { rtems_status_code sc; @@ -59,22 +52,6 @@ static void test(void) &id ); rtems_test_assert(sc == RTEMS_UNSATISFIED); - - sc = rtems_task_create( - rtems_build_name('T', 'A', 'S', 'K'), - RTEMS_MAXIMUM_PRIORITY, - RTEMS_MINIMUM_STACK_SIZE, - RTEMS_DEFAULT_MODES, - RTEMS_DEFAULT_ATTRIBUTES, - &id - ); - rtems_test_assert(sc == RTEMS_SUCCESSFUL); - - sc = rtems_task_start(id, some_task, 0); - rtems_test_assert(sc == RTEMS_SUCCESSFUL); - - sc = rtems_task_restart(id, 0); - rtems_test_assert(sc == RTEMS_INCORRECT_STATE); } static void Init(rtems_task_argument arg) |