Changeset aebdd1da in rtems


Ignore:
Timestamp:
Jul 20, 2020, 1:57:08 PM (3 weeks ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
38636e23
Parents:
031e824
git-author:
Sebastian Huber <sebastian.huber@…> (07/20/20 13:57:08)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/23/20 07:27:47)
Message:

spintrcritical18: Use T_interrupt_test()

Location:
testsuites/sptests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • testsuites/sptests/Makefile.am

    r031e824 raebdd1da  
    13311331sp_screens += spintrcritical18/spintrcritical18.scn
    13321332sp_docs += spintrcritical18/spintrcritical18.doc
    1333 spintrcritical18_SOURCES = spintrcritical18/init.c \
    1334         spintrcritical_support/intrcritical.h \
    1335         spintrcritical_support/intrcritical.c
     1333spintrcritical18_SOURCES = spintrcritical18/init.c
    13361334spintrcritical18_CPPFLAGS = $(AM_CPPFLAGS) \
    13371335        $(TEST_FLAGS_spintrcritical18) $(support_includes) \
  • testsuites/sptests/spintrcritical18/init.c

    r031e824 raebdd1da  
    11/*
    2  * Copyright (c) 2012 embedded brains GmbH.  All rights reserved.
    3  *
    4  *  embedded brains GmbH
    5  *  Obere Lagerstr. 30
    6  *  82178 Puchheim
    7  *  Germany
    8  *  <rtems@embedded-brains.de>
     2 * Copyright (C) 2012, 2020 embedded brains GmbH (http://www.embedded-brains.de)
    93 *
    104 * The license and distribution terms for this file may be
     
    1711#endif
    1812
    19 #include <tmacros.h>
    20 #include <intrcritical.h>
     13#include <rtems/test.h>
     14#include <rtems/test-info.h>
    2115
    2216const char rtems_test_name[] = "SPINTRCRITICAL 18";
     
    2923
    3024#define PRIORITY_HIGH 1
    31 
    32 #define ASSERT_SC(sc) rtems_test_assert( (sc) == RTEMS_SUCCESSFUL )
    3325
    3426typedef struct {
     
    3628  rtems_id high_priority_task;
    3729  bool high_priority_task_activated;
     30  volatile bool early;
     31  volatile bool switching;
     32  volatile bool late;
     33  long potential_hits;
    3834} test_context;
    3935
    40 static test_context global_ctx;
    41 
    42 static void wake_up(rtems_id task)
     36static void wake_up( rtems_id task )
    4337{
    4438  rtems_status_code sc;
    4539
    4640  sc = rtems_event_send( task, WAKE_UP );
    47   ASSERT_SC( sc );
     41  T_quiet_rsc_success( sc );
    4842}
    4943
     
    5953    &events
    6054  );
    61   ASSERT_SC( sc );
    62   rtems_test_assert( events == WAKE_UP );
    63 }
    64 
    65 static void active_high_priority_task( rtems_id timer, void *arg )
    66 {
    67   /* The arg is NULL */
    68   test_context *ctx = &global_ctx;
    69 
    70   rtems_test_assert( !ctx->high_priority_task_activated );
     55  T_quiet_rsc_success( sc );
     56  T_quiet_eq_u32( events, WAKE_UP );
     57}
     58
     59static T_interrupt_test_state active_high_priority_task( void *arg )
     60{
     61  test_context *ctx = arg;
     62  T_interrupt_test_state state;
     63
     64  state = T_interrupt_test_get_state();
     65
     66  if ( state != T_INTERRUPT_TEST_ACTION ) {
     67    return T_INTERRUPT_TEST_CONTINUE;
     68  }
     69
     70  T_quiet_false( ctx->high_priority_task_activated );
    7171  ctx->high_priority_task_activated = true;
    7272  wake_up( ctx->high_priority_task );
     73
     74  if ( ctx->early ) {
     75    state = T_INTERRUPT_TEST_EARLY;
     76  } else if ( ctx->late ) {
     77    state = T_INTERRUPT_TEST_LATE;
     78  } else {
     79    ++ctx->potential_hits;
     80
     81    if ( ctx->potential_hits > 13 ) {
     82      state = T_INTERRUPT_TEST_DONE;
     83    } else {
     84      state = T_INTERRUPT_TEST_CONTINUE;
     85    }
     86  }
     87
     88  return state;
    7389}
    7490
     
    7995  while ( true ) {
    8096    wait_for_wake_up();
    81 
    82     rtems_test_assert( !ctx->high_priority_task_activated );
     97    ctx->late = true;
     98
     99    T_quiet_false( ctx->high_priority_task_activated );
    83100  }
    84101}
     
    91108    wait_for_wake_up();
    92109
    93     rtems_test_assert( ctx->high_priority_task_activated );
     110    T_quiet_true( ctx->high_priority_task_activated );
    94111    ctx->high_priority_task_activated = false;
    95112  }
    96113}
    97114
    98 static bool test_body( void *arg )
    99 {
    100   test_context *ctx = arg;
    101 
     115static void prepare( void *arg )
     116{
     117  test_context *ctx = arg;
     118
     119  ctx->early = true;
     120  ctx->switching = false;
     121  ctx->late = false;
     122}
     123
     124static void action( void *arg )
     125{
     126  test_context *ctx = arg;
     127
     128  ctx->early = false;
    102129  wake_up( ctx->middle_priority_task );
    103 
    104   return false;
    105 }
    106 
    107 static void Init( rtems_task_argument ignored )
    108 {
    109   test_context *ctx = &global_ctx;
     130}
     131
     132static void blocked( void *arg )
     133{
     134  test_context *ctx = arg;
     135  T_interrupt_test_state state;
     136
     137  state = T_interrupt_test_change_state(
     138    T_INTERRUPT_TEST_ACTION,
     139    T_INTERRUPT_TEST_LATE
     140  );
     141
     142  if ( state == T_INTERRUPT_TEST_ACTION ) {
     143    ctx->switching = true;
     144    T_busy( 100 );
     145    ctx->switching = false;
     146  }
     147}
     148
     149static const T_interrupt_test_config config = {
     150  .prepare = prepare,
     151  .action = action,
     152  .interrupt = active_high_priority_task,
     153  .blocked = blocked,
     154  .max_iteration_count = 10000
     155};
     156
     157T_TEST_CASE(InterruptDuringThreadDispatch)
     158{
     159  T_interrupt_test_state state;
     160  test_context ctx;
    110161  rtems_status_code sc;
    111162
    112   TEST_BEGIN();
     163  memset( &ctx, 0, sizeof( ctx ) );
    113164
    114165  sc = rtems_task_create(
     
    118169    RTEMS_DEFAULT_MODES,
    119170    RTEMS_DEFAULT_ATTRIBUTES,
    120     &ctx->high_priority_task
    121   );
    122   ASSERT_SC(sc);
     171    &ctx.high_priority_task
     172  );
     173  T_assert_rsc_success( sc );
    123174
    124175  sc = rtems_task_start(
    125     ctx->high_priority_task,
     176    ctx.high_priority_task,
    126177    high_priority_task,
    127     (rtems_task_argument) ctx
    128   );
    129   ASSERT_SC(sc);
     178    (rtems_task_argument) &ctx
     179  );
     180  T_assert_rsc_success( sc );
    130181
    131182  sc = rtems_task_create(
     
    135186    RTEMS_DEFAULT_MODES,
    136187    RTEMS_DEFAULT_ATTRIBUTES,
    137     &ctx->middle_priority_task
    138   );
    139   ASSERT_SC(sc);
     188    &ctx.middle_priority_task
     189  );
     190  T_assert_rsc_success( sc );
    140191
    141192  sc = rtems_task_start(
    142     ctx->middle_priority_task,
     193    ctx.middle_priority_task,
    143194    middle_priority_task,
    144     (rtems_task_argument) ctx
    145   );
    146   ASSERT_SC(sc);
    147 
    148   interrupt_critical_section_test( test_body, ctx, active_high_priority_task );
    149 
    150   TEST_END();
    151 
    152   rtems_test_exit( 0 );
     195    (rtems_task_argument) &ctx
     196  );
     197  T_assert_rsc_success( sc );
     198
     199  state = T_interrupt_test( &config, &ctx );
     200  T_eq_int( state, T_INTERRUPT_TEST_DONE );
     201
     202  sc = rtems_task_delete( ctx.high_priority_task );
     203  T_rsc_success( sc );
     204
     205  sc = rtems_task_delete( ctx.middle_priority_task );
     206  T_rsc_success( sc );
     207}
     208
     209static rtems_task Init( rtems_task_argument argument )
     210{
     211  rtems_test_run( argument, TEST_STATE );
    153212}
    154213
     
    159218
    160219#define CONFIGURE_MAXIMUM_TASKS 3
    161 #define CONFIGURE_MAXIMUM_TIMERS 1
    162 #define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
    163220
    164221#define CONFIGURE_INIT_TASK_PRIORITY PRIORITY_LOW
  • testsuites/sptests/spintrcritical18/spintrcritical18.scn

    r031e824 raebdd1da  
    1 *** TEST INTERRUPT CRITICAL SECTION 18 ***
     1*** BEGIN OF TEST SPINTRCRITICAL 18 ***
     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 18
     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:InterruptDuringThreadDispatch
     17P:0:0:UI1:init.c:176
     18P:1:0:UI1:init.c:183
     19P:2:0:UI1:init.c:193
     20P:3:0:UI1:init.c:200
     21P:4:0:UI1:init.c:203
     22P:5:0:UI1:init.c:206
     23P:6:0:UI1:init.c:209
     24E:InterruptDuringThreadDispatch:N:7:F:0:D:0.096291
     25Z:SPINTRCRITICAL 18:C:1:N:7:F:0:D:0.097615
     26Y:ReportHash:SHA256:60e93b7dd3417ceb3b6374392e8dd8e1b16279a45bf6ae7ccca3c67bb9ee298f
    227
    3 Support - rtems_timer_create - creating timer 1
    4 *** END OF TEST INTERRUPT CRITICAL SECTION 18 ***
     28*** END OF TEST SPINTRCRITICAL 18 ***
Note: See TracChangeset for help on using the changeset viewer.