Changeset 5020a28 in rtems


Ignore:
Timestamp:
Jul 20, 2020, 2:35:04 PM (3 weeks ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
1c2e05d4
Parents:
8cbba449
git-author:
Sebastian Huber <sebastian.huber@…> (07/20/20 14:35:04)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/23/20 07:27:47)
Message:

spintrcritical13/14: Use T_interrupt_test()

Location:
testsuites/sptests
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • testsuites/sptests/Makefile.am

    r8cbba449 r5020a28  
    12911291sp_screens += spintrcritical13/spintrcritical13.scn
    12921292sp_docs += spintrcritical13/spintrcritical13.doc
    1293 spintrcritical13_SOURCES = spintrcritical13/init.c \
    1294         spintrcritical_support/intrcritical.c \
    1295         spintrcritical_support/intrcritical.h
     1293spintrcritical13_SOURCES = spintrcritical13/init.c
    12961294spintrcritical13_CPPFLAGS = $(AM_CPPFLAGS) \
    12971295        $(TEST_FLAGS_spintrcritical13) $(support_includes) \
     
    13031301sp_screens += spintrcritical14/spintrcritical14.scn
    13041302sp_docs += spintrcritical14/spintrcritical14.doc
    1305 spintrcritical14_SOURCES = spintrcritical14/init.c \
    1306         spintrcritical_support/intrcritical.c
     1303spintrcritical14_SOURCES = spintrcritical14/init.c
    13071304spintrcritical14_CPPFLAGS = $(AM_CPPFLAGS) \
    13081305        $(TEST_FLAGS_spintrcritical14) $(support_includes) \
  • testsuites/sptests/spintrcritical13/spintrcritical13.scn

    r8cbba449 r5020a28  
    1 *** TEST INTERRUPT CRITICAL SECTION 13 ***
    2 Init - Trying to generate timer fire from ISR while firing
    3 Init - Variation is: Timer Fire After
    4 Init - There is no way for the test to know if it hits the case
    5 Init - rtems_timer_create - OK
    6 Support - rtems_timer_create - creating timer 1
    7 *** END OF TEST INTERRUPT CRITICAL SECTION 13 ***
     1*** BEGIN OF TEST SPINTRCRITICAL 13 ***
     2*** TEST VERSION: 6.0.0.929e49a54ab4d2d18c9fb8d03610614f63e25b8d
     3*** TEST STATE: EXPECTED_PASS
     4*** TEST BUILD: RTEMS_DEBUG RTEMS_POSIX_API RTEMS_SMP
     5*** TEST TOOLS: 10.0.1 20200406 (RTEMS 6, RSB bec88a6dd856892c3e66e4598252ea07d7a0d762, Newlib ece49e4)
     6A:SPINTRCRITICAL 13
     7S:Platform:RTEMS
     8S:Compiler:10.0.1 20200406 (RTEMS 6, RSB bec88a6dd856892c3e66e4598252ea07d7a0d762, Newlib ece49e4)
     9S:Version:6.0.0.929e49a54ab4d2d18c9fb8d03610614f63e25b8d
     10S:BSP:realview_pbx_a9_qemu
     11S:RTEMS_DEBUG:1
     12S:RTEMS_MULTIPROCESSING:0
     13S:RTEMS_POSIX_API:1
     14S:RTEMS_PROFILING:0
     15S:RTEMS_SMP:1
     16B:TimerFireAfterInterrupt
     17P:0:0:UI1:spintrcritical13impl.h:131
     18P:1:0:UI1:spintrcritical13impl.h:134
     19P:2:0:UI1:spintrcritical13impl.h:137
     20E:TimerFireAfterInterrupt:N:3:F:0:D:0.116053
     21Z:SPINTRCRITICAL 13:C:1:N:3:F:0:D:0.117144
     22Y:ReportHash:SHA256:66bf247c36962dc930b099cc4979215b4cadb41edd8925097a91e8e7a4356725
     23
     24*** END OF TEST SPINTRCRITICAL 13 ***
  • testsuites/sptests/spintrcritical13/spintrcritical13impl.h

    r8cbba449 r5020a28  
    11/*
     2 *  Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
     3 *
    24 *  COPYRIGHT (c) 1989-2009.
    35 *  On-Line Applications Research Corporation (OAR).
     
    1214#endif
    1315
    14 #include <tmacros.h>
    15 #include <intrcritical.h>
     16#include <string.h>
     17
     18#include <rtems/test.h>
     19#include <rtems/test-info.h>
    1620
    1721#if defined(FIRE_AFTER)
    1822  #define TEST_NAME          "13"
    19   #define TEST_STRING        "Timer Fire After"
     23  #define TEST_STRING        TimerFireAfterInterrupt
    2024  #define TEST_DIRECTIVE     rtems_timer_fire_after
    2125
    2226#elif defined(SERVER_FIRE_AFTER)
    2327  #define TEST_NAME          "14"
    24   #define TEST_STRING        "Timer Server Fire After"
     28  #define TEST_STRING        TimerServerFireAfterInterrupt
    2529  #define TEST_DIRECTIVE     rtems_timer_server_fire_after
    2630
     
    3135const char rtems_test_name[] = "SPINTRCRITICAL " TEST_NAME;
    3236
    33 /* forward declarations to avoid warnings */
    34 rtems_task Init(rtems_task_argument argument);
    35 rtems_timer_service_routine test_release_from_isr(rtems_id  timer, void *arg);
    36 rtems_timer_service_routine TimerMethod(rtems_id  timer, void *arg);
     37typedef struct {
     38  rtems_id timer;
     39  long potential_hits;
     40  volatile bool early;
     41  volatile bool late;
     42} test_context;
    3743
    38 rtems_id Timer;
    39 
    40 rtems_timer_service_routine TimerMethod(
     44static rtems_timer_service_routine TimerMethod(
    4145  rtems_id  timer,
    4246  void     *arg
    4347)
    4448{
     49  (void) timer;
     50  (void) arg;
    4551}
    4652
    47 rtems_timer_service_routine test_release_from_isr(
    48   rtems_id  timer,
    49   void     *arg
    50 )
     53static T_interrupt_test_state interrupt( void *arg )
    5154{
    52   (void) rtems_timer_fire_after( Timer, 10, TimerMethod, NULL );
     55  test_context           *ctx;
     56  rtems_status_code       sc;
     57  T_interrupt_test_state  state;
     58
     59  state = T_interrupt_test_get_state();
     60
     61  if ( state != T_INTERRUPT_TEST_ACTION ) {
     62    return T_INTERRUPT_TEST_CONTINUE;
     63  }
     64
     65  ctx = arg;
     66  sc = TEST_DIRECTIVE( ctx->timer, 10, TimerMethod, NULL );
     67  T_quiet_rsc_success( sc );
     68
     69  if ( ctx->early ) {
     70    state = T_INTERRUPT_TEST_EARLY;
     71  } else if ( ctx->late ) {
     72    state = T_INTERRUPT_TEST_LATE;
     73  } else {
     74    ++ctx->potential_hits;
     75
     76    if ( ctx->potential_hits > 13 ) {
     77      state = T_INTERRUPT_TEST_DONE;
     78    } else {
     79      state = T_INTERRUPT_TEST_CONTINUE;
     80    }
     81  }
     82
     83  return state;
    5384}
    5485
    55 static bool test_body( void *arg )
     86static void prepare( void *arg )
    5687{
    57   rtems_status_code sc;
     88  test_context *ctx;
    5889
    59   (void) arg;
    60 
    61   sc = TEST_DIRECTIVE( Timer, 10, TimerMethod, NULL );
    62   rtems_test_assert( sc == RTEMS_SUCCESSFUL );
    63 
    64   return false;
     90  ctx = arg;
     91  ctx->early = true;
     92  ctx->late = false;
    6593}
    6694
    67 rtems_task Init(
    68   rtems_task_argument ignored
    69 )
     95static void action( void *arg )
    7096{
    71   rtems_status_code     sc;
     97  test_context      *ctx;
     98  rtems_status_code  sc;
    7299
    73   TEST_BEGIN();
     100  ctx = arg;
     101  ctx->early = false;
     102  sc = TEST_DIRECTIVE( ctx->timer, 10, TimerMethod, NULL );
     103  T_quiet_rsc_success( sc );
     104  ctx->late = true;
    74105
    75   puts( "Init - Trying to generate timer fire from ISR while firing" );
    76   puts( "Init - Variation is: " TEST_STRING );
     106  T_interrupt_test_busy_wait_for_interrupt();
     107}
    77108
    78   puts( "Init - There is no way for the test to know if it hits the case" );
     109static const T_interrupt_test_config config = {
     110  .prepare = prepare,
     111  .action = action,
     112  .interrupt = interrupt,
     113  .max_iteration_count = 10000
     114};
    79115
    80   #if defined(SERVER_FIRE_AFTER)
    81    /* initiate timer server */
    82     sc = rtems_timer_initiate_server(
    83       RTEMS_MINIMUM_PRIORITY,
    84       RTEMS_MINIMUM_STACK_SIZE,
    85       RTEMS_DEFAULT_ATTRIBUTES
    86     );
    87     directive_failed( sc, "rtems_timer_initiate_server" );
    88   #endif
     116T_TEST_CASE( TEST_STRING )
     117{
     118  test_context           ctx;
     119  rtems_status_code      sc;
     120  T_interrupt_test_state state;
    89121
    90   puts( "Init - rtems_timer_create - OK" );
    91   sc = rtems_timer_create( rtems_build_name( 'P', 'E', 'R', '1' ), &Timer);
    92   directive_failed( sc, "rtems_timer_create" );
     122  memset( &ctx, 0, sizeof( ctx ) );
    93123
    94   interrupt_critical_section_test( test_body, NULL, test_release_from_isr );
     124  sc = rtems_timer_create(
     125    rtems_build_name( 'P', 'E', 'R', '1' ),
     126    &ctx.timer
     127  );
     128  T_assert_rsc_success( sc );
    95129
    96   TEST_END();
    97   rtems_test_exit(0);
     130  state = T_interrupt_test( &config, &ctx );
     131  T_eq_int( state, T_INTERRUPT_TEST_DONE );
     132
     133  sc = rtems_timer_delete( ctx.timer );
     134  T_rsc_success( sc );
     135}
     136
     137static rtems_task Init( rtems_task_argument argument )
     138{
     139#if defined(SERVER_FIRE_AFTER)
     140  (void) rtems_timer_initiate_server(
     141    RTEMS_MINIMUM_PRIORITY,
     142    RTEMS_MINIMUM_STACK_SIZE,
     143    RTEMS_DEFAULT_ATTRIBUTES
     144  );
     145#endif
     146
     147  rtems_test_run( argument, TEST_STATE );
    98148}
    99149
     
    108158  #define CONFIGURE_MAXIMUM_TASKS     2
    109159#endif
    110 #define CONFIGURE_MAXIMUM_TIMERS      2
    111 #define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
     160#define CONFIGURE_MAXIMUM_TIMERS      1
    112161#define CONFIGURE_MICROSECONDS_PER_TICK  1000
    113162#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
  • testsuites/sptests/spintrcritical14/spintrcritical14.scn

    r8cbba449 r5020a28  
    1 *** TEST INTERRUPT CRITICAL SECTION 14 ***
    2 Init - Trying to generate timer fire from ISR while firing
    3 Init - Variation is: Timer Server Fire After
    4 Init - There is no way for the test to know if it hits the case
    5 Init - rtems_timer_create - OK
    6 Support - rtems_timer_create - creating timer 1
    7 *** END OF TEST INTERRUPT CRITICAL SECTION 14 ***
     1*** BEGIN OF TEST SPINTRCRITICAL 14 ***
     2*** TEST VERSION: 6.0.0.929e49a54ab4d2d18c9fb8d03610614f63e25b8d
     3*** TEST STATE: EXPECTED_PASS
     4*** TEST BUILD: RTEMS_DEBUG RTEMS_POSIX_API RTEMS_SMP
     5*** TEST TOOLS: 10.0.1 20200406 (RTEMS 6, RSB bec88a6dd856892c3e66e4598252ea07d7a0d762, Newlib ece49e4)
     6A:SPINTRCRITICAL 14
     7S:Platform:RTEMS
     8S:Compiler:10.0.1 20200406 (RTEMS 6, RSB bec88a6dd856892c3e66e4598252ea07d7a0d762, Newlib ece49e4)
     9S:Version:6.0.0.929e49a54ab4d2d18c9fb8d03610614f63e25b8d
     10S:BSP:realview_pbx_a9_qemu
     11S:RTEMS_DEBUG:1
     12S:RTEMS_MULTIPROCESSING:0
     13S:RTEMS_POSIX_API:1
     14S:RTEMS_PROFILING:0
     15S:RTEMS_SMP:1
     16B:TimerServerFireAfterInterrupt
     17P:0:0:UI1:spintrcritical13impl.h:131
     18P:1:0:UI1:spintrcritical13impl.h:134
     19P:2:0:UI1:spintrcritical13impl.h:137
     20E:TimerServerFireAfterInterrupt:N:3:F:0:D:0.086586
     21Z:SPINTRCRITICAL 14:C:1:N:3:F:0:D:0.087802
     22Y:ReportHash:SHA256:d6f998056acf55838c88d67702cb4fee07f862f8d2eaa9638a606bd9da4d5c17
     23
     24*** END OF TEST SPINTRCRITICAL 14 ***
Note: See TracChangeset for help on using the changeset viewer.