Changeset 031e824 in rtems


Ignore:
Timestamp:
Jul 20, 2020, 5:18:16 PM (3 weeks ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
aebdd1da
Parents:
1c2e05d4
git-author:
Sebastian Huber <sebastian.huber@…> (07/20/20 17:18:16)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/23/20 07:27:47)
Message:

spintrcritical16: Use T_interrupt_test()

Location:
testsuites/sptests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • testsuites/sptests/Makefile.am

    r1c2e05d4 r031e824  
    13211321sp_screens += spintrcritical16/spintrcritical16.scn
    13221322sp_docs += spintrcritical16/spintrcritical16.doc
    1323 spintrcritical16_SOURCES = spintrcritical16/init.c \
    1324         spintrcritical_support/intrcritical.c \
    1325         spintrcritical_support/intrcritical.h
     1323spintrcritical16_SOURCES = spintrcritical16/init.c
    13261324spintrcritical16_CPPFLAGS = $(AM_CPPFLAGS) \
    13271325        $(TEST_FLAGS_spintrcritical16) $(support_includes) \
  • testsuites/sptests/spintrcritical16/init.c

    r1c2e05d4 r031e824  
    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 <rtems/test.h>
     17#include <rtems/test-info.h>
    1618
    1719#include <rtems/score/threadimpl.h>
     
    1921const char rtems_test_name[] = "SPINTRCRITICAL 16";
    2022
    21 static Thread_Control *Main_TCB;
     23typedef struct {
     24  Thread_Control *thread;
     25  rtems_id        semaphore;
     26} test_context;
    2227
    23 static rtems_id Semaphore;
     28static T_interrupt_test_state interrupt( void *arg )
     29{
     30  test_context *ctx;
     31  T_interrupt_test_state state;
     32  Thread_Wait_flags flags;
     33  rtems_status_code sc;
    2434
    25 static bool case_hit;
     35  state = T_interrupt_test_get_state();
    2636
    27 static bool interrupts_blocking_op(void)
    28 {
    29   Thread_Wait_flags flags = _Thread_Wait_flags_get( Main_TCB );
     37  if (state != T_INTERRUPT_TEST_ACTION) {
     38    return T_INTERRUPT_TEST_CONTINUE;
     39  }
    3040
    31   return
    32     flags == ( THREAD_WAIT_CLASS_OBJECT | THREAD_WAIT_STATE_INTEND_TO_BLOCK );
     41  ctx = arg;
     42  flags = _Thread_Wait_flags_get( ctx->thread );
     43
     44  if (
     45    flags == ( THREAD_WAIT_CLASS_OBJECT | THREAD_WAIT_STATE_INTEND_TO_BLOCK )
     46  ) {
     47    state = T_INTERRUPT_TEST_DONE;
     48  } else if (
     49    flags == ( THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_BLOCKED )
     50  ) {
     51    state = T_INTERRUPT_TEST_LATE;
     52  } else {
     53    state = T_INTERRUPT_TEST_EARLY;
     54  }
     55
     56  sc = rtems_semaphore_release( ctx->semaphore );
     57  T_quiet_rsc_success( sc );
     58
     59  return state;
    3360}
    3461
    35 static rtems_timer_service_routine test_release_from_isr(
    36   rtems_id  timer,
    37   void     *arg
    38 )
     62static void prepare( void *arg )
    3963{
    40   if ( interrupts_blocking_op() ) {
    41     case_hit = true;
    42     (void) rtems_semaphore_release( Semaphore );
    43   }
     64  test_context *ctx;
     65  rtems_status_code sc;
    4466
    45   if ( Main_TCB->Wait.queue != NULL ) {
    46     _Thread_Timeout( &Main_TCB->Timer.Watchdog );
    47   }
     67  ctx = arg;
     68
     69  do {
     70    sc = rtems_semaphore_obtain( ctx->semaphore, RTEMS_NO_WAIT, 0 );
     71  } while ( sc == RTEMS_SUCCESSFUL );
    4872}
    4973
    50 static bool test_body( void *arg )
     74static void action( void *arg )
    5175{
     76  test_context *ctx;
    5277  rtems_status_code sc;
    5378
    54   (void) arg;
    55 
    56   sc = rtems_semaphore_obtain( Semaphore, RTEMS_DEFAULT_OPTIONS, 2 );
    57   rtems_test_assert( sc == RTEMS_SUCCESSFUL || sc == RTEMS_TIMEOUT );
    58 
    59   return case_hit;
     79  ctx = arg;
     80  sc = rtems_semaphore_obtain( ctx->semaphore, RTEMS_DEFAULT_OPTIONS, 2 );
     81  T_quiet_rsc_success( sc );
    6082}
    6183
    62 static rtems_task Init(
    63   rtems_task_argument ignored
    64 )
     84static void blocked( void *arg )
    6585{
    66   rtems_status_code     sc;
     86  test_context *ctx;
     87  rtems_status_code sc;
    6788
    68   TEST_BEGIN();
    69   puts(
    70     "Init - Trying to generate timeout of a thread that had its blocking\n"
    71     "Init -   request satisfied while blocking but before time timeout"
     89  T_interrupt_test_change_state(
     90    T_INTERRUPT_TEST_ACTION,
     91    T_INTERRUPT_TEST_LATE
    7292  );
    7393
    74   puts( "Init - rtems_semaphore_create - OK" );
     94  ctx = arg;
     95  sc = rtems_semaphore_release( ctx->semaphore );
     96  T_quiet_rsc_success( sc );
     97}
     98
     99static const T_interrupt_test_config config = {
     100  .prepare = prepare,
     101  .action = action,
     102  .interrupt = interrupt,
     103  .blocked = blocked,
     104  .max_iteration_count = 10000
     105};
     106
     107/*
     108 * Trying to generate timeout of a thread that had its blocking request
     109 * satisfied while blocking but before time timeout.
     110 */
     111T_TEST_CASE( SemaphoreSatisfyBeforeTimeout )
     112{
     113  test_context ctx;
     114  rtems_status_code sc;
     115  T_interrupt_test_state state;
     116
     117  ctx.thread = _Thread_Get_executing();
     118
    75119  sc = rtems_semaphore_create(
    76120    rtems_build_name( 'S', 'M', '1', ' ' ),
     
    78122    RTEMS_DEFAULT_ATTRIBUTES,
    79123    RTEMS_NO_PRIORITY,
    80     &Semaphore
     124    &ctx.semaphore
    81125  );
    82   directive_failed( sc, "rtems_semaphore_create of SM1" );
     126  T_assert_rsc_success( sc );
    83127
    84   Main_TCB  = _Thread_Get_executing();
     128  state = T_interrupt_test( &config, &ctx );
     129  T_eq_int( state, T_INTERRUPT_TEST_DONE );
    85130
    86   interrupt_critical_section_test( test_body, NULL, test_release_from_isr );
     131  sc = rtems_semaphore_delete( ctx.semaphore );
     132  T_rsc_success( sc );
     133}
    87134
    88   if ( case_hit ) {
    89     puts( "Init - Case hit" );
    90     TEST_END();
    91   } else
    92     puts( "Init - Case not hit - ran too long" );
    93 
    94 
    95   rtems_test_exit(0);
     135static rtems_task Init( rtems_task_argument argument )
     136{
     137  rtems_test_run( argument, TEST_STATE );
    96138}
    97139
     
    102144
    103145#define CONFIGURE_MAXIMUM_TASKS          1
    104 #define CONFIGURE_MAXIMUM_TIMERS         1
    105146#define CONFIGURE_MAXIMUM_SEMAPHORES     1
    106 #define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
    107147#define CONFIGURE_MICROSECONDS_PER_TICK  1000
    108148#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
  • testsuites/sptests/spintrcritical16/spintrcritical16.scn

    r1c2e05d4 r031e824  
    1 *** TEST INTERRUPT CRITICAL SECTION 16 ***
    2 Init - Trying to generate timeout of a thread that had its blocking
    3 Init -   request satisfied while blocking but before time timeout
    4 Init - rtems_semaphore_create - OK
    5 Support - rtems_timer_create - creating timer 1
    6 Init - Case hit
    7 *** END OF TEST INTERRUPT CRITICAL SECTION 16 ***
     1*** BEGIN OF TEST SPINTRCRITICAL 16 ***
     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 16
     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:SemaphoreSatisfyBeforeTimeout
     17P:0:0:UI1:init.c:119
     18P:1:0:UI1:init.c:122
     19P:2:0:UI1:init.c:125
     20E:SemaphoreSatisfyBeforeTimeout:N:3:F:0:D:0.058378
     21Z:SPINTRCRITICAL 16:C:1:N:3:F:0:D:0.059654
     22Y:ReportHash:SHA256:c1e358e47313edf10cbf9e1aef2cdd06ce96bc85c69d109e3494b4d1e0880f8f
     23
     24*** END OF TEST SPINTRCRITICAL 16 ***
Note: See TracChangeset for help on using the changeset viewer.