mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-20 15:47:48 +08:00
spintrcritical13/14: Use T_interrupt_test()
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 ***
|
||||
|
||||
@@ -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);
|
||||
typedef struct {
|
||||
rtems_id timer;
|
||||
long potential_hits;
|
||||
volatile bool early;
|
||||
volatile bool late;
|
||||
} test_context;
|
||||
|
||||
rtems_id Timer;
|
||||
|
||||
rtems_timer_service_routine TimerMethod(
|
||||
static rtems_timer_service_routine TimerMethod(
|
||||
rtems_id timer,
|
||||
void *arg
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
rtems_timer_service_routine test_release_from_isr(
|
||||
rtems_id timer,
|
||||
void *arg
|
||||
)
|
||||
{
|
||||
(void) rtems_timer_fire_after( Timer, 10, TimerMethod, NULL );
|
||||
}
|
||||
|
||||
static bool test_body( void *arg )
|
||||
{
|
||||
rtems_status_code sc;
|
||||
|
||||
(void) timer;
|
||||
(void) arg;
|
||||
|
||||
sc = TEST_DIRECTIVE( Timer, 10, TimerMethod, NULL );
|
||||
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
rtems_task Init(
|
||||
rtems_task_argument ignored
|
||||
)
|
||||
static T_interrupt_test_state interrupt( void *arg )
|
||||
{
|
||||
rtems_status_code sc;
|
||||
test_context *ctx;
|
||||
rtems_status_code sc;
|
||||
T_interrupt_test_state state;
|
||||
|
||||
TEST_BEGIN();
|
||||
state = T_interrupt_test_get_state();
|
||||
|
||||
puts( "Init - Trying to generate timer fire from ISR while firing" );
|
||||
puts( "Init - Variation is: " TEST_STRING );
|
||||
if ( state != T_INTERRUPT_TEST_ACTION ) {
|
||||
return T_INTERRUPT_TEST_CONTINUE;
|
||||
}
|
||||
|
||||
puts( "Init - There is no way for the test to know if it hits the case" );
|
||||
ctx = arg;
|
||||
sc = TEST_DIRECTIVE( ctx->timer, 10, TimerMethod, NULL );
|
||||
T_quiet_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
|
||||
if ( ctx->early ) {
|
||||
state = T_INTERRUPT_TEST_EARLY;
|
||||
} else if ( ctx->late ) {
|
||||
state = T_INTERRUPT_TEST_LATE;
|
||||
} else {
|
||||
++ctx->potential_hits;
|
||||
|
||||
puts( "Init - rtems_timer_create - OK" );
|
||||
sc = rtems_timer_create( rtems_build_name( 'P', 'E', 'R', '1' ), &Timer);
|
||||
directive_failed( sc, "rtems_timer_create" );
|
||||
if ( ctx->potential_hits > 13 ) {
|
||||
state = T_INTERRUPT_TEST_DONE;
|
||||
} else {
|
||||
state = T_INTERRUPT_TEST_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
interrupt_critical_section_test( test_body, NULL, test_release_from_isr );
|
||||
return state;
|
||||
}
|
||||
|
||||
TEST_END();
|
||||
rtems_test_exit(0);
|
||||
static void prepare( void *arg )
|
||||
{
|
||||
test_context *ctx;
|
||||
|
||||
ctx = arg;
|
||||
ctx->early = true;
|
||||
ctx->late = false;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
T_interrupt_test_busy_wait_for_interrupt();
|
||||
}
|
||||
|
||||
static const T_interrupt_test_config config = {
|
||||
.prepare = prepare,
|
||||
.action = action,
|
||||
.interrupt = interrupt,
|
||||
.max_iteration_count = 10000
|
||||
};
|
||||
|
||||
T_TEST_CASE( TEST_STRING )
|
||||
{
|
||||
test_context ctx;
|
||||
rtems_status_code sc;
|
||||
T_interrupt_test_state state;
|
||||
|
||||
memset( &ctx, 0, sizeof( ctx ) );
|
||||
|
||||
sc = rtems_timer_create(
|
||||
rtems_build_name( 'P', 'E', 'R', '1' ),
|
||||
&ctx.timer
|
||||
);
|
||||
T_assert_rsc_success( sc );
|
||||
|
||||
state = T_interrupt_test( &config, &ctx );
|
||||
T_eq_int( state, T_INTERRUPT_TEST_DONE );
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -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 ***
|
||||
|
||||
Reference in New Issue
Block a user