File indexing completed on 2025-05-11 08:24:47
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 #ifdef HAVE_CONFIG_H
0032 #include "config.h"
0033 #endif
0034
0035 #include <string.h>
0036
0037 #include <rtems/test.h>
0038 #include <rtems/test-info.h>
0039
0040 #if defined(FIRE_AFTER)
0041 #define TEST_NAME "13"
0042 #define TEST_STRING TimerFireAfterInterrupt
0043 #define TEST_DIRECTIVE rtems_timer_fire_after
0044
0045 #elif defined(SERVER_FIRE_AFTER)
0046 #define TEST_NAME "14"
0047 #define TEST_STRING TimerServerFireAfterInterrupt
0048 #define TEST_DIRECTIVE rtems_timer_server_fire_after
0049
0050 #else
0051 #error "Test Mode not defined"
0052 #endif
0053
0054 const char rtems_test_name[] = "SPINTRCRITICAL " TEST_NAME;
0055
0056 typedef struct {
0057 rtems_id timer;
0058 long potential_hits;
0059 volatile bool early;
0060 volatile bool late;
0061 } test_context;
0062
0063 static rtems_timer_service_routine TimerMethod(
0064 rtems_id timer,
0065 void *arg
0066 )
0067 {
0068 (void) timer;
0069 (void) arg;
0070 }
0071
0072 static T_interrupt_test_state interrupt( void *arg )
0073 {
0074 test_context *ctx;
0075 rtems_status_code sc;
0076 T_interrupt_test_state state;
0077
0078 state = T_interrupt_test_get_state();
0079
0080 if ( state != T_INTERRUPT_TEST_ACTION ) {
0081 return T_INTERRUPT_TEST_CONTINUE;
0082 }
0083
0084 ctx = arg;
0085 sc = TEST_DIRECTIVE( ctx->timer, 10, TimerMethod, NULL );
0086 T_quiet_rsc_success( sc );
0087
0088 if ( ctx->early ) {
0089 state = T_INTERRUPT_TEST_EARLY;
0090 } else if ( ctx->late ) {
0091 state = T_INTERRUPT_TEST_LATE;
0092 } else {
0093 ++ctx->potential_hits;
0094
0095 if ( ctx->potential_hits > 13 ) {
0096 state = T_INTERRUPT_TEST_DONE;
0097 } else {
0098 state = T_INTERRUPT_TEST_CONTINUE;
0099 }
0100 }
0101
0102 return state;
0103 }
0104
0105 static void prepare( void *arg )
0106 {
0107 test_context *ctx;
0108
0109 ctx = arg;
0110 ctx->early = true;
0111 ctx->late = false;
0112 }
0113
0114 static void action( void *arg )
0115 {
0116 test_context *ctx;
0117 rtems_status_code sc;
0118
0119 ctx = arg;
0120 ctx->early = false;
0121 sc = TEST_DIRECTIVE( ctx->timer, 10, TimerMethod, NULL );
0122 T_quiet_rsc_success( sc );
0123 ctx->late = true;
0124
0125 T_interrupt_test_busy_wait_for_interrupt();
0126 }
0127
0128 static const T_interrupt_test_config config = {
0129 .prepare = prepare,
0130 .action = action,
0131 .interrupt = interrupt,
0132 .max_iteration_count = 10000
0133 };
0134
0135 T_TEST_CASE( TEST_STRING )
0136 {
0137 test_context ctx;
0138 rtems_status_code sc;
0139 T_interrupt_test_state state;
0140
0141 memset( &ctx, 0, sizeof( ctx ) );
0142
0143 sc = rtems_timer_create(
0144 rtems_build_name( 'P', 'E', 'R', '1' ),
0145 &ctx.timer
0146 );
0147 T_assert_rsc_success( sc );
0148
0149 state = T_interrupt_test( &config, &ctx );
0150 T_eq_int( state, T_INTERRUPT_TEST_DONE );
0151
0152 sc = rtems_timer_delete( ctx.timer );
0153 T_rsc_success( sc );
0154 }
0155
0156 static rtems_task Init( rtems_task_argument argument )
0157 {
0158 #if defined(SERVER_FIRE_AFTER)
0159 (void) rtems_timer_initiate_server(
0160 RTEMS_MINIMUM_PRIORITY,
0161 RTEMS_MINIMUM_STACK_SIZE,
0162 RTEMS_DEFAULT_ATTRIBUTES
0163 );
0164 #endif
0165
0166 rtems_test_run( argument, TEST_STATE );
0167 }
0168
0169
0170
0171 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0172 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
0173
0174 #if defined(SERVER_FIRE_AFTER)
0175 #define CONFIGURE_MAXIMUM_TASKS 3
0176 #else
0177 #define CONFIGURE_MAXIMUM_TASKS 2
0178 #endif
0179 #define CONFIGURE_MAXIMUM_TIMERS 1
0180 #define CONFIGURE_MICROSECONDS_PER_TICK 1000
0181 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0182
0183 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0184
0185 #define CONFIGURE_INIT
0186 #include <rtems/confdefs.h>
0187
0188