Changeset 1c2e05d4 in rtems


Ignore:
Timestamp:
Jul 20, 2020, 3:44:42 PM (3 weeks ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
031e824
Parents:
5020a28
git-author:
Sebastian Huber <sebastian.huber@…> (07/20/20 15:44:42)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/23/20 07:27:47)
Message:

spintrcritical15: Use T_interrupt_test()

Location:
testsuites/sptests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • testsuites/sptests/Makefile.am

    r5020a28 r1c2e05d4  
    13111311sp_screens += spintrcritical15/spintrcritical15.scn
    13121312sp_docs += spintrcritical15/spintrcritical15.doc
    1313 spintrcritical15_SOURCES = spintrcritical15/init.c \
    1314         spintrcritical_support/intrcritical.c \
    1315         spintrcritical_support/intrcritical.h
     1313spintrcritical15_SOURCES = spintrcritical15/init.c
    13161314spintrcritical15_CPPFLAGS = $(AM_CPPFLAGS) \
    13171315        $(TEST_FLAGS_spintrcritical15) $(support_includes) \
  • testsuites/sptests/spintrcritical15/init.c

    r5020a28 r1c2e05d4  
    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>
     18
     19#include <rtems/score/threadimpl.h>
    1620
    1721const char rtems_test_name[] = "SPINTRCRITICAL 15";
    18 
    19 /* forward declarations to avoid warnings */
    20 rtems_task Init(rtems_task_argument argument);
    21 rtems_task Secondary_task(rtems_task_argument ignored);
    2222
    2323#define INIT_PRIORITY      2
    2424#define BLOCKER_PRIORITY   1
    2525
    26 rtems_id Secondary_task_id;
    27 rtems_id Semaphore;
     26typedef struct {
     27  rtems_id secondary_task_id;
     28  rtems_id semaphore;
     29  Thread_Control *main_thread;
     30} test_context;
    2831
    29 rtems_task Secondary_task(
    30   rtems_task_argument ignored
    31 )
     32static rtems_task Secondary_task( rtems_task_argument arg )
    3233{
    33   rtems_status_code     sc;
     34  test_context      *ctx;
     35  rtems_status_code  sc;
     36
     37  ctx = (test_context *) arg;
    3438
    3539  while (1) {
    36     sc = rtems_semaphore_obtain( Semaphore, RTEMS_DEFAULT_OPTIONS, 1 );
    37     fatal_directive_status( sc, RTEMS_TIMEOUT, "rtems_semaphore_obtain" );
     40    sc = rtems_semaphore_obtain( ctx->semaphore, RTEMS_DEFAULT_OPTIONS, 1 );
     41    T_quiet_rsc( sc, RTEMS_TIMEOUT );
    3842  }
    3943}
    4044
    41 static bool test_body( void *arg )
     45static T_interrupt_test_state interrupt(void *arg)
    4246{
    43   rtems_status_code sc;
     47  test_context           *ctx;
     48  Thread_Wait_flags       flags;
     49  T_interrupt_test_state  state;
    4450
    45   (void) arg;
     51  ctx = arg;
     52  flags = _Thread_Wait_flags_get( ctx->main_thread );
    4653
    47   sc = rtems_task_restart( Secondary_task_id, 1 );
    48   rtems_test_assert( sc == RTEMS_SUCCESSFUL );
     54  if (
     55    flags == ( THREAD_WAIT_CLASS_OBJECT | THREAD_WAIT_STATE_INTEND_TO_BLOCK )
     56  ) {
     57    state = T_INTERRUPT_TEST_DONE;
     58  } else if (
     59    flags == ( THREAD_WAIT_CLASS_OBJECT | THREAD_WAIT_STATE_BLOCKED )
     60  ) {
     61    state = T_INTERRUPT_TEST_LATE;
     62  } else {
     63    state = T_INTERRUPT_TEST_EARLY;
     64  }
    4965
    50   sc = rtems_semaphore_obtain( Semaphore, RTEMS_DEFAULT_OPTIONS, 1 );
    51   rtems_test_assert( sc == RTEMS_TIMEOUT );
    52 
    53   return false;
     66  return state;
    5467}
    5568
    56 rtems_task Init(
    57   rtems_task_argument ignored
    58 )
     69static void prepare( void *arg )
    5970{
    60   rtems_status_code     sc;
     71  test_context      *ctx;
     72  rtems_status_code  sc;
    6173
    62   TEST_BEGIN();
    63   puts(
    64     "Init - Trying to generate timeout of a thread while another is blocking\n"
    65     "Init -   on the same thread queue\n"
    66     "Init - There is no way for the test to know if it hits the case"
    67   );
     74  ctx = arg;
     75  sc = rtems_task_restart( ctx->secondary_task_id, (rtems_task_argument) ctx );
     76  T_quiet_rsc_success( sc );
     77}
    6878
    69   puts( "Init - rtems_semaphore_create - OK" );
     79static void action( void *arg )
     80{
     81  test_context      *ctx;
     82  rtems_status_code  sc;
     83
     84  ctx = arg;
     85  sc = rtems_semaphore_obtain( ctx->semaphore, RTEMS_DEFAULT_OPTIONS, 1 );
     86  T_quiet_rsc( sc, RTEMS_TIMEOUT );
     87}
     88
     89static const T_interrupt_test_config config = {
     90  .prepare = prepare,
     91  .action = action,
     92  .interrupt = interrupt,
     93  .max_iteration_count = 10000
     94};
     95
     96T_TEST_CASE( SemaphoreObtainBlockedInterrupt )
     97{
     98  test_context           ctx;
     99  rtems_status_code      sc;
     100  T_interrupt_test_state state;
     101
     102  ctx.main_thread = _Thread_Get_executing();
     103
    70104  sc = rtems_semaphore_create(
    71105    rtems_build_name( 'S', 'M', '1', ' ' ),
     
    73107    RTEMS_DEFAULT_ATTRIBUTES,
    74108    RTEMS_NO_PRIORITY,
    75     &Semaphore
     109    &ctx.semaphore
    76110  );
    77   directive_failed( sc, "rtems_semaphore_create of SM1" );
     111  T_assert_rsc_success( sc );
    78112
    79   puts( "Init - rtems_task_create - OK" );
    80113  sc = rtems_task_create(
    81114    rtems_build_name( 'B', 'L', 'C', 'K' ),
     
    84117    RTEMS_NO_PREEMPT,
    85118    RTEMS_DEFAULT_ATTRIBUTES,
    86     &Secondary_task_id
     119    &ctx.secondary_task_id
    87120  );
    88   directive_failed( sc, "rtems_task_create" );
     121  T_assert_rsc_success( sc );
    89122
    90   sc = rtems_task_start( Secondary_task_id, Secondary_task, 0 );
    91   directive_failed( sc, "rtems_task_start" );
     123  sc = rtems_task_start(
     124    ctx.secondary_task_id,
     125    Secondary_task,
     126    (rtems_task_argument) &ctx
     127  );
     128  T_assert_rsc_success( sc );
    92129
    93   interrupt_critical_section_test( test_body, NULL, NULL );
     130  state = T_interrupt_test( &config, &ctx );
     131  T_eq_int( state, T_INTERRUPT_TEST_DONE );
    94132
    95   TEST_END();
    96   rtems_test_exit(0);
     133  sc = rtems_task_delete( ctx.secondary_task_id );
     134  T_rsc_success( sc );
     135
     136  sc = rtems_semaphore_delete( ctx.semaphore );
     137  T_rsc_success( sc );
     138}
     139
     140static rtems_task Init( rtems_task_argument argument )
     141{
     142  rtems_test_run( argument, TEST_STATE );
    97143}
    98144
     
    104150#define CONFIGURE_MAXIMUM_TASKS          2
    105151#define CONFIGURE_MAXIMUM_SEMAPHORES     1
    106 #define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
    107152#define CONFIGURE_MICROSECONDS_PER_TICK  1000
    108153#define CONFIGURE_INIT_TASK_PRIORITY  INIT_PRIORITY
  • testsuites/sptests/spintrcritical15/spintrcritical15.scn

    r5020a28 r1c2e05d4  
    1 *** TEST INTERRUPT CRITICAL SECTION 15 ***
    2 Init - Trying to generate timeout of a thread while another is blocking
    3 Init -   on the same thread queue
    4 Init - There is no way for the test to know if it hits the case
    5 Init - rtems_semaphore_create - OK
    6 Init - rtems_task_create - OK
    7 *** END OF TEST INTERRUPT CRITICAL SECTION 15 ***
     1*** BEGIN OF TEST SPINTRCRITICAL 15 ***
     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 15
     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:SemaphoreObtainBlockedInterrupt
     17P:0:0:UI1:init.c:111
     18P:1:0:UI1:init.c:121
     19P:2:0:UI1:init.c:128
     20P:3:0:UI1:init.c:131
     21P:4:0:UI1:init.c:134
     22P:5:0:UI1:init.c:137
     23E:SemaphoreObtainBlockedInterrupt:N:6:F:0:D:0.063907
     24Z:SPINTRCRITICAL 15:C:1:N:6:F:0:D:0.065120
     25Y:ReportHash:SHA256:198a9452944e985b137ec4b427be51cef71af413f6e3bfdf03a2f29a9bd81259
     26
     27*** END OF TEST SPINTRCRITICAL 15 ***
Note: See TracChangeset for help on using the changeset viewer.