[PATCH 24/33] spintrcritical13/14: Use T_interrupt_test()
Sebastian Huber
sebastian.huber at embedded-brains.de
Tue Jul 21 15:04:41 UTC 2020
---
testsuites/sptests/Makefile.am | 7 +-
.../spintrcritical13/spintrcritical13.scn | 31 +++-
.../spintrcritical13/spintrcritical13impl.h | 150 ++++++++++++------
.../spintrcritical14/spintrcritical14.scn | 31 +++-
4 files changed, 151 insertions(+), 68 deletions(-)
diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index f9dcd0d570..7dbc829ddf 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 712706caae..8181218b5f 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 e284d3c33d..b378937801 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/simple-test.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,120 @@
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;
-
- (void) arg;
+ test_context *ctx;
- sc = TEST_DIRECTIVE( Timer, 10, TimerMethod, NULL );
- rtems_test_assert( sc == RTEMS_SUCCESSFUL );
-
- return false;
+ ctx = arg;
+ ctx->early = true;
+ ctx->late = false;
}
-rtems_task Init(
- rtems_task_argument ignored
-)
+static void action( void *arg )
{
- rtems_status_code sc;
+ test_context *ctx;
+ rtems_status_code sc;
+ T_interrupt_test_state state;
+
+ ctx = arg;
+ ctx->early = false;
+ sc = TEST_DIRECTIVE( ctx->timer, 10, TimerMethod, NULL );
+ T_quiet_rsc_success( sc );
+ ctx->late = true;
+
+ do {
+ state = T_interrupt_test_get_state();
+ } while (state == T_INTERRUPT_TEST_ACTION);
+}
- TEST_BEGIN();
+static const T_interrupt_test_config config = {
+ .prepare = prepare,
+ .action = action,
+ .interrupt = interrupt,
+ .max_iteration_count = 10000
+};
- puts( "Init - Trying to generate timer fire from ISR while firing" );
- puts( "Init - Variation is: " TEST_STRING );
+T_TEST_CASE( TEST_STRING )
+{
+ test_context ctx;
+ rtems_status_code sc;
+ T_interrupt_test_state state;
- puts( "Init - There is no way for the test to know if it hits the case" );
+ memset( &ctx, 0, sizeof( ctx ) );
- #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
+ sc = rtems_timer_create(
+ rtems_build_name( 'P', 'E', 'R', '1' ),
+ &ctx.timer
+ );
+ T_assert_rsc_success( sc );
- puts( "Init - rtems_timer_create - OK" );
- sc = rtems_timer_create( rtems_build_name( 'P', 'E', 'R', '1' ), &Timer);
- directive_failed( sc, "rtems_timer_create" );
+ state = T_interrupt_test( &config, &ctx );
+ T_eq_int( state, T_INTERRUPT_TEST_DONE );
- interrupt_critical_section_test( test_body, NULL, test_release_from_isr );
+ sc = rtems_timer_delete( ctx.timer );
+ T_rsc_success( sc );
+}
+
+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 +160,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 43079695f5..3f4aca3959 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 ***
--
2.26.2
More information about the devel
mailing list