[PATCH] sptests/sp39: Convert to sptests/spintrcritical21

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Sep 9 15:15:32 UTC 2014


Use interrupt critical section test support.  Do not print end of test
message in case of failure.
---
 testsuites/sptests/Makefile.am                     |   3 +-
 testsuites/sptests/configure.ac                    |   2 +-
 testsuites/sptests/sp39/Makefile.am                |  22 ---
 testsuites/sptests/sp39/init.c                     | 192 ---------------------
 testsuites/sptests/sp39/sp39.doc                   |  22 ---
 testsuites/sptests/sp39/sp39.scn                   |   4 -
 testsuites/sptests/sp39/system.h                   |  38 ----
 testsuites/sptests/spintrcritical21/Makefile.am    |  20 +++
 testsuites/sptests/spintrcritical21/init.c         | 170 ++++++++++++++++++
 .../sptests/spintrcritical21/spintrcritical21.doc  |  22 +++
 .../sptests/spintrcritical21/spintrcritical21.scn  |   4 +
 testsuites/sptests/spintrcritical21/system.h       |  39 +++++
 12 files changed, 258 insertions(+), 280 deletions(-)
 delete mode 100644 testsuites/sptests/sp39/Makefile.am
 delete mode 100644 testsuites/sptests/sp39/init.c
 delete mode 100644 testsuites/sptests/sp39/sp39.doc
 delete mode 100644 testsuites/sptests/sp39/sp39.scn
 delete mode 100644 testsuites/sptests/sp39/system.h
 create mode 100644 testsuites/sptests/spintrcritical21/Makefile.am
 create mode 100644 testsuites/sptests/spintrcritical21/init.c
 create mode 100644 testsuites/sptests/spintrcritical21/spintrcritical21.doc
 create mode 100644 testsuites/sptests/spintrcritical21/spintrcritical21.scn
 create mode 100644 testsuites/sptests/spintrcritical21/system.h

diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index a0acbc3..3df4ffb 100644
--- a/testsuites/sptests/Makefile.am
+++ b/testsuites/sptests/Makefile.am
@@ -6,7 +6,7 @@ _SUBDIRS = \
          sp01 sp02 sp03 sp04 sp05 sp06 sp07 sp08 \
     sp10 sp11 sp12 sp13 sp14 sp15 sp16 sp17 sp18 sp19 \
     sp20 sp21 sp22 sp23 sp24 sp25 sp26 sp27 sp27a           \
-    sp30 sp31 sp32 sp33 sp34 sp35      sp37 sp38 sp39 \
+    sp30 sp31 sp32 sp33 sp34 sp35      sp37 sp38 \
     sp40 sp41 sp42 sp43 sp44 sp45 sp46 sp47 sp48 sp49 \
     sp50 sp51 sp52 sp53 sp54 sp55 sp56 sp57 sp58 sp59 \
     sp60      sp62 sp63 sp64 sp65 sp66 sp67 sp68 sp69 \
@@ -53,6 +53,7 @@ _SUBDIRS += sptls02
 endif
 _SUBDIRS += sptls01
 _SUBDIRS += spintrcritical20
+_SUBDIRS += spintrcritical21
 _SUBDIRS += spcontext01
 _SUBDIRS += spfatal26
 _SUBDIRS += speventtransient01
diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac
index d376a4f..fa149ab 100644
--- a/testsuites/sptests/configure.ac
+++ b/testsuites/sptests/configure.ac
@@ -53,6 +53,7 @@ spcpucounter01/Makefile
 sptls02/Makefile
 sptls01/Makefile
 spintrcritical20/Makefile
+spintrcritical21/Makefile
 spcontext01/Makefile
 spfatal26/Makefile
 spinternalerror02/Makefile
@@ -98,7 +99,6 @@ sp35/Makefile
 sp36/Makefile
 sp37/Makefile
 sp38/Makefile
-sp39/Makefile
 sp40/Makefile
 sp41/Makefile
 sp42/Makefile
diff --git a/testsuites/sptests/sp39/Makefile.am b/testsuites/sptests/sp39/Makefile.am
deleted file mode 100644
index fc091da..0000000
--- a/testsuites/sptests/sp39/Makefile.am
+++ /dev/null
@@ -1,22 +0,0 @@
-
-rtems_tests_PROGRAMS = sp39
-sp39_SOURCES = init.c system.h
-
-dist_rtems_tests_DATA = sp39.scn
-dist_rtems_tests_DATA += sp39.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
-
-LINK_OBJS = $(sp39_OBJECTS)
-LINK_LIBS = $(sp39_LDLIBS)
-
-sp39$(EXEEXT): $(sp39_OBJECTS) $(sp39_DEPENDENCIES)
-	@rm -f sp39$(EXEEXT)
-	$(make-exe)
-
-include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/sp39/init.c b/testsuites/sptests/sp39/init.c
deleted file mode 100644
index b78cd7f..0000000
--- a/testsuites/sptests/sp39/init.c
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- *  Classic API Signal to Task from ISR
- *
- *  COPYRIGHT (c) 1989-2011.
- *  On-Line Applications Research Corporation (OAR).
- *
- *  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
-
-#define CONFIGURE_INIT
-#include "system.h"
-
-#include <rtems/rtems/eventimpl.h>
-
-const char rtems_test_name[] = "SP 39";
-
-/*
- *  ERROR CHECKING NOTE:
- *
- *  We are either at dispatch disable level 1 or 2.  Either way, it is
- *  safer not to check the dispatch level explicitly so we are using
- *  fatal_directive_check_status_only() not directive_failed().
- */
-
-rtems_timer_service_routine test_event_from_isr(
-  rtems_id  timer,
-  void     *arg
-);
-rtems_timer_service_routine test_event_with_timeout_from_isr(
-  rtems_id  timer,
-  void     *arg
-);
-
-volatile bool case_hit;
-
-rtems_id main_task;
-rtems_id other_task;
-
-rtems_timer_service_routine test_event_from_isr(
-  rtems_id  timer,
-  void     *arg
-)
-{
-  rtems_status_code     status;
-
-  if ( _Event_Sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED ) {
-    /*
-     *  This event send hits the critical section but sends to
-     *  another task so doesn't impact this critical section.
-     */
-    status = rtems_event_send( other_task, 0x02 );
-    fatal_directive_check_status_only( status, RTEMS_SUCCESSFUL, "event send" );
-
-    /*
-     *  This event send hits the main task but doesn't satisfy
-     *  it's blocking condition so it will still block
-     */
-    status = rtems_event_send( main_task, 0x02 );
-    fatal_directive_check_status_only( status, RTEMS_SUCCESSFUL, "event send" );
-
-    case_hit = TRUE;
-  }
-  status = rtems_event_send( main_task, 0x01 );
-  fatal_directive_check_status_only( status, RTEMS_SUCCESSFUL, "event send" );
-}
-
-rtems_timer_service_routine test_event_with_timeout_from_isr(
-  rtems_id  timer,
-  void     *arg
-)
-{
-  rtems_status_code     status;
-
-  if ( _Event_Sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED ) {
-    /*
-     *  We want to catch the task while it is blocking.  Otherwise
-     *  just send and make it happy.
-     */
-    case_hit = TRUE;
-  }
-  status = rtems_event_send( main_task, 0x01 );
-  fatal_directive_check_status_only( status, RTEMS_SUCCESSFUL, "event send" );
-}
-
-rtems_task Init(
-  rtems_task_argument argument
-)
-{
-  rtems_status_code     status;
-  rtems_id              timer;
-  rtems_event_set       out;
-  int                   i;
-  int                   max;
-  uint32_t              iterations = 0;
-
-  TEST_BEGIN();
-
-  main_task = rtems_task_self();
-
-  /*
-   *  Timer used in multiple ways
-   */
-  status = rtems_timer_create( 1, &timer );
-  directive_failed( status, "rtems_timer_create" );
-
-  status = rtems_task_create(
-    0xa5a5a5a5,
-    1,
-    RTEMS_MINIMUM_STACK_SIZE,
-    RTEMS_DEFAULT_MODES,
-    RTEMS_DEFAULT_ATTRIBUTES,
-    &other_task
-  );
-  directive_failed( status, "rtems_task_create" );
-
-  /*
-   * Test Event send successful from ISR -- receive is forever
-   */
-  case_hit = FALSE;
-  iterations = 0;
-  max = 1;
-
-  while (1) {
-    if ( case_hit )
-      break;
-    status = rtems_timer_fire_after( timer, 1, test_event_from_isr, NULL );
-    directive_failed( status, "timer_fire_after failed" );
-
-    for (i=0 ; i<max ; i++ )
-      if ( _Event_Sync_state == THREAD_BLOCKING_OPERATION_SATISFIED )
-        break;
-
-    status = rtems_event_receive( 0x01, RTEMS_DEFAULT_OPTIONS, 0, &out );
-    directive_failed( status, "rtems_event_receive" );
-    if ( case_hit == TRUE )
-      break;
-    max += 2;
-
-    /* with our clock tick, this is about 30 seconds */
-    if ( ++iterations >= 4L * 1000L * 30L)
-      break;
-  }
-
-  printf(
-    "Event sent from ISR hitting synchronization point has %soccurred\n",
-    (( case_hit == TRUE ) ? "" : "NOT ")
-  );
-
-  /*
-   * Test Event send successful from ISR -- receive has timeout
-   */
-  case_hit = FALSE;
-  iterations = 0;
-  max = 1;
-
-  while (1) {
-    if ( case_hit )
-      break;
-    status = rtems_timer_fire_after(
-      timer, 1, test_event_with_timeout_from_isr, NULL );
-    directive_failed( status, "timer_fire_after failed" );
-
-    for (i=0 ; i<max ; i++ )
-      if ( _Event_Sync_state == THREAD_BLOCKING_OPERATION_SATISFIED )
-        break;
-
-    status = rtems_event_receive( 0x01, RTEMS_DEFAULT_OPTIONS, 10, &out );
-    directive_failed( status, "rtems_event_receive" );
-    if ( case_hit == TRUE )
-      break;
-    max += 2;
-
-    /* with our clock tick, this is about 30 seconds */
-    if ( ++iterations >= 4L * 1000L * 30L)
-      break;
-  }
-
-  printf(
-    "Event sent from ISR (with timeout) hitting synchronization "
-      "point has %soccurred\n",
-    (( case_hit == TRUE ) ? "" : "NOT ")
-  );
-
-  TEST_END();
-  rtems_test_exit( 0 );
-}
diff --git a/testsuites/sptests/sp39/sp39.doc b/testsuites/sptests/sp39/sp39.doc
deleted file mode 100644
index e5b7510..0000000
--- a/testsuites/sptests/sp39/sp39.doc
+++ /dev/null
@@ -1,22 +0,0 @@
-#  COPYRIGHT (c) 1989-2009.
-#  On-Line Applications Research Corporation (OAR).
-#
-#  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.
-#
-
-This file describes the directives and concepts tested by this test set.
-
-test set name:  sp39
-
-directives:
-
-  rtems_event_receive
-  rtems_event_send
-
-concepts:
-
-+ Ensure that the interrupt critical section for sending an event from an
-  ISR while the receiving task is in the process of blocking with and withing
-  timeout is handled properly.
diff --git a/testsuites/sptests/sp39/sp39.scn b/testsuites/sptests/sp39/sp39.scn
deleted file mode 100644
index adf690b..0000000
--- a/testsuites/sptests/sp39/sp39.scn
+++ /dev/null
@@ -1,4 +0,0 @@
-*** TEST 39 ***
-Event sent from ISR hitting synchronization point has occurred
-Event sent from ISR (with timeout) hitting synchronization point has occurred
-*** END OF TEST 39 ***
diff --git a/testsuites/sptests/sp39/system.h b/testsuites/sptests/sp39/system.h
deleted file mode 100644
index f5f1f25..0000000
--- a/testsuites/sptests/sp39/system.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*  system.h
- *
- *  This include file contains information that is included in every
- *  function in the test set.
- *
- *  COPYRIGHT (c) 1989-2007.
- *  On-Line Applications Research Corporation (OAR).
- *
- *  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.
- */
-
-#include <tmacros.h>
-
-/* functions */
-
-rtems_task Init(
-  rtems_task_argument argument
-);
-
-/* configuration information */
-
-#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
-#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
-
-#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
-
-#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
-
-#define CONFIGURE_MICROSECONDS_PER_TICK   1000
-
-#define CONFIGURE_MAXIMUM_TASKS             2
-#define CONFIGURE_MAXIMUM_TIMERS            1
-
-#include <rtems/confdefs.h>
-
-/* end of include file */
diff --git a/testsuites/sptests/spintrcritical21/Makefile.am b/testsuites/sptests/spintrcritical21/Makefile.am
new file mode 100644
index 0000000..b53d000
--- /dev/null
+++ b/testsuites/sptests/spintrcritical21/Makefile.am
@@ -0,0 +1,20 @@
+rtems_tests_PROGRAMS = spintrcritical21
+spintrcritical21_SOURCES = init.c ../spintrcritical_support/intrcritical.c
+
+dist_rtems_tests_DATA = spintrcritical21.scn spintrcritical21.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 = $(spintrcritical21_OBJECTS)
+LINK_LIBS = $(spintrcritical21_LDLIBS)
+
+spintrcritical21$(EXEEXT): $(spintrcritical21_OBJECTS) $(spintrcritical21_DEPENDENCIES)
+	@rm -f spintrcritical21$(EXEEXT)
+	$(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/spintrcritical21/init.c b/testsuites/sptests/spintrcritical21/init.c
new file mode 100644
index 0000000..8b1ddcf
--- /dev/null
+++ b/testsuites/sptests/spintrcritical21/init.c
@@ -0,0 +1,170 @@
+/*
+ *  Classic API Signal to Task from ISR
+ *
+ *  COPYRIGHT (c) 1989-2011.
+ *  On-Line Applications Research Corporation (OAR).
+ *
+ *  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
+
+#define CONFIGURE_INIT
+#include "system.h"
+
+#include <intrcritical.h>
+
+#include <rtems/rtems/eventimpl.h>
+
+const char rtems_test_name[] = "SPINTRCRITICAL 21";
+
+/*
+ *  ERROR CHECKING NOTE:
+ *
+ *  We are either at dispatch disable level 1 or 2.  Either way, it is
+ *  safer not to check the dispatch level explicitly so we are using
+ *  fatal_directive_check_status_only() not directive_failed().
+ */
+
+static volatile bool case_hit;
+
+static rtems_id main_task;
+
+static rtems_id other_task;
+
+static rtems_timer_service_routine test_event_from_isr(
+  rtems_id  timer,
+  void     *arg
+)
+{
+  rtems_status_code     status;
+
+  if ( _Event_Sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED ) {
+    /*
+     *  This event send hits the critical section but sends to
+     *  another task so doesn't impact this critical section.
+     */
+    status = rtems_event_send( other_task, 0x02 );
+    fatal_directive_check_status_only( status, RTEMS_SUCCESSFUL, "event send" );
+
+    /*
+     *  This event send hits the main task but doesn't satisfy
+     *  it's blocking condition so it will still block
+     */
+    status = rtems_event_send( main_task, 0x02 );
+    fatal_directive_check_status_only( status, RTEMS_SUCCESSFUL, "event send" );
+
+    case_hit = true;
+  }
+  status = rtems_event_send( main_task, 0x01 );
+  fatal_directive_check_status_only( status, RTEMS_SUCCESSFUL, "event send" );
+}
+
+static bool test_body_event_from_isr( void *arg )
+{
+  rtems_status_code status;
+  rtems_event_set   out;
+
+  (void) arg;
+
+  status = rtems_event_receive( 0x01, RTEMS_DEFAULT_OPTIONS, 0, &out );
+  rtems_test_assert( status == RTEMS_SUCCESSFUL );
+
+  return case_hit;
+}
+
+static rtems_timer_service_routine test_event_with_timeout_from_isr(
+  rtems_id  timer,
+  void     *arg
+)
+{
+  rtems_status_code     status;
+
+  if ( _Event_Sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED ) {
+    /*
+     *  We want to catch the task while it is blocking.  Otherwise
+     *  just send and make it happy.
+     */
+    case_hit = true;
+  }
+  status = rtems_event_send( main_task, 0x01 );
+  fatal_directive_check_status_only( status, RTEMS_SUCCESSFUL, "event send" );
+}
+
+static bool test_body_event_with_timeout_from_isr( void *arg )
+{
+  rtems_status_code status;
+  rtems_event_set   out;
+
+  (void) arg;
+
+  status = rtems_event_receive( 0x01, RTEMS_DEFAULT_OPTIONS, 1, &out );
+  rtems_test_assert( status == RTEMS_SUCCESSFUL || status == RTEMS_TIMEOUT );
+
+  return case_hit;
+}
+
+rtems_task Init(
+  rtems_task_argument argument
+)
+{
+  rtems_status_code     status;
+
+  TEST_BEGIN();
+
+  main_task = rtems_task_self();
+
+  status = rtems_task_create(
+    0xa5a5a5a5,
+    1,
+    RTEMS_MINIMUM_STACK_SIZE,
+    RTEMS_DEFAULT_MODES,
+    RTEMS_DEFAULT_ATTRIBUTES,
+    &other_task
+  );
+  directive_failed( status, "rtems_task_create" );
+
+  /*
+   * Test Event send successful from ISR -- receive is forever
+   */
+
+  case_hit = false;
+  interrupt_critical_section_test(
+    test_body_event_from_isr,
+    NULL,
+    test_event_from_isr
+  );
+
+  printf(
+    "Event sent from ISR hitting synchronization point has %soccurred\n",
+    case_hit ? "" : "NOT "
+  );
+
+  rtems_test_assert( case_hit );
+
+  /*
+   * Test Event send successful from ISR -- receive has timeout
+   */
+
+  case_hit = false;
+  interrupt_critical_section_test(
+    test_body_event_with_timeout_from_isr,
+    NULL,
+    test_event_with_timeout_from_isr
+  );
+
+  printf(
+    "Event sent from ISR (with timeout) hitting synchronization "
+      "point has %soccurred\n",
+    case_hit ? "" : "NOT "
+  );
+
+  rtems_test_assert( case_hit );
+
+  TEST_END();
+  rtems_test_exit( 0 );
+}
diff --git a/testsuites/sptests/spintrcritical21/spintrcritical21.doc b/testsuites/sptests/spintrcritical21/spintrcritical21.doc
new file mode 100644
index 0000000..94423e1
--- /dev/null
+++ b/testsuites/sptests/spintrcritical21/spintrcritical21.doc
@@ -0,0 +1,22 @@
+#  COPYRIGHT (c) 1989-2009.
+#  On-Line Applications Research Corporation (OAR).
+#
+#  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.
+#
+
+This file describes the directives and concepts tested by this test set.
+
+test set name:  spintrcritical21
+
+directives:
+
+  rtems_event_receive
+  rtems_event_send
+
+concepts:
+
++ Ensure that the interrupt critical section for sending an event from an
+  ISR while the receiving task is in the process of blocking with and withing
+  timeout is handled properly.
diff --git a/testsuites/sptests/spintrcritical21/spintrcritical21.scn b/testsuites/sptests/spintrcritical21/spintrcritical21.scn
new file mode 100644
index 0000000..d7a1998
--- /dev/null
+++ b/testsuites/sptests/spintrcritical21/spintrcritical21.scn
@@ -0,0 +1,4 @@
+*** BEGIN OF TEST SPINTRCRITICAL 21 ***
+Event sent from ISR hitting synchronization point has occurred
+Event sent from ISR (with timeout) hitting synchronization point has occurred
+*** END OF TEST SPINTRCRITICAL 21 ***
diff --git a/testsuites/sptests/spintrcritical21/system.h b/testsuites/sptests/spintrcritical21/system.h
new file mode 100644
index 0000000..f9111c0
--- /dev/null
+++ b/testsuites/sptests/spintrcritical21/system.h
@@ -0,0 +1,39 @@
+/*  system.h
+ *
+ *  This include file contains information that is included in every
+ *  function in the test set.
+ *
+ *  COPYRIGHT (c) 1989-2007.
+ *  On-Line Applications Research Corporation (OAR).
+ *
+ *  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.
+ */
+
+#include <tmacros.h>
+
+/* functions */
+
+rtems_task Init(
+  rtems_task_argument argument
+);
+
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_MICROSECONDS_PER_TICK   1000
+
+#define CONFIGURE_MAXIMUM_TASKS             2
+#define CONFIGURE_MAXIMUM_TIMERS            1
+#define CONFIGURE_MAXIMUM_USER_EXTENSIONS   1
+
+#include <rtems/confdefs.h>
+
+/* end of include file */
-- 
1.8.4.5



More information about the devel mailing list