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(EVENT_ANY)
0041 #define TEST_NAME "11"
0042 #define TEST_STRING Any
0043 #define EVENTS_TO_SEND 0x1
0044 #define EVENTS_TO_RECEIVE 0x3
0045
0046 #elif defined(EVENT_ALL)
0047 #define TEST_NAME "12"
0048 #define TEST_STRING All
0049 #define EVENTS_TO_SEND 0x3
0050 #define EVENTS_TO_RECEIVE 0x3
0051
0052 #else
0053 #error "Test Mode not defined"
0054
0055 #endif
0056
0057 const char rtems_test_name[] = "SPINTRCRITICAL " TEST_NAME;
0058
0059 typedef struct {
0060 rtems_id main_task;
0061 long potential_hits;
0062 volatile bool early;
0063 volatile bool late;
0064 } test_context;
0065
0066 static T_interrupt_test_state interrupt( void *arg )
0067 {
0068 test_context *ctx;
0069 T_interrupt_test_state state;
0070 rtems_status_code sc;
0071
0072 state = T_interrupt_test_get_state();
0073
0074 if ( state != T_INTERRUPT_TEST_ACTION ) {
0075 return T_INTERRUPT_TEST_CONTINUE;
0076 }
0077
0078 ctx = arg;
0079 sc = rtems_event_send( ctx->main_task, EVENTS_TO_SEND );
0080 T_quiet_rsc_success( sc );
0081
0082 if ( ctx->early ) {
0083 state = T_INTERRUPT_TEST_EARLY;
0084 } else if ( ctx->late ) {
0085 state = T_INTERRUPT_TEST_LATE;
0086 } else {
0087 ++ctx->potential_hits;
0088 state = T_INTERRUPT_TEST_CONTINUE;
0089 }
0090
0091 return state;
0092 }
0093
0094 static void prepare( void *arg )
0095 {
0096 test_context *ctx;
0097 rtems_event_set out;
0098
0099 ctx = arg;
0100 ctx->early = true;
0101 ctx->late = false;
0102 (void ) rtems_event_receive( RTEMS_PENDING_EVENTS, RTEMS_NO_WAIT, 0, &out );
0103 }
0104
0105 static void action( void *arg )
0106 {
0107 test_context *ctx;
0108 rtems_event_set out;
0109
0110 ctx = arg;
0111 ctx->early = false;
0112 (void ) rtems_event_receive( EVENTS_TO_RECEIVE, RTEMS_EVENT_ANY, 1, &out );
0113 ctx->late = true;
0114 }
0115
0116 static const T_interrupt_test_config config = {
0117 .prepare = prepare,
0118 .action = action,
0119 .interrupt = interrupt,
0120 .max_iteration_count = 1000
0121 };
0122
0123 T_TEST_CASE( RTEMS_XCONCAT( EventReceiveInterrupt, TEST_STRING ) )
0124 {
0125 test_context ctx;
0126 T_interrupt_test_state state;
0127
0128 memset( &ctx, 0, sizeof( ctx ) );
0129 ctx.main_task = rtems_task_self();
0130
0131 state = T_interrupt_test( &config, &ctx );
0132 T_eq_int( state, T_INTERRUPT_TEST_TIMEOUT );
0133
0134 T_log( T_NORMAL, "potential hits = %ld", ctx.potential_hits );
0135 T_gt_long( ctx.potential_hits, 0 );
0136 }
0137
0138 static rtems_task Init( rtems_task_argument argument )
0139 {
0140 rtems_test_run( argument, TEST_STATE );
0141 }
0142
0143
0144
0145 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0146 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
0147
0148 #define CONFIGURE_MAXIMUM_TASKS 1
0149 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0150
0151 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0152 #define CONFIGURE_MICROSECONDS_PER_TICK 1000
0153
0154 #define CONFIGURE_INIT
0155 #include <rtems/confdefs.h>
0156
0157