Changeset a231276 in rtems


Ignore:
Timestamp:
Jul 20, 2020, 2:12:02 PM (3 weeks ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
be2f9d7
Parents:
5f66ac86
git-author:
Sebastian Huber <sebastian.huber@…> (07/20/20 14:12:02)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/23/20 07:27:47)
Message:

spintrcritical09: Use T_interrupt_test()

Location:
testsuites/sptests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • testsuites/sptests/Makefile.am

    r5f66ac86 ra231276  
    12511251sp_screens += spintrcritical09/spintrcritical09.scn
    12521252sp_docs += spintrcritical09/spintrcritical09.doc
    1253 spintrcritical09_SOURCES = spintrcritical09/init.c \
    1254         spintrcritical_support/intrcritical.c \
    1255         spintrcritical_support/intrcritical.h
     1253spintrcritical09_SOURCES = spintrcritical09/init.c
    12561254spintrcritical09_CPPFLAGS = $(AM_CPPFLAGS) \
    12571255        $(TEST_FLAGS_spintrcritical09) $(support_includes) \
  • testsuites/sptests/spintrcritical09/init.c

    r5f66ac86 ra231276  
    11/*
     2 *  Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
     3 *
    24 *  COPYRIGHT (c) 1989-2012.
    35 *  On-Line Applications Research Corporation (OAR).
     
    1214#endif
    1315
    14 #include <tmacros.h>
    15 #include <intrcritical.h>
     16#include <rtems/test.h>
     17#include <rtems/test-info.h>
    1618
    1719#include <rtems/score/threadimpl.h>
     
    2123const char rtems_test_name[] = "SPINTRCRITICAL 9";
    2224
    23 static Thread_Control *thread;
     25typedef struct {
     26  Thread_Control *thread;
     27  rtems_id        semaphore;
     28  volatile bool   early;
     29} test_context;
    2430
    25 static rtems_id Semaphore;
    26 
    27 static bool case_hit;
    28 
    29 static bool is_interrupt_timeout(void)
     31static bool is_interrupt_timeout( test_context *ctx )
    3032{
    31   Thread_Wait_flags flags = _Thread_Wait_flags_get( thread );
     33  Thread_Wait_flags flags = _Thread_Wait_flags_get( ctx->thread );
    3234
    3335  return flags == ( THREAD_WAIT_CLASS_OBJECT | THREAD_WAIT_STATE_READY_AGAIN );
    3436}
    3537
    36 static rtems_timer_service_routine test_release_from_isr(
    37   rtems_id  timer,
    38   void     *arg
    39 )
     38static T_interrupt_test_state interrupt( void *arg )
    4039{
    41   Per_CPU_Control *cpu_self = _Per_CPU_Get();
    42   Watchdog_Header *header = &cpu_self->Watchdog.Header[ PER_CPU_WATCHDOG_TICKS ];
    43   Watchdog_Control *watchdog = (Watchdog_Control *) header->first;
     40  test_context           *ctx;
     41  Per_CPU_Control        *cpu_self;
     42  Watchdog_Header        *header;
     43  Watchdog_Control       *watchdog;
     44  T_interrupt_test_state  state;
     45
     46  ctx = arg;
     47  cpu_self = _Per_CPU_Get();
     48  header = &cpu_self->Watchdog.Header[ PER_CPU_WATCHDOG_TICKS ];
     49  watchdog = (Watchdog_Control *) header->first;
    4450
    4551  if (
     
    4854      && watchdog->routine == _Thread_Timeout
    4955  ) {
     56    ISR_Level level;
     57
     58    _ISR_Local_disable( level );
    5059    _Watchdog_Per_CPU_remove( watchdog, cpu_self, header );
     60    _ISR_Local_enable( level );
    5161
    52     (*watchdog->routine)( watchdog );
     62    ( *watchdog->routine )( watchdog );
    5363
    54     if ( is_interrupt_timeout() ) {
    55       case_hit = true;
     64    if ( is_interrupt_timeout( ctx ) ) {
     65      state = T_INTERRUPT_TEST_DONE;
     66    } else {
     67      state = T_INTERRUPT_TEST_LATE;
     68    }
     69  } else {
     70    if ( ctx->early ) {
     71      state = T_INTERRUPT_TEST_EARLY;
     72    } else {
     73      state = T_INTERRUPT_TEST_LATE;
    5674    }
    5775  }
     76
     77  return state;
    5878}
    5979
    60 static bool test_body( void *arg )
     80static void prepare( void *arg )
    6181{
    62   (void) arg;
     82  test_context      *ctx;
     83  rtems_status_code  sc;
    6384
    64   rtems_semaphore_obtain( Semaphore, RTEMS_DEFAULT_OPTIONS, 1 );
    65 
    66   return case_hit;
     85  ctx = arg;
     86  ctx->early = true;
     87  sc = rtems_semaphore_obtain( ctx->semaphore, RTEMS_NO_WAIT, 0 );
     88  T_quiet_true( sc == RTEMS_SUCCESSFUL || sc == RTEMS_UNSATISFIED );
    6789}
    6890
    69 static rtems_task Init(
    70   rtems_task_argument ignored
    71 )
     91static void action( void *arg )
    7292{
    73   rtems_status_code     sc;
     93  test_context      *ctx;
     94  rtems_status_code  sc;
    7495
    75   TEST_BEGIN();
     96  ctx = arg;
     97  ctx->early = false;
     98  sc = rtems_semaphore_obtain( ctx->semaphore, RTEMS_DEFAULT_OPTIONS, 1 );
     99  T_quiet_rsc( sc, RTEMS_TIMEOUT );
     100}
    76101
    77   thread = _Thread_Get_executing();
     102static const T_interrupt_test_config config = {
     103  .prepare = prepare,
     104  .action = action,
     105  .interrupt = interrupt,
     106  .max_iteration_count = 10000
     107};
    78108
    79   puts( "Init - Test may not be able to detect case is hit reliably" );
    80   puts( "Init - Trying to generate timeout from ISR while blocking" );
     109T_TEST_CASE( SemaphoreObtainInterrupt )
     110{
     111  test_context           ctx;
     112  rtems_status_code      sc;
     113  T_interrupt_test_state state;
     114
     115  ctx.thread = _Thread_Get_executing();
     116
    81117  sc = rtems_semaphore_create(
    82118    rtems_build_name( 'S', 'M', '1', ' ' ),
     
    84120    RTEMS_DEFAULT_ATTRIBUTES,
    85121    RTEMS_NO_PRIORITY,
    86     &Semaphore
     122    &ctx.semaphore
    87123  );
    88   directive_failed( sc, "rtems_semaphore_create of SM1" );
     124  T_assert_rsc_success( sc );
    89125
    90   interrupt_critical_section_test( test_body, NULL, test_release_from_isr );
     126  state = T_interrupt_test( &config, &ctx );
     127  T_eq_int( state, T_INTERRUPT_TEST_DONE );
    91128
    92   if ( case_hit ) {
    93     puts( "Init - It appears the case has been hit" );
    94     TEST_END();
    95   } else
    96     puts( "Init - Case not hit - ran too long" );
     129  sc = rtems_semaphore_delete( ctx.semaphore );
     130  T_rsc_success( sc );
     131}
    97132
    98   rtems_test_exit(0);
     133static rtems_task Init( rtems_task_argument argument )
     134{
     135  rtems_test_run( argument, TEST_STATE );
    99136}
    100137
     
    105142
    106143#define CONFIGURE_MAXIMUM_TASKS       1
    107 #define CONFIGURE_MAXIMUM_TIMERS      1
    108144#define CONFIGURE_MAXIMUM_SEMAPHORES  1
    109 #define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
    110145#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
    111146
  • testsuites/sptests/spintrcritical09/spintrcritical09.scn

    r5f66ac86 ra231276  
    1 *** TEST INTERRUPT CRITICAL SECTION 09 ***
    2 Init - Test may not be able to detect case is hit reliably
    3 Init - Trying to generate timeout from ISR while blocking
    4 Support - rtems_timer_create - creating timer 1
     1*** BEGIN OF TEST SPINTRCRITICAL 9 ***
     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 9
     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:SemaphoreObtainInterrupt
     17P:0:0:UI1:init.c:124
     18P:1:0:UI1:init.c:127
     19P:2:0:UI1:init.c:130
     20E:SemaphoreObtainInterrupt:N:3:F:0:D:0.060862
     21Z:SPINTRCRITICAL 9:C:1:N:3:F:0:D:0.061985
     22Y:ReportHash:SHA256:432e69ffa61dcb2eaef5b67504104b7da761a56e2c1943cf64973c4a89885008
     23
     24*** END OF TEST SPINTRCRITICAL 9 ***
Note: See TracChangeset for help on using the changeset viewer.