[PATCH 23/33] spintrcritical11/12: Use T_interrupt_test()

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Jul 21 15:04:40 UTC 2020


---
 testsuites/sptests/Makefile.am                |   7 +-
 .../spintrcritical11/spintrcritical11.scn     |  30 ++++-
 .../spintrcritical11/spintrcritical11impl.h   | 110 ++++++++++++------
 .../spintrcritical12/spintrcritical12.scn     |  30 ++++-
 4 files changed, 126 insertions(+), 51 deletions(-)

diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index ceea27565f..f9dcd0d570 100644
--- a/testsuites/sptests/Makefile.am
+++ b/testsuites/sptests/Makefile.am
@@ -1270,9 +1270,7 @@ if TEST_spintrcritical11
 sp_tests += spintrcritical11
 sp_screens += spintrcritical11/spintrcritical11.scn
 sp_docs += spintrcritical11/spintrcritical11.doc
-spintrcritical11_SOURCES = spintrcritical11/init.c \
-	spintrcritical_support/intrcritical.c \
-	spintrcritical_support/intrcritical.h
+spintrcritical11_SOURCES = spintrcritical11/init.c
 spintrcritical11_CPPFLAGS = $(AM_CPPFLAGS) \
 	$(TEST_FLAGS_spintrcritical11) $(support_includes) \
 	-I$(top_srcdir)/spintrcritical_support
@@ -1282,8 +1280,7 @@ if TEST_spintrcritical12
 sp_tests += spintrcritical12
 sp_screens += spintrcritical12/spintrcritical12.scn
 sp_docs += spintrcritical12/spintrcritical12.doc
-spintrcritical12_SOURCES = spintrcritical12/init.c \
-	spintrcritical_support/intrcritical.c
+spintrcritical12_SOURCES = spintrcritical12/init.c
 spintrcritical12_CPPFLAGS = $(AM_CPPFLAGS) \
 	$(TEST_FLAGS_spintrcritical12) $(support_includes) \
 	-I$(top_srcdir)/spintrcritical_support
diff --git a/testsuites/sptests/spintrcritical11/spintrcritical11.scn b/testsuites/sptests/spintrcritical11/spintrcritical11.scn
index 9451d04292..26f38d037e 100644
--- a/testsuites/sptests/spintrcritical11/spintrcritical11.scn
+++ b/testsuites/sptests/spintrcritical11/spintrcritical11.scn
@@ -1,6 +1,24 @@
-*** TEST INTERRUPT CRITICAL SECTION 11 ***
-Init - Test may not be able to detect case is hit reliably
-Init - Trying to generate event send from ISR while blocking
-Init - Variation is: Event Any condition
-Support - rtems_timer_create - creating timer 1
-*** END OF TEST INTERRUPT CRITICAL SECTION 11 ***
+*** BEGIN OF TEST SPINTRCRITICAL 11 ***
+*** TEST VERSION: 6.0.0.929e49a54ab4d2d18c9fb8d03610614f63e25b8d
+*** TEST STATE: EXPECTED_PASS
+*** TEST BUILD: RTEMS_DEBUG RTEMS_POSIX_API RTEMS_SMP
+*** TEST TOOLS: 10.0.1 20200406 (RTEMS 6, RSB bec88a6dd856892c3e66e4598252ea07d7a0d762, Newlib ece49e4)
+A:SPINTRCRITICAL 11
+S:Platform:RTEMS
+S:Compiler:10.0.1 20200406 (RTEMS 6, RSB bec88a6dd856892c3e66e4598252ea07d7a0d762, Newlib ece49e4)
+S:Version:6.0.0.929e49a54ab4d2d18c9fb8d03610614f63e25b8d
+S:BSP:realview_pbx_a9_qemu
+S:RTEMS_DEBUG:1
+S:RTEMS_MULTIPROCESSING:0
+S:RTEMS_POSIX_API:1
+S:RTEMS_PROFILING:0
+S:RTEMS_SMP:1
+B:EventReceiveInterruptAny
+P:0:0:UI1:spintrcritical11impl.h:113
+L:potential hits = 999
+P:1:0:UI1:spintrcritical11impl.h:116
+E:EventReceiveInterruptAny:N:2:F:0:D:1.058417
+Z:SPINTRCRITICAL 11:C:1:N:2:F:0:D:1.059457
+Y:ReportHash:SHA256:e666eb8c6287c596e6d1851fea90f50fdcc8a52c7799ede485964d09de3fc9ed
+
+*** END OF TEST SPINTRCRITICAL 11 ***
diff --git a/testsuites/sptests/spintrcritical11/spintrcritical11impl.h b/testsuites/sptests/spintrcritical11/spintrcritical11impl.h
index fb0d320dea..dfa312f0b5 100644
--- a/testsuites/sptests/spintrcritical11/spintrcritical11impl.h
+++ b/testsuites/sptests/spintrcritical11/spintrcritical11impl.h
@@ -1,4 +1,6 @@
 /*
+ *  Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
+ *
  *  COPYRIGHT (c) 1989-2012.
  *  On-Line Applications Research Corporation (OAR).
  *
@@ -11,24 +13,20 @@
 #include "config.h"
 #endif
 
-#include <tmacros.h>
-#include <intrcritical.h>
-
-/* forward declarations to avoid warnings */
-rtems_task Init(rtems_task_argument argument);
-rtems_timer_service_routine test_release_from_isr(rtems_id  timer, void *arg);
+#include <string.h>
 
-rtems_id Main_task;
+#include <rtems/test.h>
+#include <rtems/simple-test.h>
 
 #if defined(EVENT_ANY)
   #define TEST_NAME          "11"
-  #define TEST_STRING        "Event Any condition"
+  #define TEST_STRING        Any
   #define EVENTS_TO_SEND     0x1
   #define EVENTS_TO_RECEIVE  0x3
 
 #elif defined(EVENT_ALL)
   #define TEST_NAME          "12"
-  #define TEST_STRING        "Event All condition"
+  #define TEST_STRING        All
   #define EVENTS_TO_SEND     0x3
   #define EVENTS_TO_RECEIVE  0x3
 
@@ -39,41 +37,88 @@ rtems_id Main_task;
 
 const char rtems_test_name[] = "SPINTRCRITICAL " TEST_NAME;
 
-rtems_timer_service_routine test_release_from_isr(
-  rtems_id  timer,
-  void     *arg
-)
+typedef struct {
+  rtems_id      main_task;
+  long          potential_hits;
+  volatile bool early;
+  volatile bool late;
+} test_context;
+
+static T_interrupt_test_state interrupt( void *arg )
 {
-  (void) rtems_event_send( Main_task, EVENTS_TO_SEND );
+  test_context           *ctx;
+  T_interrupt_test_state  state;
+  rtems_status_code       sc;
+
+  state = T_interrupt_test_get_state();
+
+  if ( state != T_INTERRUPT_TEST_ACTION ) {
+    return T_INTERRUPT_TEST_CONTINUE;
+  }
+
+  ctx = arg;
+  sc = rtems_event_send( ctx->main_task, EVENTS_TO_SEND );
+  T_quiet_rsc_success( sc );
+
+  if ( ctx->early ) {
+    state = T_INTERRUPT_TEST_EARLY;
+  } else if ( ctx->late ) {
+    state = T_INTERRUPT_TEST_LATE;
+  } else {
+    ++ctx->potential_hits;
+    state = T_INTERRUPT_TEST_CONTINUE;
+  }
+
+  return state;
 }
 
-static bool test_body( void *arg )
+static void prepare( void *arg )
 {
-  rtems_event_set out;
+  test_context    *ctx;
+  rtems_event_set  out;
 
-  (void) arg;
+  ctx = arg;
+  ctx->early = true;
+  ctx->late = false;
+  (void ) rtems_event_receive( RTEMS_PENDING_EVENTS, RTEMS_NO_WAIT, 0, &out );
+}
 
-  rtems_event_receive( EVENTS_TO_RECEIVE, RTEMS_EVENT_ANY, 1, &out );
+static void action( void *arg )
+{
+  test_context    *ctx;
+  rtems_event_set  out;
 
-  return false;
+  ctx = arg;
+  ctx->early = false;
+  (void ) rtems_event_receive( EVENTS_TO_RECEIVE, RTEMS_EVENT_ANY, 1, &out );
+  ctx->late = true;
 }
 
-rtems_task Init(
-  rtems_task_argument ignored
-)
+static const T_interrupt_test_config config = {
+  .prepare = prepare,
+  .action = action,
+  .interrupt = interrupt,
+  .max_iteration_count = 1000
+};
+
+T_TEST_CASE( RTEMS_XCONCAT( EventReceiveInterrupt, TEST_STRING ) )
 {
-  TEST_BEGIN();
+  test_context           ctx;
+  T_interrupt_test_state state;
 
-  puts( "Init - Test may not be able to detect case is hit reliably" );
-  puts( "Init - Trying to generate event send from ISR while blocking" );
-  puts( "Init - Variation is: " TEST_STRING );
+  memset( &ctx, 0, sizeof( ctx ) );
+  ctx.main_task = rtems_task_self();
 
-  Main_task = rtems_task_self();
+  state = T_interrupt_test( &config, &ctx );
+  T_eq_int( state, T_INTERRUPT_TEST_TIMEOUT );
 
-  interrupt_critical_section_test( test_body, NULL, test_release_from_isr );
+  T_log( T_NORMAL, "potential hits = %ld", ctx.potential_hits );
+  T_gt_long( ctx.potential_hits, 0 );
+}
 
-  TEST_END();
-  rtems_test_exit(0);
+static rtems_task Init( rtems_task_argument argument )
+{
+  rtems_test_run( argument, TEST_STATE );
 }
 
 /* configuration information */
@@ -81,10 +126,7 @@ rtems_task Init(
 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
 
-#define CONFIGURE_MAXIMUM_TASKS       2
-#define CONFIGURE_MAXIMUM_TIMERS      1
-#define CONFIGURE_MAXIMUM_SEMAPHORES  1
-#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
+#define CONFIGURE_MAXIMUM_TASKS       1
 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
 
 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
diff --git a/testsuites/sptests/spintrcritical12/spintrcritical12.scn b/testsuites/sptests/spintrcritical12/spintrcritical12.scn
index 6b04a9ee7b..6447d63fbe 100644
--- a/testsuites/sptests/spintrcritical12/spintrcritical12.scn
+++ b/testsuites/sptests/spintrcritical12/spintrcritical12.scn
@@ -1,6 +1,24 @@
-*** TEST INTERRUPT CRITICAL SECTION 12 ***
-Init - Test may not be able to detect case is hit reliably
-Init - Trying to generate event send from ISR while blocking
-Init - Variation is: Event All condition
-Support - rtems_timer_create - creating timer 1
-*** END OF TEST INTERRUPT CRITICAL SECTION 12 ***
+*** BEGIN OF TEST SPINTRCRITICAL 12 ***
+*** TEST VERSION: 6.0.0.929e49a54ab4d2d18c9fb8d03610614f63e25b8d
+*** TEST STATE: EXPECTED_PASS
+*** TEST BUILD: RTEMS_DEBUG RTEMS_POSIX_API RTEMS_SMP
+*** TEST TOOLS: 10.0.1 20200406 (RTEMS 6, RSB bec88a6dd856892c3e66e4598252ea07d7a0d762, Newlib ece49e4)
+A:SPINTRCRITICAL 12
+S:Platform:RTEMS
+S:Compiler:10.0.1 20200406 (RTEMS 6, RSB bec88a6dd856892c3e66e4598252ea07d7a0d762, Newlib ece49e4)
+S:Version:6.0.0.929e49a54ab4d2d18c9fb8d03610614f63e25b8d
+S:BSP:realview_pbx_a9_qemu
+S:RTEMS_DEBUG:1
+S:RTEMS_MULTIPROCESSING:0
+S:RTEMS_POSIX_API:1
+S:RTEMS_PROFILING:0
+S:RTEMS_SMP:1
+B:EventReceiveInterruptAll
+P:0:0:UI1:spintrcritical11impl.h:113
+L:potential hits = 999
+P:1:0:UI1:spintrcritical11impl.h:116
+E:EventReceiveInterruptAll:N:2:F:0:D:1.057546
+Z:SPINTRCRITICAL 12:C:1:N:2:F:0:D:1.058728
+Y:ReportHash:SHA256:3b2267f65c7604b1fbf3da33492b23a658b32021755868bcf69b04fe69c7f85d
+
+*** END OF TEST SPINTRCRITICAL 12 ***
-- 
2.26.2



More information about the devel mailing list