spintrcritical11/12: Use T_interrupt_test()

This commit is contained in:
Sebastian Huber
2020-07-23 09:27:47 +02:00
parent be2f9d74cb
commit 8cbba4496a
4 changed files with 128 additions and 53 deletions
+2 -5
View File
@@ -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
@@ -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 ***
@@ -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>
#include <string.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);
rtems_id Main_task;
#include <rtems/test.h>
#include <rtems/test-info.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;
rtems_event_receive( EVENTS_TO_RECEIVE, RTEMS_EVENT_ANY, 1, &out );
return false;
ctx = arg;
ctx->early = true;
ctx->late = false;
(void ) rtems_event_receive( RTEMS_PENDING_EVENTS, RTEMS_NO_WAIT, 0, &out );
}
rtems_task Init(
rtems_task_argument ignored
)
static void action( void *arg )
{
TEST_BEGIN();
test_context *ctx;
rtems_event_set out;
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 );
ctx = arg;
ctx->early = false;
(void ) rtems_event_receive( EVENTS_TO_RECEIVE, RTEMS_EVENT_ANY, 1, &out );
ctx->late = true;
}
Main_task = rtems_task_self();
static const T_interrupt_test_config config = {
.prepare = prepare,
.action = action,
.interrupt = interrupt,
.max_iteration_count = 1000
};
interrupt_critical_section_test( test_body, NULL, test_release_from_isr );
T_TEST_CASE( RTEMS_XCONCAT( EventReceiveInterrupt, TEST_STRING ) )
{
test_context ctx;
T_interrupt_test_state state;
TEST_END();
rtems_test_exit(0);
memset( &ctx, 0, sizeof( ctx ) );
ctx.main_task = rtems_task_self();
state = T_interrupt_test( &config, &ctx );
T_eq_int( state, T_INTERRUPT_TEST_TIMEOUT );
T_log( T_NORMAL, "potential hits = %ld", ctx.potential_hits );
T_gt_long( ctx.potential_hits, 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
@@ -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 ***