From c3cd7e7b7b55489f45ec0e53eb1d5765aecfb199 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 9 Apr 2014 15:26:17 +0200 Subject: smptests/smpschedule01: Rename in smpscheduler01 --- testsuites/smptests/Makefile.am | 2 +- testsuites/smptests/configure.ac | 2 +- testsuites/smptests/smpschedule01/Makefile.am | 19 -- testsuites/smptests/smpschedule01/init.c | 212 --------------------- .../smptests/smpschedule01/smpschedule01.doc | 14 -- .../smptests/smpschedule01/smpschedule01.scn | 2 - testsuites/smptests/smpscheduler01/Makefile.am | 19 ++ testsuites/smptests/smpscheduler01/init.c | 212 +++++++++++++++++++++ .../smptests/smpscheduler01/smpscheduler01.doc | 14 ++ .../smptests/smpscheduler01/smpscheduler01.scn | 2 + 10 files changed, 249 insertions(+), 249 deletions(-) delete mode 100644 testsuites/smptests/smpschedule01/Makefile.am delete mode 100644 testsuites/smptests/smpschedule01/init.c delete mode 100644 testsuites/smptests/smpschedule01/smpschedule01.doc delete mode 100644 testsuites/smptests/smpschedule01/smpschedule01.scn create mode 100644 testsuites/smptests/smpscheduler01/Makefile.am create mode 100644 testsuites/smptests/smpscheduler01/init.c create mode 100644 testsuites/smptests/smpscheduler01/smpscheduler01.doc create mode 100644 testsuites/smptests/smpscheduler01/smpscheduler01.scn diff --git a/testsuites/smptests/Makefile.am b/testsuites/smptests/Makefile.am index dddd7abe3a..82f5322eb4 100644 --- a/testsuites/smptests/Makefile.am +++ b/testsuites/smptests/Makefile.am @@ -18,7 +18,7 @@ SUBDIRS += smpfatal02 SUBDIRS += smpfatal03 SUBDIRS += smplock01 SUBDIRS += smpmigration01 -SUBDIRS += smpschedule01 +SUBDIRS += smpscheduler01 SUBDIRS += smpsignal01 SUBDIRS += smpswitchextension01 SUBDIRS += smpthreadlife01 diff --git a/testsuites/smptests/configure.ac b/testsuites/smptests/configure.ac index b7bd8d2259..97b825bccc 100644 --- a/testsuites/smptests/configure.ac +++ b/testsuites/smptests/configure.ac @@ -75,7 +75,7 @@ smpmigration01/Makefile smppsxaffinity01/Makefile smppsxaffinity02/Makefile smppsxsignal01/Makefile -smpschedule01/Makefile +smpscheduler01/Makefile smpsignal01/Makefile smpswitchextension01/Makefile smpthreadlife01/Makefile diff --git a/testsuites/smptests/smpschedule01/Makefile.am b/testsuites/smptests/smpschedule01/Makefile.am deleted file mode 100644 index bd1db04d64..0000000000 --- a/testsuites/smptests/smpschedule01/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -rtems_tests_PROGRAMS = smpschedule01 -smpschedule01_SOURCES = init.c - -dist_rtems_tests_DATA = smpschedule01.scn smpschedule01.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 = $(smpschedule01_OBJECTS) -LINK_LIBS = $(smpschedule01_LDLIBS) - -smpschedule01$(EXEEXT): $(smpschedule01_OBJECTS) $(smpschedule01_DEPENDENCIES) - @rm -f smpschedule01$(EXEEXT) - $(make-exe) - -include $(top_srcdir)/../automake/local.am diff --git a/testsuites/smptests/smpschedule01/init.c b/testsuites/smptests/smpschedule01/init.c deleted file mode 100644 index f44f9290a2..0000000000 --- a/testsuites/smptests/smpschedule01/init.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (c) 2013 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * 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 - -#include "tmacros.h" - -const char rtems_test_name[] = "SMPSCHEDULE 1"; - -#define CPU_COUNT 2 - -#define TASK_COUNT 4 - -#define FIRST_TASK_PRIORITY 1 - -#define SECOND_TASK_READY RTEMS_EVENT_0 - -static rtems_id task_ids[TASK_COUNT]; - -static void suspend(size_t i) -{ - rtems_status_code sc = rtems_task_suspend(task_ids[i]); - rtems_test_assert(sc == RTEMS_SUCCESSFUL); -} - -static void resume(size_t i) -{ - rtems_status_code sc = rtems_task_resume(task_ids[i]); - rtems_test_assert(sc == RTEMS_SUCCESSFUL); -} - -static void task(rtems_task_argument arg) -{ - rtems_task_priority task_priority; - rtems_status_code sc; - - sc = rtems_task_set_priority( - RTEMS_SELF, - RTEMS_CURRENT_PRIORITY, - &task_priority - ); - rtems_test_assert(sc == RTEMS_SUCCESSFUL); - - if (arg == 1) { - sc = rtems_event_send(task_ids[0], SECOND_TASK_READY); - rtems_test_assert(sc == RTEMS_SUCCESSFUL); - } - - while (true) { - /* Do nothing */ - } -} - -static bool is_per_cpu_state_ok(void) -{ - bool ok = true; - uint32_t n = rtems_smp_get_processor_count(); - uint32_t i; - - for (i = 0; i < n; ++i) { - const Thread_Control *thread = _Per_CPU_Get_by_index(i)->executing; - uint32_t count = 0; - uint32_t j; - - for (j = 0; j < n; ++j) { - const Per_CPU_Control *cpu = _Per_CPU_Get_by_index(j); - const Thread_Control *executing = cpu->executing; - const Thread_Control *heir = cpu->heir; - - if (i != j) { - count += executing == thread; - count += heir == thread; - } else { - ++count; - } - - ok = ok && executing->cpu == cpu; - ok = ok && heir->cpu == cpu; - } - - ok = ok && (count == 1); - } - - return ok; -} - -static void test_scheduler_cross(void) -{ - bool per_cpu_state_ok; - - _Thread_Disable_dispatch(); - - suspend(0); - suspend(1); - resume(0); - resume(1); - - per_cpu_state_ok = is_per_cpu_state_ok(); - - _Thread_Enable_dispatch(); - - rtems_test_assert(per_cpu_state_ok); -} - -static void test_scheduler_move_heir(void) -{ - bool per_cpu_state_ok; - - _Thread_Disable_dispatch(); - - suspend(2); - suspend(3); - suspend(0); - resume(2); - suspend(1); - resume(3); - resume(0); - - per_cpu_state_ok = is_per_cpu_state_ok(); - - resume(1); - - _Thread_Enable_dispatch(); - - rtems_test_assert(per_cpu_state_ok); -} - -static void test(void) -{ - rtems_event_set events; - rtems_status_code sc; - rtems_task_argument task_index; - - task_ids[0] = rtems_task_self(); - - for (task_index = 1; task_index < TASK_COUNT; ++task_index) { - rtems_id task_id; - - sc = rtems_task_create( - rtems_build_name('T', 'A', 'S', 'K'), - FIRST_TASK_PRIORITY + task_index, - RTEMS_MINIMUM_STACK_SIZE, - RTEMS_DEFAULT_MODES, - RTEMS_DEFAULT_ATTRIBUTES, - &task_id - ); - rtems_test_assert(sc == RTEMS_SUCCESSFUL); - - sc = rtems_task_start(task_id, task, task_index); - rtems_test_assert(sc == RTEMS_SUCCESSFUL); - - task_ids[task_index] = task_id; - } - - sc = rtems_event_receive( - SECOND_TASK_READY, - RTEMS_EVENT_ALL | RTEMS_WAIT, - RTEMS_NO_TIMEOUT, - &events - ); - rtems_test_assert(sc == RTEMS_SUCCESSFUL); - rtems_test_assert(events == SECOND_TASK_READY); - - test_scheduler_cross(); - test_scheduler_move_heir(); -} - -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_SMP_APPLICATION - -#define CONFIGURE_SMP_MAXIMUM_PROCESSORS CPU_COUNT - -#define CONFIGURE_MAXIMUM_TASKS TASK_COUNT - -#define CONFIGURE_INIT_TASK_PRIORITY FIRST_TASK_PRIORITY -#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_DEFAULT_MODES -#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_DEFAULT_ATTRIBUTES - -#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION - -#define CONFIGURE_RTEMS_INIT_TASKS_TABLE - -#define CONFIGURE_INIT - -#include diff --git a/testsuites/smptests/smpschedule01/smpschedule01.doc b/testsuites/smptests/smpschedule01/smpschedule01.doc deleted file mode 100644 index 9727d4f515..0000000000 --- a/testsuites/smptests/smpschedule01/smpschedule01.doc +++ /dev/null @@ -1,14 +0,0 @@ -This file describes the directives and concepts tested by this test set. - -test set name: smpschedule01 - -directives: - - - _Scheduler_simple_smp_Enqueue_priority_fifo - - _Scheduler_simple_smp_Enqueue_priority_lifo - - _Scheduler_simple_smp_Extract - -concepts: - - - Ensure that the per-processor state is consistent after a sequence of - scheduling events. diff --git a/testsuites/smptests/smpschedule01/smpschedule01.scn b/testsuites/smptests/smpschedule01/smpschedule01.scn deleted file mode 100644 index e290a64706..0000000000 --- a/testsuites/smptests/smpschedule01/smpschedule01.scn +++ /dev/null @@ -1,2 +0,0 @@ -*** TEST SMPSCHEDULE 1 *** -*** END OF TEST SMPSCHEDULE 1 *** diff --git a/testsuites/smptests/smpscheduler01/Makefile.am b/testsuites/smptests/smpscheduler01/Makefile.am new file mode 100644 index 0000000000..aacdf2170c --- /dev/null +++ b/testsuites/smptests/smpscheduler01/Makefile.am @@ -0,0 +1,19 @@ +rtems_tests_PROGRAMS = smpscheduler01 +smpscheduler01_SOURCES = init.c + +dist_rtems_tests_DATA = smpscheduler01.scn smpscheduler01.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 = $(smpscheduler01_OBJECTS) +LINK_LIBS = $(smpscheduler01_LDLIBS) + +smpscheduler01$(EXEEXT): $(smpscheduler01_OBJECTS) $(smpscheduler01_DEPENDENCIES) + @rm -f smpscheduler01$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/smptests/smpscheduler01/init.c b/testsuites/smptests/smpscheduler01/init.c new file mode 100644 index 0000000000..a0d37602b3 --- /dev/null +++ b/testsuites/smptests/smpscheduler01/init.c @@ -0,0 +1,212 @@ +/* + * Copyright (c) 2013 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * 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 + +#include "tmacros.h" + +const char rtems_test_name[] = "SMPSCHEDULER 1"; + +#define CPU_COUNT 2 + +#define TASK_COUNT 4 + +#define FIRST_TASK_PRIORITY 1 + +#define SECOND_TASK_READY RTEMS_EVENT_0 + +static rtems_id task_ids[TASK_COUNT]; + +static void suspend(size_t i) +{ + rtems_status_code sc = rtems_task_suspend(task_ids[i]); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); +} + +static void resume(size_t i) +{ + rtems_status_code sc = rtems_task_resume(task_ids[i]); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); +} + +static void task(rtems_task_argument arg) +{ + rtems_task_priority task_priority; + rtems_status_code sc; + + sc = rtems_task_set_priority( + RTEMS_SELF, + RTEMS_CURRENT_PRIORITY, + &task_priority + ); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + + if (arg == 1) { + sc = rtems_event_send(task_ids[0], SECOND_TASK_READY); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + } + + while (true) { + /* Do nothing */ + } +} + +static bool is_per_cpu_state_ok(void) +{ + bool ok = true; + uint32_t n = rtems_smp_get_processor_count(); + uint32_t i; + + for (i = 0; i < n; ++i) { + const Thread_Control *thread = _Per_CPU_Get_by_index(i)->executing; + uint32_t count = 0; + uint32_t j; + + for (j = 0; j < n; ++j) { + const Per_CPU_Control *cpu = _Per_CPU_Get_by_index(j); + const Thread_Control *executing = cpu->executing; + const Thread_Control *heir = cpu->heir; + + if (i != j) { + count += executing == thread; + count += heir == thread; + } else { + ++count; + } + + ok = ok && executing->cpu == cpu; + ok = ok && heir->cpu == cpu; + } + + ok = ok && (count == 1); + } + + return ok; +} + +static void test_scheduler_cross(void) +{ + bool per_cpu_state_ok; + + _Thread_Disable_dispatch(); + + suspend(0); + suspend(1); + resume(0); + resume(1); + + per_cpu_state_ok = is_per_cpu_state_ok(); + + _Thread_Enable_dispatch(); + + rtems_test_assert(per_cpu_state_ok); +} + +static void test_scheduler_move_heir(void) +{ + bool per_cpu_state_ok; + + _Thread_Disable_dispatch(); + + suspend(2); + suspend(3); + suspend(0); + resume(2); + suspend(1); + resume(3); + resume(0); + + per_cpu_state_ok = is_per_cpu_state_ok(); + + resume(1); + + _Thread_Enable_dispatch(); + + rtems_test_assert(per_cpu_state_ok); +} + +static void test(void) +{ + rtems_event_set events; + rtems_status_code sc; + rtems_task_argument task_index; + + task_ids[0] = rtems_task_self(); + + for (task_index = 1; task_index < TASK_COUNT; ++task_index) { + rtems_id task_id; + + sc = rtems_task_create( + rtems_build_name('T', 'A', 'S', 'K'), + FIRST_TASK_PRIORITY + task_index, + RTEMS_MINIMUM_STACK_SIZE, + RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, + &task_id + ); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + + sc = rtems_task_start(task_id, task, task_index); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + + task_ids[task_index] = task_id; + } + + sc = rtems_event_receive( + SECOND_TASK_READY, + RTEMS_EVENT_ALL | RTEMS_WAIT, + RTEMS_NO_TIMEOUT, + &events + ); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + rtems_test_assert(events == SECOND_TASK_READY); + + test_scheduler_cross(); + test_scheduler_move_heir(); +} + +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_SMP_APPLICATION + +#define CONFIGURE_SMP_MAXIMUM_PROCESSORS CPU_COUNT + +#define CONFIGURE_MAXIMUM_TASKS TASK_COUNT + +#define CONFIGURE_INIT_TASK_PRIORITY FIRST_TASK_PRIORITY +#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_DEFAULT_MODES +#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_DEFAULT_ATTRIBUTES + +#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INIT + +#include diff --git a/testsuites/smptests/smpscheduler01/smpscheduler01.doc b/testsuites/smptests/smpscheduler01/smpscheduler01.doc new file mode 100644 index 0000000000..304e778f84 --- /dev/null +++ b/testsuites/smptests/smpscheduler01/smpscheduler01.doc @@ -0,0 +1,14 @@ +This file describes the directives and concepts tested by this test set. + +test set name: smpscheduler01 + +directives: + + - _Scheduler_simple_smp_Enqueue_priority_fifo + - _Scheduler_simple_smp_Enqueue_priority_lifo + - _Scheduler_simple_smp_Extract + +concepts: + + - Ensure that the per-processor state is consistent after a sequence of + scheduling events. diff --git a/testsuites/smptests/smpscheduler01/smpscheduler01.scn b/testsuites/smptests/smpscheduler01/smpscheduler01.scn new file mode 100644 index 0000000000..e290a64706 --- /dev/null +++ b/testsuites/smptests/smpscheduler01/smpscheduler01.scn @@ -0,0 +1,2 @@ +*** TEST SMPSCHEDULE 1 *** +*** END OF TEST SMPSCHEDULE 1 *** -- cgit v1.2.3