[rtems commit] sptests/spintrcritical22: New test

Sebastian Huber sebh at rtems.org
Fri Sep 19 12:17:19 UTC 2014


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Sep 19 14:18:00 2014 +0200

sptests/spintrcritical22: New test

---

 testsuites/sptests/Makefile.am                     |    1 +
 testsuites/sptests/configure.ac                    |    1 +
 testsuites/sptests/spintrcritical22/Makefile.am    |   22 +++
 testsuites/sptests/spintrcritical22/init.c         |  138 ++++++++++++++++++++
 .../sptests/spintrcritical22/spintrcritical22.doc  |   12 ++
 .../sptests/spintrcritical22/spintrcritical22.scn  |    2 +
 6 files changed, 176 insertions(+), 0 deletions(-)

diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index 3df4ffb..7764a3e 100644
--- a/testsuites/sptests/Makefile.am
+++ b/testsuites/sptests/Makefile.am
@@ -37,6 +37,7 @@ if HAS_SMP
 else
 _SUBDIRS += sp29
 endif
+_SUBDIRS += spintrcritical22
 _SUBDIRS += spsem03
 _SUBDIRS += spresource01
 _SUBDIRS += spmrsp01
diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac
index fa149ab..282cbcf 100644
--- a/testsuites/sptests/configure.ac
+++ b/testsuites/sptests/configure.ac
@@ -40,6 +40,7 @@ AM_CONDITIONAL(HAS_SMP,test "$rtems_cv_RTEMS_SMP" = "yes")
 
 # Explicitly list all Makefiles here
 AC_CONFIG_FILES([Makefile
+spintrcritical22/Makefile
 spsem03/Makefile
 spresource01/Makefile
 spmrsp01/Makefile
diff --git a/testsuites/sptests/spintrcritical22/Makefile.am b/testsuites/sptests/spintrcritical22/Makefile.am
new file mode 100644
index 0000000..86486b1
--- /dev/null
+++ b/testsuites/sptests/spintrcritical22/Makefile.am
@@ -0,0 +1,22 @@
+rtems_tests_PROGRAMS = spintrcritical22
+spintrcritical22_SOURCES = init.c
+spintrcritical22_SOURCES += ../spintrcritical_support/intrcritical.h
+spintrcritical22_SOURCES += ../spintrcritical_support/intrcritical.c
+
+dist_rtems_tests_DATA = spintrcritical22.scn spintrcritical22.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 = $(spintrcritical22_OBJECTS)
+LINK_LIBS = $(spintrcritical22_LDLIBS)
+
+spintrcritical22$(EXEEXT): $(spintrcritical22_OBJECTS) $(spintrcritical22_DEPENDENCIES)
+	@rm -f spintrcritical22$(EXEEXT)
+	$(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/spintrcritical22/init.c b/testsuites/sptests/spintrcritical22/init.c
new file mode 100644
index 0000000..93946c3
--- /dev/null
+++ b/testsuites/sptests/spintrcritical22/init.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2014 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  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.org/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+  #include "config.h"
+#endif
+
+#include <tmacros.h>
+#include <intrcritical.h>
+#include <rtems/rtems/semimpl.h>
+
+const char rtems_test_name[] = "SPINTRCRITICAL 22";
+
+typedef struct {
+  rtems_id semaphore_id;
+  Semaphore_Control *semaphore_control;
+  Thread_Control *main_task_control;
+  volatile bool done;
+} test_context;
+
+static test_context ctx_instance;
+
+static Semaphore_Control *get_semaphore_control(rtems_id id)
+{
+  Objects_Locations location;
+  Semaphore_Control *sem;
+
+  sem = (Semaphore_Control *)
+    _Objects_Get(&_Semaphore_Information, id, &location);
+  _Thread_Unnest_dispatch();
+
+  rtems_test_assert(sem != NULL && location == OBJECTS_LOCAL);
+
+  return sem;
+}
+
+static void release_semaphore(rtems_id timer, void *arg)
+{
+  /* The arg is NULL */
+  test_context *ctx = &ctx_instance;
+  rtems_status_code sc;
+  CORE_mutex_Control *mtx = &ctx->semaphore_control->Core_control.mutex;
+
+  if (mtx->Wait_queue.sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED) {
+    ctx->done = true;
+
+    sc = rtems_semaphore_release(ctx->semaphore_id);
+    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+    rtems_test_assert(
+      mtx->Wait_queue.sync_state == THREAD_BLOCKING_OPERATION_SATISFIED
+    );
+    rtems_test_assert(mtx->nest_count == 1);
+    rtems_test_assert(mtx->holder == ctx->main_task_control);
+  } else {
+    sc = rtems_semaphore_release(ctx->semaphore_id);
+    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+  }
+}
+
+static bool test_body(void *arg)
+{
+  test_context *ctx = arg;
+  rtems_status_code sc;
+
+  sc = rtems_semaphore_obtain(
+    ctx->semaphore_id,
+    RTEMS_NO_WAIT,
+    0
+  );
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL || sc == RTEMS_UNSATISFIED);
+
+  sc = rtems_semaphore_obtain(
+    ctx->semaphore_id,
+    RTEMS_WAIT,
+    2
+  );
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL || sc == RTEMS_TIMEOUT);
+
+  return ctx->done;
+}
+
+static void Init(rtems_task_argument ignored)
+{
+  test_context *ctx = &ctx_instance;
+  rtems_status_code sc;
+
+  TEST_BEGIN();
+
+  ctx->main_task_control = _Thread_Get_executing();
+
+  sc = rtems_semaphore_create(
+    rtems_build_name('S', 'E', 'M', 'A'),
+    1,
+    RTEMS_SIMPLE_BINARY_SEMAPHORE,
+    0,
+    &ctx->semaphore_id
+  );
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+  ctx->semaphore_control = get_semaphore_control(ctx->semaphore_id);
+
+  interrupt_critical_section_test(test_body, ctx, release_semaphore);
+  rtems_test_assert(ctx->done);
+
+  TEST_END();
+
+  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_SEMAPHORES 1
+#define CONFIGURE_MAXIMUM_TASKS 1
+#define CONFIGURE_MAXIMUM_TIMERS 1
+#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
+
+#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/sptests/spintrcritical22/spintrcritical22.doc b/testsuites/sptests/spintrcritical22/spintrcritical22.doc
new file mode 100644
index 0000000..9b16f45
--- /dev/null
+++ b/testsuites/sptests/spintrcritical22/spintrcritical22.doc
@@ -0,0 +1,12 @@
+This file describes the directives and concepts tested by this test set.
+
+test set name: spintrcritical22
+
+directives:
+
+  - _Thread_queue_Dequeue()
+
+concepts:
+
+  - Ensure that _Thread_queue_Dequeue() dequeues the executing thread if it is
+    about to enqueue.
diff --git a/testsuites/sptests/spintrcritical22/spintrcritical22.scn b/testsuites/sptests/spintrcritical22/spintrcritical22.scn
new file mode 100644
index 0000000..7cf4ed2
--- /dev/null
+++ b/testsuites/sptests/spintrcritical22/spintrcritical22.scn
@@ -0,0 +1,2 @@
+*** BEGIN OF TEST SPINTRCRITICAL 22 ***
+*** END OF TEST SPINTRCRITICAL 22 ***



More information about the vc mailing list