[rtems commit] spintrcritical13/14: Use T_interrupt_test()

Sebastian Huber sebh at rtems.org
Thu Jul 23 08:57:41 UTC 2020


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Jul 20 16:35:04 2020 +0200

spintrcritical13/14: Use T_interrupt_test()

---

 testsuites/sptests/Makefile.am                     |   7 +-
 .../sptests/spintrcritical13/spintrcritical13.scn  |  31 ++++-
 .../spintrcritical13/spintrcritical13impl.h        | 145 ++++++++++++++-------
 .../sptests/spintrcritical14/spintrcritical14.scn  |  31 ++++-
 4 files changed, 147 insertions(+), 67 deletions(-)

diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index f9dcd0d..7dbc829 100644
--- a/testsuites/sptests/Makefile.am
+++ b/testsuites/sptests/Makefile.am
@@ -1290,9 +1290,7 @@ if TEST_spintrcritical13
 sp_tests += spintrcritical13
 sp_screens += spintrcritical13/spintrcritical13.scn
 sp_docs += spintrcritical13/spintrcritical13.doc
-spintrcritical13_SOURCES = spintrcritical13/init.c \
-	spintrcritical_support/intrcritical.c \
-	spintrcritical_support/intrcritical.h
+spintrcritical13_SOURCES = spintrcritical13/init.c
 spintrcritical13_CPPFLAGS = $(AM_CPPFLAGS) \
 	$(TEST_FLAGS_spintrcritical13) $(support_includes) \
 	-I$(top_srcdir)/spintrcritical_support
@@ -1302,8 +1300,7 @@ if TEST_spintrcritical14
 sp_tests += spintrcritical14
 sp_screens += spintrcritical14/spintrcritical14.scn
 sp_docs += spintrcritical14/spintrcritical14.doc
-spintrcritical14_SOURCES = spintrcritical14/init.c \
-	spintrcritical_support/intrcritical.c
+spintrcritical14_SOURCES = spintrcritical14/init.c
 spintrcritical14_CPPFLAGS = $(AM_CPPFLAGS) \
 	$(TEST_FLAGS_spintrcritical14) $(support_includes) \
 	-I$(top_srcdir)/spintrcritical_support
diff --git a/testsuites/sptests/spintrcritical13/spintrcritical13.scn b/testsuites/sptests/spintrcritical13/spintrcritical13.scn
index 712706c..8181218 100644
--- a/testsuites/sptests/spintrcritical13/spintrcritical13.scn
+++ b/testsuites/sptests/spintrcritical13/spintrcritical13.scn
@@ -1,7 +1,24 @@
-*** TEST INTERRUPT CRITICAL SECTION 13 ***
-Init - Trying to generate timer fire from ISR while firing
-Init - Variation is: Timer Fire After
-Init - There is no way for the test to know if it hits the case
-Init - rtems_timer_create - OK
-Support - rtems_timer_create - creating timer 1
-*** END OF TEST INTERRUPT CRITICAL SECTION 13 ***
+*** BEGIN OF TEST SPINTRCRITICAL 13 ***
+*** 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 13
+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:TimerFireAfterInterrupt
+P:0:0:UI1:spintrcritical13impl.h:131
+P:1:0:UI1:spintrcritical13impl.h:134
+P:2:0:UI1:spintrcritical13impl.h:137
+E:TimerFireAfterInterrupt:N:3:F:0:D:0.116053
+Z:SPINTRCRITICAL 13:C:1:N:3:F:0:D:0.117144
+Y:ReportHash:SHA256:66bf247c36962dc930b099cc4979215b4cadb41edd8925097a91e8e7a4356725
+
+*** END OF TEST SPINTRCRITICAL 13 ***
diff --git a/testsuites/sptests/spintrcritical13/spintrcritical13impl.h b/testsuites/sptests/spintrcritical13/spintrcritical13impl.h
index e284d3c..55fc964 100644
--- a/testsuites/sptests/spintrcritical13/spintrcritical13impl.h
+++ b/testsuites/sptests/spintrcritical13/spintrcritical13impl.h
@@ -1,4 +1,6 @@
 /*
+ *  Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
+ *
  *  COPYRIGHT (c) 1989-2009.
  *  On-Line Applications Research Corporation (OAR).
  *
@@ -11,17 +13,19 @@
 #include "config.h"
 #endif
 
-#include <tmacros.h>
-#include <intrcritical.h>
+#include <string.h>
+
+#include <rtems/test.h>
+#include <rtems/test-info.h>
 
 #if defined(FIRE_AFTER)
   #define TEST_NAME          "13"
-  #define TEST_STRING        "Timer Fire After"
+  #define TEST_STRING        TimerFireAfterInterrupt
   #define TEST_DIRECTIVE     rtems_timer_fire_after
 
 #elif defined(SERVER_FIRE_AFTER)
   #define TEST_NAME          "14"
-  #define TEST_STRING        "Timer Server Fire After"
+  #define TEST_STRING        TimerServerFireAfterInterrupt
   #define TEST_DIRECTIVE     rtems_timer_server_fire_after
 
 #else
@@ -30,71 +34,117 @@
 
 const char rtems_test_name[] = "SPINTRCRITICAL " TEST_NAME;
 
-/* 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);
-rtems_timer_service_routine TimerMethod(rtems_id  timer, void *arg);
-
-rtems_id Timer;
+typedef struct {
+  rtems_id timer;
+  long potential_hits;
+  volatile bool early;
+  volatile bool late;
+} test_context;
 
-rtems_timer_service_routine TimerMethod(
+static rtems_timer_service_routine TimerMethod(
   rtems_id  timer,
   void     *arg
 )
 {
+  (void) timer;
+  (void) arg;
 }
 
-rtems_timer_service_routine test_release_from_isr(
-  rtems_id  timer,
-  void     *arg
-)
+static T_interrupt_test_state interrupt( void *arg )
 {
-  (void) rtems_timer_fire_after( Timer, 10, TimerMethod, NULL );
+  test_context           *ctx;
+  rtems_status_code       sc;
+  T_interrupt_test_state  state;
+
+  state = T_interrupt_test_get_state();
+
+  if ( state != T_INTERRUPT_TEST_ACTION ) {
+    return T_INTERRUPT_TEST_CONTINUE;
+  }
+
+  ctx = arg;
+  sc = TEST_DIRECTIVE( ctx->timer, 10, TimerMethod, NULL );
+  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;
+
+    if ( ctx->potential_hits > 13 ) {
+      state = T_INTERRUPT_TEST_DONE;
+    } else {
+      state = T_INTERRUPT_TEST_CONTINUE;
+    }
+  }
+
+  return state;
 }
 
-static bool test_body( void *arg )
+static void prepare( void *arg )
 {
-  rtems_status_code sc;
+  test_context *ctx;
 
-  (void) arg;
+  ctx = arg;
+  ctx->early = true;
+  ctx->late = false;
+}
 
-  sc = TEST_DIRECTIVE( Timer, 10, TimerMethod, NULL );
-  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
+static void action( void *arg )
+{
+  test_context      *ctx;
+  rtems_status_code  sc;
+
+  ctx = arg;
+  ctx->early = false;
+  sc = TEST_DIRECTIVE( ctx->timer, 10, TimerMethod, NULL );
+  T_quiet_rsc_success( sc );
+  ctx->late = true;
 
-  return false;
+  T_interrupt_test_busy_wait_for_interrupt();
 }
 
-rtems_task Init(
-  rtems_task_argument ignored
-)
-{
-  rtems_status_code     sc;
+static const T_interrupt_test_config config = {
+  .prepare = prepare,
+  .action = action,
+  .interrupt = interrupt,
+  .max_iteration_count = 10000
+};
 
-  TEST_BEGIN();
+T_TEST_CASE( TEST_STRING )
+{
+  test_context           ctx;
+  rtems_status_code      sc;
+  T_interrupt_test_state state;
 
-  puts( "Init - Trying to generate timer fire from ISR while firing" );
-  puts( "Init - Variation is: " TEST_STRING );
+  memset( &ctx, 0, sizeof( ctx ) );
 
-  puts( "Init - There is no way for the test to know if it hits the case" );
+  sc = rtems_timer_create(
+    rtems_build_name( 'P', 'E', 'R', '1' ),
+    &ctx.timer
+  );
+  T_assert_rsc_success( sc );
 
-  #if defined(SERVER_FIRE_AFTER)
-   /* initiate timer server */
-    sc = rtems_timer_initiate_server(
-      RTEMS_MINIMUM_PRIORITY,
-      RTEMS_MINIMUM_STACK_SIZE,
-      RTEMS_DEFAULT_ATTRIBUTES
-    );
-    directive_failed( sc, "rtems_timer_initiate_server" );
-  #endif
+  state = T_interrupt_test( &config, &ctx );
+  T_eq_int( state, T_INTERRUPT_TEST_DONE );
 
-  puts( "Init - rtems_timer_create - OK" );
-  sc = rtems_timer_create( rtems_build_name( 'P', 'E', 'R', '1' ), &Timer);
-  directive_failed( sc, "rtems_timer_create" );
+  sc = rtems_timer_delete( ctx.timer );
+  T_rsc_success( sc );
+}
 
-  interrupt_critical_section_test( test_body, NULL, test_release_from_isr );
+static rtems_task Init( rtems_task_argument argument )
+{
+#if defined(SERVER_FIRE_AFTER)
+  (void) rtems_timer_initiate_server(
+    RTEMS_MINIMUM_PRIORITY,
+    RTEMS_MINIMUM_STACK_SIZE,
+    RTEMS_DEFAULT_ATTRIBUTES
+  );
+#endif
 
-  TEST_END();
-  rtems_test_exit(0);
+  rtems_test_run( argument, TEST_STATE );
 }
 
 /* configuration information */
@@ -107,8 +157,7 @@ rtems_task Init(
 #else
   #define CONFIGURE_MAXIMUM_TASKS     2
 #endif
-#define CONFIGURE_MAXIMUM_TIMERS      2
-#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
+#define CONFIGURE_MAXIMUM_TIMERS      1
 #define CONFIGURE_MICROSECONDS_PER_TICK  1000
 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
 
diff --git a/testsuites/sptests/spintrcritical14/spintrcritical14.scn b/testsuites/sptests/spintrcritical14/spintrcritical14.scn
index 4307969..3f4aca3 100644
--- a/testsuites/sptests/spintrcritical14/spintrcritical14.scn
+++ b/testsuites/sptests/spintrcritical14/spintrcritical14.scn
@@ -1,7 +1,24 @@
-*** TEST INTERRUPT CRITICAL SECTION 14 ***
-Init - Trying to generate timer fire from ISR while firing
-Init - Variation is: Timer Server Fire After
-Init - There is no way for the test to know if it hits the case
-Init - rtems_timer_create - OK
-Support - rtems_timer_create - creating timer 1
-*** END OF TEST INTERRUPT CRITICAL SECTION 14 ***
+*** BEGIN OF TEST SPINTRCRITICAL 14 ***
+*** 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 14
+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:TimerServerFireAfterInterrupt
+P:0:0:UI1:spintrcritical13impl.h:131
+P:1:0:UI1:spintrcritical13impl.h:134
+P:2:0:UI1:spintrcritical13impl.h:137
+E:TimerServerFireAfterInterrupt:N:3:F:0:D:0.086586
+Z:SPINTRCRITICAL 14:C:1:N:3:F:0:D:0.087802
+Y:ReportHash:SHA256:d6f998056acf55838c88d67702cb4fee07f862f8d2eaa9638a606bd9da4d5c17
+
+*** END OF TEST SPINTRCRITICAL 14 ***



More information about the vc mailing list