summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2013-07-29 10:46:28 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2013-07-30 09:53:24 +0200
commitd4f13d14797bfc9745848c158048859f7dd24b81 (patch)
treeddcb466d7cd54ea690be73a4b44936c8c389afc3
parent21ff802c7f77dee09144b0a249fc0dc5d6ae0e2c (diff)
downloadrtems-d4f13d14797bfc9745848c158048859f7dd24b81.tar.bz2
smptests/smpsignal01: New test
-rw-r--r--testsuites/smptests/Makefile.am1
-rw-r--r--testsuites/smptests/configure.ac1
-rw-r--r--testsuites/smptests/smpsignal01/Makefile.am19
-rw-r--r--testsuites/smptests/smpsignal01/init.c191
-rw-r--r--testsuites/smptests/smpsignal01/smpsignal01.doc12
-rw-r--r--testsuites/smptests/smpsignal01/smpsignal01.scn2
6 files changed, 226 insertions, 0 deletions
diff --git a/testsuites/smptests/Makefile.am b/testsuites/smptests/Makefile.am
index 7a37751d54..714a21b6a3 100644
--- a/testsuites/smptests/Makefile.am
+++ b/testsuites/smptests/Makefile.am
@@ -20,6 +20,7 @@ SUBDIRS += smpatomic06
SUBDIRS += smpatomic07
SUBDIRS += smplock01
SUBDIRS += smpschedule01
+SUBDIRS += smpsignal01
SUBDIRS += smpunsupported01
endif
diff --git a/testsuites/smptests/configure.ac b/testsuites/smptests/configure.ac
index 64859d31b9..b1b786352b 100644
--- a/testsuites/smptests/configure.ac
+++ b/testsuites/smptests/configure.ac
@@ -53,6 +53,7 @@ smpatomic06/Makefile
smpatomic07/Makefile
smplock01/Makefile
smpschedule01/Makefile
+smpsignal01/Makefile
smpunsupported01/Makefile
])
AC_OUTPUT
diff --git a/testsuites/smptests/smpsignal01/Makefile.am b/testsuites/smptests/smpsignal01/Makefile.am
new file mode 100644
index 0000000000..9bfb561791
--- /dev/null
+++ b/testsuites/smptests/smpsignal01/Makefile.am
@@ -0,0 +1,19 @@
+rtems_tests_PROGRAMS = smpsignal01
+smpsignal01_SOURCES = init.c
+
+dist_rtems_tests_DATA = smpsignal01.scn smpsignal01.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 = $(smpsignal01_OBJECTS)
+LINK_LIBS = $(smpsignal01_LDLIBS)
+
+smpsignal01$(EXEEXT): $(smpsignal01_OBJECTS) $(smpsignal01_DEPENDENCIES)
+ @rm -f smpsignal01$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/smptests/smpsignal01/init.c b/testsuites/smptests/smpsignal01/init.c
new file mode 100644
index 0000000000..af2f414db4
--- /dev/null
+++ b/testsuites/smptests/smpsignal01/init.c
@@ -0,0 +1,191 @@
+/*
+ * 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 TEST_SIGNAL RTEMS_SIGNAL_0
+
+typedef enum {
+ SIG_0_READY,
+ SIG_0_SENT,
+ SIG_0_ENABLE,
+ SIG_0_PROCESSED,
+ SIG_1_READY,
+ SIG_1_SENT,
+ SIG_1_PROCESSED
+} test_state;
+
+typedef struct {
+ test_state state;
+ rtems_id consumer;
+ rtems_id producer;
+ uint32_t consumer_processor;
+ uint32_t producer_processor;
+} test_context;
+
+static void change_state(test_context *ctx, test_state new_state)
+{
+ ctx->state = new_state;
+ _CPU_SMP_Processor_event_broadcast();
+}
+
+static void wait_for_state(const test_context *ctx, test_state desired_state)
+{
+ while ( ctx->state != desired_state ) {
+ _CPU_SMP_Processor_event_receive();
+ }
+}
+
+static test_context ctx_instance = {
+ .state = SIG_0_READY
+};
+
+static void signal_handler(rtems_signal_set signal)
+{
+ test_context *ctx = &ctx_instance;
+
+ switch (ctx->state) {
+ case SIG_0_ENABLE:
+ change_state(ctx, SIG_0_PROCESSED);
+ break;
+ case SIG_1_SENT:
+ change_state(ctx, SIG_1_PROCESSED);
+ break;
+ default:
+ rtems_test_assert(0);
+ }
+}
+
+static void signal_send(test_context *ctx, test_state new_state)
+{
+ rtems_status_code sc;
+
+ sc = rtems_signal_send(ctx->consumer, TEST_SIGNAL);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ change_state(ctx, new_state);
+}
+
+static void check_consumer_processor(const test_context *ctx)
+{
+ rtems_test_assert(
+ ctx->consumer_processor == rtems_smp_get_current_processor()
+ );
+}
+
+static void check_producer_processor(const test_context *ctx)
+{
+ rtems_test_assert(
+ ctx->producer_processor == rtems_smp_get_current_processor()
+ );
+}
+
+static void producer(rtems_task_argument arg)
+{
+ test_context *ctx = (test_context *) arg;
+
+ ctx->producer_processor = rtems_smp_get_current_processor();
+
+ rtems_test_assert(ctx->consumer_processor != ctx->producer_processor);
+
+ wait_for_state(ctx, SIG_0_READY);
+ signal_send(ctx, SIG_0_SENT);
+
+ check_producer_processor(ctx);
+
+ wait_for_state(ctx, SIG_1_READY);
+ signal_send(ctx, SIG_1_SENT);
+
+ check_producer_processor(ctx);
+
+ rtems_task_suspend(RTEMS_SELF);
+ rtems_test_assert(0);
+}
+
+static void test(void)
+{
+ test_context *ctx = &ctx_instance;
+ rtems_status_code sc;
+ rtems_mode mode;
+
+ ctx->consumer = rtems_task_self();
+ ctx->consumer_processor = rtems_smp_get_current_processor();
+
+ sc = rtems_signal_catch(signal_handler, RTEMS_DEFAULT_MODES);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ sc = rtems_task_create(
+ rtems_build_name('P', 'R', 'O', 'D'),
+ RTEMS_MINIMUM_PRIORITY,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &ctx->producer
+ );
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ sc = rtems_task_start(ctx->producer, producer, (rtems_task_argument) ctx);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ check_consumer_processor(ctx);
+
+ wait_for_state(ctx, SIG_0_SENT);
+ change_state(ctx, SIG_0_ENABLE);
+
+ sc = rtems_task_mode(RTEMS_ASR, RTEMS_ASR_MASK, &mode);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ wait_for_state(ctx, SIG_0_PROCESSED);
+
+ check_consumer_processor(ctx);
+
+ change_state(ctx, SIG_1_READY);
+ wait_for_state(ctx, SIG_1_PROCESSED);
+
+ check_consumer_processor(ctx);
+}
+
+static void Init(rtems_task_argument arg)
+{
+ puts("\n\n*** TEST SMPSIGNAL 1 ***");
+
+ if (rtems_smp_get_processor_count() >= 2) {
+ test();
+ }
+
+ puts("*** END OF TEST SMPSIGNAL 1 ***");
+
+ 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 2
+
+#define CONFIGURE_MAXIMUM_TASKS 2
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_NO_ASR
+
+#define CONFIGURE_INIT
+
+#include <rtems/confdefs.h>
diff --git a/testsuites/smptests/smpsignal01/smpsignal01.doc b/testsuites/smptests/smpsignal01/smpsignal01.doc
new file mode 100644
index 0000000000..98a2a85d70
--- /dev/null
+++ b/testsuites/smptests/smpsignal01/smpsignal01.doc
@@ -0,0 +1,12 @@
+This file describes the directives and concepts tested by this test set.
+
+test set name: smpsignal01
+
+directives:
+
+ - rtems_signal_catch()
+ - rtems_signal_send()
+
+concepts:
+
+ - Ensure that Classic Signals work on SMP.
diff --git a/testsuites/smptests/smpsignal01/smpsignal01.scn b/testsuites/smptests/smpsignal01/smpsignal01.scn
new file mode 100644
index 0000000000..fe394a0bbc
--- /dev/null
+++ b/testsuites/smptests/smpsignal01/smpsignal01.scn
@@ -0,0 +1,2 @@
+*** TEST SMPSIGNAL 1 ***
+*** END OF TEST SMPSIGNAL 1 ***