[rtems commit] sptests/spintrcritical19: PR2136: New test

Sebastian Huber sebh at rtems.org
Thu Aug 8 12:11:18 UTC 2013


Module:    rtems
Branch:    master
Commit:    6b0cd960e520f0558a142669b53606b20751a9c9
Changeset: http://git.rtems.org/rtems/commit/?id=6b0cd960e520f0558a142669b53606b20751a9c9

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Aug  8 13:58:10 2013 +0200

sptests/spintrcritical19: PR2136: New test

---

 testsuites/sptests/Makefile.am                     |    1 +
 testsuites/sptests/configure.ac                    |    1 +
 testsuites/sptests/spintrcritical19/Makefile.am    |   20 +++
 testsuites/sptests/spintrcritical19/init.c         |  134 ++++++++++++++++++++
 .../sptests/spintrcritical19/spintrcritical19.doc  |   13 ++
 .../sptests/spintrcritical19/spintrcritical19.scn  |    4 +
 6 files changed, 173 insertions(+), 0 deletions(-)

diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index cd3114a..29f77ba 100644
--- a/testsuites/sptests/Makefile.am
+++ b/testsuites/sptests/Makefile.am
@@ -29,6 +29,7 @@ SUBDIRS = \
     spsem01 spsem02 spsimplesched01 spsimplesched02 spsimplesched03 spnsext01 \
     spedfsched01 spedfsched02 spedfsched03 \
     spcbssched01 spcbssched02 spcbssched03 spqreslib sptimespec01
+SUBDIRS += spintrcritical19
 SUBDIRS += spcontext01
 SUBDIRS += spfatal26
 SUBDIRS += speventtransient01
diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac
index b8fb57c..6b3f731 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
+spintrcritical19/Makefile
 spcontext01/Makefile
 spfatal26/Makefile
 spinternalerror02/Makefile
diff --git a/testsuites/sptests/spintrcritical19/Makefile.am b/testsuites/sptests/spintrcritical19/Makefile.am
new file mode 100644
index 0000000..a2350ca
--- /dev/null
+++ b/testsuites/sptests/spintrcritical19/Makefile.am
@@ -0,0 +1,20 @@
+rtems_tests_PROGRAMS = spintrcritical19
+spintrcritical19_SOURCES = init.c ../spintrcritical_support/intrcritical.c
+
+dist_rtems_tests_DATA = spintrcritical19.scn spintrcritical19.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP at .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 = $(spintrcritical19_OBJECTS)
+LINK_LIBS = $(spintrcritical19_LDLIBS)
+
+spintrcritical19$(EXEEXT): $(spintrcritical19_OBJECTS) $(spintrcritical19_DEPENDENCIES)
+	@rm -f spintrcritical19$(EXEEXT)
+	$(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/spintrcritical19/init.c b/testsuites/sptests/spintrcritical19/init.c
new file mode 100644
index 0000000..79b0eba
--- /dev/null
+++ b/testsuites/sptests/spintrcritical19/init.c
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2012 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Obere Lagerstr. 30
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems at 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>
+#include <intrcritical.h>
+#include <rtems/score/statesimpl.h>
+
+#define TEST_NAME "19"
+
+#define PRIORITY_RED 1
+
+#define PRIORITY_GREEN 2
+
+#define PRIORITY_RESUMER 3
+
+typedef struct {
+  rtems_id master_task;
+  rtems_id resumer_task;
+  Thread_Control *master_task_tcb;
+  bool test_case_hit;
+} test_context;
+
+static test_context ctx_instance;
+
+static void resumer_task(rtems_task_argument arg)
+{
+  test_context *ctx = (test_context *) arg;
+
+  while (true) {
+    rtems_status_code sc = rtems_task_resume(ctx->master_task);
+    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+  }
+}
+
+static void suspend_master_task(rtems_id timer, void *arg)
+{
+  /* The arg is NULL */
+  test_context *ctx = &ctx_instance;
+  rtems_status_code sc;
+
+  if (_States_Is_transient(ctx->master_task_tcb->current_state)) {
+    ctx->test_case_hit = true;
+  }
+
+  sc = rtems_task_suspend(ctx->master_task);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+}
+
+static void Init(rtems_task_argument ignored)
+{
+  test_context *ctx = &ctx_instance;
+  rtems_task_priority priority = PRIORITY_RED;
+  int resets = 0;
+  rtems_status_code sc;
+
+  puts("\n\n*** TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***\n");
+
+  ctx->master_task = rtems_task_self();
+  ctx->master_task_tcb = _Thread_Get_executing();
+
+  sc = rtems_task_create(
+    rtems_build_name('R', 'E', 'S', 'U'),
+    PRIORITY_RESUMER,
+    RTEMS_MINIMUM_STACK_SIZE,
+    RTEMS_DEFAULT_MODES,
+    RTEMS_DEFAULT_ATTRIBUTES,
+    &ctx->resumer_task
+  );
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+  sc = rtems_task_start(
+    ctx->resumer_task,
+    resumer_task,
+    (rtems_task_argument) ctx
+  );
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+  interrupt_critical_section_test_support_initialize(
+    suspend_master_task
+  );
+
+  while (resets < 3 && !ctx->test_case_hit) {
+    if (interrupt_critical_section_test_support_delay()) {
+      ++resets;
+    }
+
+    sc = rtems_task_set_priority(RTEMS_SELF, priority, &priority);
+    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+    rtems_test_assert(_States_Is_ready(ctx->master_task_tcb->current_state));
+  }
+
+  rtems_test_assert(ctx->test_case_hit);
+
+  sc = rtems_task_delete(ctx->resumer_task);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+  puts("*** END OF TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***");
+
+  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 1
+
+#define CONFIGURE_INIT_TASK_PRIORITY PRIORITY_GREEN
+#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_DEFAULT_ATTRIBUTES
+#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_DEFAULT_MODES
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_INIT
+
+#include <rtems/confdefs.h>
diff --git a/testsuites/sptests/spintrcritical19/spintrcritical19.doc b/testsuites/sptests/spintrcritical19/spintrcritical19.doc
new file mode 100644
index 0000000..4228ff2
--- /dev/null
+++ b/testsuites/sptests/spintrcritical19/spintrcritical19.doc
@@ -0,0 +1,13 @@
+This file describes the directives and concepts tested by this test set.
+
+test set name: spintrcritical19
+
+directives:
+
+  - rtems_task_suspend()
+  - rtems_task_set_priority()
+
+concepts:
+
+  - Ensure that a priority change works during suspend requests from an
+    interrupt service routine.
diff --git a/testsuites/sptests/spintrcritical19/spintrcritical19.scn b/testsuites/sptests/spintrcritical19/spintrcritical19.scn
new file mode 100644
index 0000000..3d7d209
--- /dev/null
+++ b/testsuites/sptests/spintrcritical19/spintrcritical19.scn
@@ -0,0 +1,4 @@
+*** TEST INTERRUPT CRITICAL SECTION 19 ***
+
+Support - rtems_timer_create - creating timer 1
+*** END OF TEST INTERRUPT CRITICAL SECTION 19 ***




More information about the vc mailing list