[PATCH 18/33] spintrcritical01/2/3/4/5: Use T_interrupt_test()

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


---
 testsuites/sptests/Makefile.am                |  16 +--
 .../spintrcritical01/spintrcritical01.scn     |  30 ++++-
 .../spintrcritical01/spintrcritical01impl.h   | 121 ++++++++++--------
 .../spintrcritical02/spintrcritical02.scn     |  30 ++++-
 .../spintrcritical03/spintrcritical03.scn     |  30 ++++-
 .../spintrcritical04/spintrcritical04.scn     |  30 ++++-
 .../spintrcritical05/spintrcritical05.scn     |  30 ++++-
 7 files changed, 191 insertions(+), 96 deletions(-)

diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index 62bb1aa685..3bdb0fe232 100644
--- a/testsuites/sptests/Makefile.am
+++ b/testsuites/sptests/Makefile.am
@@ -1190,9 +1190,7 @@ if TEST_spintrcritical01
 sp_tests += spintrcritical01
 sp_screens += spintrcritical01/spintrcritical01.scn
 sp_docs += spintrcritical01/spintrcritical01.doc
-spintrcritical01_SOURCES = spintrcritical01/init.c \
-	spintrcritical_support/intrcritical.c \
-	spintrcritical_support/intrcritical.h
+spintrcritical01_SOURCES = spintrcritical01/init.c
 spintrcritical01_CPPFLAGS = $(AM_CPPFLAGS) \
 	$(TEST_FLAGS_spintrcritical01) $(support_includes) \
 	-I$(top_srcdir)/spintrcritical_support
@@ -1202,8 +1200,7 @@ if TEST_spintrcritical02
 sp_tests += spintrcritical02
 sp_screens += spintrcritical02/spintrcritical02.scn
 sp_docs += spintrcritical02/spintrcritical02.doc
-spintrcritical02_SOURCES = spintrcritical02/init.c \
-	spintrcritical_support/intrcritical.c
+spintrcritical02_SOURCES = spintrcritical02/init.c
 spintrcritical02_CPPFLAGS = $(AM_CPPFLAGS) \
 	$(TEST_FLAGS_spintrcritical02) $(support_includes) \
 	-I$(top_srcdir)/spintrcritical_support
@@ -1213,8 +1210,7 @@ if TEST_spintrcritical03
 sp_tests += spintrcritical03
 sp_screens += spintrcritical03/spintrcritical03.scn
 sp_docs += spintrcritical03/spintrcritical03.doc
-spintrcritical03_SOURCES = spintrcritical03/init.c \
-	spintrcritical_support/intrcritical.c
+spintrcritical03_SOURCES = spintrcritical03/init.c
 spintrcritical03_CPPFLAGS = $(AM_CPPFLAGS) \
 	$(TEST_FLAGS_spintrcritical03) $(support_includes) \
 	-I$(top_srcdir)/spintrcritical_support
@@ -1224,8 +1220,7 @@ if TEST_spintrcritical04
 sp_tests += spintrcritical04
 sp_screens += spintrcritical04/spintrcritical04.scn
 sp_docs += spintrcritical04/spintrcritical04.doc
-spintrcritical04_SOURCES = spintrcritical04/init.c \
-	spintrcritical_support/intrcritical.c
+spintrcritical04_SOURCES = spintrcritical04/init.c
 spintrcritical04_CPPFLAGS = $(AM_CPPFLAGS) \
 	$(TEST_FLAGS_spintrcritical04) $(support_includes) \
 	-I$(top_srcdir)/spintrcritical_support
@@ -1235,8 +1230,7 @@ if TEST_spintrcritical05
 sp_tests += spintrcritical05
 sp_screens += spintrcritical05/spintrcritical05.scn
 sp_docs += spintrcritical05/spintrcritical05.doc
-spintrcritical05_SOURCES = spintrcritical05/init.c \
-	spintrcritical_support/intrcritical.c
+spintrcritical05_SOURCES = spintrcritical05/init.c
 spintrcritical05_CPPFLAGS = $(AM_CPPFLAGS) \
 	$(TEST_FLAGS_spintrcritical05) $(support_includes) \
 	-I$(top_srcdir)/spintrcritical_support
diff --git a/testsuites/sptests/spintrcritical01/spintrcritical01.scn b/testsuites/sptests/spintrcritical01/spintrcritical01.scn
index cb51f99ae7..417c078724 100644
--- a/testsuites/sptests/spintrcritical01/spintrcritical01.scn
+++ b/testsuites/sptests/spintrcritical01/spintrcritical01.scn
@@ -1,6 +1,24 @@
-*** TEST INTERRUPT CRITICAL SECTION 01 ***
-Init - Trying to generate semaphore release from ISR while blocking
-Init - Variation is: FIFO/Without Timeout
-Support - rtems_timer_create - creating timer 1
-Init - Case hit
-*** END OF TEST INTERRUPT CRITICAL SECTION 01 ***
+*** BEGIN OF TEST SPINTRCRITICAL 1 ***
+*** 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 1
+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:SemaphoreReleaseFIFOWithoutTimeout
+P:0:0:UI1:spintrcritical01impl.h:133
+P:1:0:UI1:spintrcritical01impl.h:136
+P:2:0:UI1:spintrcritical01impl.h:139
+E:SemaphoreReleaseFIFOWithoutTimeout:N:3:F:0:D:0.991790
+Z:SPINTRCRITICAL 1:C:1:N:3:F:0:D:0.992984
+Y:ReportHash:SHA256:5ae7281f5dd710e1c043bbff2fa3ddff47dc22aa5c35cff545601c8156ec1a87
+
+*** END OF TEST SPINTRCRITICAL 1 ***
diff --git a/testsuites/sptests/spintrcritical01/spintrcritical01impl.h b/testsuites/sptests/spintrcritical01/spintrcritical01impl.h
index 5c480b4bb3..3f66143b74 100644
--- a/testsuites/sptests/spintrcritical01/spintrcritical01impl.h
+++ b/testsuites/sptests/spintrcritical01/spintrcritical01impl.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,38 +13,38 @@
 #include "config.h"
 #endif
 
-#include <tmacros.h>
-#include <intrcritical.h>
+#include <rtems/test.h>
+#include <rtems/simple-test.h>
 
 #include <rtems/score/threadimpl.h>
 
 #if defined(FIFO_NO_TIMEOUT)
   #define TEST_NAME                "1"
-  #define TEST_STRING              "FIFO/Without Timeout"
+  #define TEST_STRING              FIFOWithoutTimeout
   #define SEMAPHORE_OBTAIN_TIMEOUT 0
   #define SEMAPHORE_ATTRIBUTES     RTEMS_DEFAULT_ATTRIBUTES
 
 #elif defined(FIFO_WITH_TIMEOUT)
   #define TEST_NAME                "2"
-  #define TEST_STRING              "FIFO/With Timeout"
+  #define TEST_STRING              FIFOWithTimeout
   #define SEMAPHORE_OBTAIN_TIMEOUT 10
   #define SEMAPHORE_ATTRIBUTES     RTEMS_DEFAULT_ATTRIBUTES
 
 #elif defined(PRIORITY_NO_TIMEOUT)
   #define TEST_NAME                "3"
-  #define TEST_STRING              "Priority/Without Timeout"
+  #define TEST_STRING              PriorityWithoutTimeout
   #define SEMAPHORE_OBTAIN_TIMEOUT 0
   #define SEMAPHORE_ATTRIBUTES     RTEMS_PRIORITY
 
 #elif defined(PRIORITY_WITH_TIMEOUT)
   #define TEST_NAME                "4"
-  #define TEST_STRING              "Priority/With Timeout"
+  #define TEST_STRING              PriorityWithTimeout
   #define SEMAPHORE_OBTAIN_TIMEOUT 10
   #define SEMAPHORE_ATTRIBUTES     RTEMS_PRIORITY
 
 #elif defined(PRIORITY_NO_TIMEOUT_REVERSE)
   #define TEST_NAME                "5"
-  #define TEST_STRING              "Priority/Without Timeout (Reverse)"
+  #define TEST_STRING              PriorityWithoutTimeoutReverse
   #define SEMAPHORE_OBTAIN_TIMEOUT 0
   #define SEMAPHORE_ATTRIBUTES     RTEMS_PRIORITY
 
@@ -53,82 +55,93 @@
 
 const char rtems_test_name[] = "SPINTRCRITICAL " TEST_NAME;
 
-static Thread_Control *thread;
-
-static rtems_id Semaphore;
+typedef struct {
+  Thread_Control *thread;
+  rtems_id        semaphore;
+} test_context;
 
-static bool case_hit;
-
-static bool interrupts_blocking_op(void)
+static bool is_blocked( Thread_Wait_flags flags )
 {
-  Thread_Wait_flags flags = _Thread_Wait_flags_get( thread );
-
-  return
-    flags == ( THREAD_WAIT_CLASS_OBJECT | THREAD_WAIT_STATE_INTEND_TO_BLOCK );
+  return flags == ( THREAD_WAIT_CLASS_OBJECT | THREAD_WAIT_STATE_BLOCKED );
 }
 
-static rtems_timer_service_routine test_release_from_isr(
-  rtems_id  timer,
-  void     *arg
-)
+static bool interrupts_blocking_op( Thread_Wait_flags flags )
 {
-  rtems_status_code     status;
+  return flags
+    == ( THREAD_WAIT_CLASS_OBJECT | THREAD_WAIT_STATE_INTEND_TO_BLOCK );
+}
 
-  if ( interrupts_blocking_op() ) {
-    case_hit = true;
+static T_interrupt_test_state interrupt( void *arg )
+{
+  test_context           *ctx;
+  T_interrupt_test_state  state;
+  Thread_Wait_flags       flags;
+  rtems_status_code       status;
+
+  ctx = arg;
+  flags = _Thread_Wait_flags_get( ctx->thread );
+
+  if ( interrupts_blocking_op( flags ) ) {
+    state = T_INTERRUPT_TEST_DONE;
+  } else if ( is_blocked( flags ) ) {
+    state = T_INTERRUPT_TEST_LATE;
+  } else {
+    state = T_INTERRUPT_TEST_EARLY;
   }
 
-  status = rtems_semaphore_release( Semaphore );
-  directive_failed_with_level( status, "release", -1 );
-}
+  status = rtems_semaphore_release( ctx->semaphore );
+  T_quiet_rsc_success( status );
 
+  return state;
+}
 
-static bool test_body( void *arg )
+static void action( void *arg )
 {
-  rtems_status_code status;
-
-  (void) arg;
+  test_context      *ctx;
+  rtems_status_code  status;
 
+  ctx = arg;
   status = rtems_semaphore_obtain(
-    Semaphore,
+    ctx->semaphore,
     RTEMS_DEFAULT_OPTIONS,
     SEMAPHORE_OBTAIN_TIMEOUT
   );
-  directive_failed( status, "rtems_semaphore_obtain" );
-
-  return case_hit;
+  T_quiet_rsc_success( status );
 }
 
-static rtems_task Init(
-  rtems_task_argument ignored
-)
-{
-  rtems_status_code     status;
+static const T_interrupt_test_config config = {
+  .action = action,
+  .interrupt = interrupt,
+  .max_iteration_count = 10000
+};
 
-  TEST_BEGIN();
+T_TEST_CASE( RTEMS_XCONCAT( SemaphoreRelease, TEST_STRING ) )
+{
+  test_context           ctx;
+  rtems_status_code      status;
+  T_interrupt_test_state state;
 
-  thread = _Thread_Get_executing();
+  ctx.thread = _Thread_Get_executing();
 
-  puts( "Init - Trying to generate semaphore release from ISR while blocking" );
-  puts( "Init - Variation is: " TEST_STRING );
   status = rtems_semaphore_create(
     rtems_build_name( 'S', 'M', '1', ' ' ),
     0,
     SEMAPHORE_ATTRIBUTES,
     RTEMS_NO_PRIORITY,
-    &Semaphore
+    &ctx.semaphore
   );
-  directive_failed( status, "rtems_semaphore_create of SM1" );
+  T_rsc_success( status );
 
-  interrupt_critical_section_test( test_body, NULL, test_release_from_isr );
+  state = T_interrupt_test( &config, &ctx );
+  T_eq_int( state, T_INTERRUPT_TEST_DONE );
 
-  if ( case_hit ) {
-    puts( "Init - Case hit" );
-    TEST_END();
-  } else
-    puts( "Init - Case not hit - ran too long" );
+  rtems_semaphore_delete( ctx.semaphore );
+  T_rsc_success( status );
+}
 
-  rtems_test_exit(0);
+static rtems_task Init( rtems_task_argument argument )
+{
+  rtems_test_run( argument, TEST_STATE );
 }
 
 /* configuration information */
@@ -137,9 +150,7 @@ static rtems_task Init(
 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
 
 #define CONFIGURE_MAXIMUM_TASKS       1
-#define CONFIGURE_MAXIMUM_TIMERS      1
 #define CONFIGURE_MAXIMUM_SEMAPHORES  1
-#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
 #define CONFIGURE_MICROSECONDS_PER_TICK  1000
 #if defined(PRIORITY_NO_TIMEOUT_REVERSE)
   #define CONFIGURE_INIT_TASK_PRIORITY   250
diff --git a/testsuites/sptests/spintrcritical02/spintrcritical02.scn b/testsuites/sptests/spintrcritical02/spintrcritical02.scn
index ed16ba3f43..3fdb60d20b 100644
--- a/testsuites/sptests/spintrcritical02/spintrcritical02.scn
+++ b/testsuites/sptests/spintrcritical02/spintrcritical02.scn
@@ -1,6 +1,24 @@
-*** TEST INTERRUPT CRITICAL SECTION 02 ***
-Init - Trying to generate semaphore release from ISR while blocking
-Init - Variation is: FIFO/With Timeout
-Support - rtems_timer_create - creating timer 1
-Init - Case hit
-*** END OF TEST INTERRUPT CRITICAL SECTION 02 ***
+*** BEGIN OF TEST SPINTRCRITICAL 2 ***
+*** 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 2
+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:SemaphoreReleaseFIFOWithTimeout
+P:0:0:UI1:spintrcritical01impl.h:133
+P:1:0:UI1:spintrcritical01impl.h:136
+P:2:0:UI1:spintrcritical01impl.h:139
+E:SemaphoreReleaseFIFOWithTimeout:N:3:F:0:D:0.993665
+Z:SPINTRCRITICAL 2:C:1:N:3:F:0:D:0.994790
+Y:ReportHash:SHA256:39afd278c3a718205440e47e93954d7a87f2bbd49fbae108199b2dbdaeadc79e
+
+*** END OF TEST SPINTRCRITICAL 2 ***
diff --git a/testsuites/sptests/spintrcritical03/spintrcritical03.scn b/testsuites/sptests/spintrcritical03/spintrcritical03.scn
index 65b8eace3b..0d28186110 100644
--- a/testsuites/sptests/spintrcritical03/spintrcritical03.scn
+++ b/testsuites/sptests/spintrcritical03/spintrcritical03.scn
@@ -1,6 +1,24 @@
-*** TEST INTERRUPT CRITICAL SECTION 03 ***
-Init - Trying to generate semaphore release from ISR while blocking
-Init - Variation is: Priority/Without Timeout
-Support - rtems_timer_create - creating timer 1
-Init - Case hit
-*** END OF TEST INTERRUPT CRITICAL SECTION 03 ***
+*** BEGIN OF TEST SPINTRCRITICAL 3 ***
+*** 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 3
+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:SemaphoreReleasePriorityWithoutTimeout
+P:0:0:UI1:spintrcritical01impl.h:133
+P:1:0:UI1:spintrcritical01impl.h:136
+P:2:0:UI1:spintrcritical01impl.h:139
+E:SemaphoreReleasePriorityWithoutTimeout:N:3:F:0:D:0.992575
+Z:SPINTRCRITICAL 3:C:1:N:3:F:0:D:0.993746
+Y:ReportHash:SHA256:99f47d1893183fe1353cf36b2de6f27e11bae6e1fe4ce30a88e2140d941f93aa
+
+*** END OF TEST SPINTRCRITICAL 3 ***
diff --git a/testsuites/sptests/spintrcritical04/spintrcritical04.scn b/testsuites/sptests/spintrcritical04/spintrcritical04.scn
index 39c54dcefa..984fe8fff6 100644
--- a/testsuites/sptests/spintrcritical04/spintrcritical04.scn
+++ b/testsuites/sptests/spintrcritical04/spintrcritical04.scn
@@ -1,6 +1,24 @@
-*** TEST INTERRUPT CRITICAL SECTION 04 ***
-Init - Trying to generate semaphore release from ISR while blocking
-Init - Variation is: Priority/With Timeout
-Support - rtems_timer_create - creating timer 1
-Init - Case hit
-*** END OF TEST INTERRUPT CRITICAL SECTION 04 ***
+*** BEGIN OF TEST SPINTRCRITICAL 4 ***
+*** 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 4
+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:SemaphoreReleasePriorityWithTimeout
+P:0:0:UI1:spintrcritical01impl.h:133
+P:1:0:UI1:spintrcritical01impl.h:136
+P:2:0:UI1:spintrcritical01impl.h:139
+E:SemaphoreReleasePriorityWithTimeout:N:3:F:0:D:0.992884
+Z:SPINTRCRITICAL 4:C:1:N:3:F:0:D:0.994078
+Y:ReportHash:SHA256:9881b621230969971c290ca60c366534be09a32a291699bcc786d1e654ce305c
+
+*** END OF TEST SPINTRCRITICAL 4 ***
diff --git a/testsuites/sptests/spintrcritical05/spintrcritical05.scn b/testsuites/sptests/spintrcritical05/spintrcritical05.scn
index 3caec8f311..e109d5ccd4 100644
--- a/testsuites/sptests/spintrcritical05/spintrcritical05.scn
+++ b/testsuites/sptests/spintrcritical05/spintrcritical05.scn
@@ -1,6 +1,24 @@
-*** TEST INTERRUPT CRITICAL SECTION 05 ***
-Init - Trying to generate semaphore release from ISR while blocking
-Init - Variation is: Priority/Without Timeout (Reverse)
-Support - rtems_timer_create - creating timer 1
-Init - Case hit
-*** END OF TEST INTERRUPT CRITICAL SECTION 05 ***
+*** BEGIN OF TEST SPINTRCRITICAL 5 ***
+*** 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 5
+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:SemaphoreReleasePriorityWithoutTimeoutReverse
+P:0:0:UI1:spintrcritical01impl.h:133
+P:1:0:UI1:spintrcritical01impl.h:136
+P:2:0:UI1:spintrcritical01impl.h:139
+E:SemaphoreReleasePriorityWithoutTimeoutReverse:N:3:F:0:D:0.992161
+Z:SPINTRCRITICAL 5:C:1:N:3:F:0:D:0.993438
+Y:ReportHash:SHA256:577ac55f827103c83e8a851796041d45d9545e7f02e49417fdb0b876108c6327
+
+*** END OF TEST SPINTRCRITICAL 5 ***
-- 
2.26.2



More information about the devel mailing list