Changeset 38636e23 in rtems


Ignore:
Timestamp:
Jul 21, 2020, 5:19:30 AM (3 weeks ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
59ee3020
Parents:
aebdd1da
git-author:
Sebastian Huber <sebastian.huber@…> (07/21/20 05:19:30)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/23/20 07:27:47)
Message:

spintrcritical20: Use T_interrupt_test()

Location:
testsuites/sptests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • testsuites/sptests/Makefile.am

    raebdd1da r38636e23  
    13411341sp_screens += spintrcritical20/spintrcritical20.scn
    13421342sp_docs += spintrcritical20/spintrcritical20.doc
    1343 spintrcritical20_SOURCES = spintrcritical20/init.c \
    1344         spintrcritical_support/intrcritical.c
     1343spintrcritical20_SOURCES = spintrcritical20/init.c
    13451344spintrcritical20_CPPFLAGS = $(AM_CPPFLAGS) \
    13461345        $(TEST_FLAGS_spintrcritical20) $(support_includes) \
  • testsuites/sptests/spintrcritical20/init.c

    raebdd1da r38636e23  
    11/*
    2  * Copyright (c) 2013 embedded brains GmbH.  All rights reserved.
    3  *
    4  *  embedded brains GmbH
    5  *  Dornierstr. 4
    6  *  82178 Puchheim
    7  *  Germany
    8  *  <rtems@embedded-brains.de>
     2 * Copyright (C) 2013, 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 <string.h>
     14
     15#include <rtems/test.h>
     16#include <rtems/test-info.h>
     17
    2118#include <rtems/score/threadimpl.h>
    2219#include <rtems/score/threadqimpl.h>
     
    3734  bool status_was_successful;
    3835  bool status_was_timeout;
     36  volatile bool early;
     37  volatile bool late;
    3938} test_context;
    40 
    41 static test_context ctx_instance;
    4239
    4340static void semaphore_task(rtems_task_argument arg)
     
    5350      RTEMS_NO_TIMEOUT
    5451    );
    55     rtems_test_assert(sc == RTEMS_SUCCESSFUL || sc == RTEMS_TIMEOUT);
    56   }
    57 }
    58 
    59 static void release_semaphore(rtems_id timer, void *arg)
    60 {
    61   /* The arg is NULL */
    62   test_context *ctx = &ctx_instance;
    63   rtems_status_code sc = rtems_semaphore_release(ctx->semaphore_id);
    64   rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    65 }
    66 
    67 static bool test_body(void *arg)
     52    T_quiet_true(sc == RTEMS_SUCCESSFUL || sc == RTEMS_TIMEOUT);
     53  }
     54}
     55
     56static T_interrupt_test_state interrupt(void *arg)
    6857{
    6958  test_context *ctx = arg;
    70   int busy;
     59  T_interrupt_test_state state;
     60  rtems_status_code sc;
     61
     62  state = T_interrupt_test_get_state();
     63
     64  if (state != T_INTERRUPT_TEST_ACTION) {
     65    return T_INTERRUPT_TEST_CONTINUE;
     66  }
     67
     68  sc = rtems_semaphore_release(ctx->semaphore_id);
     69  T_quiet_rsc_success(sc);
     70
     71  if ( ctx->early ) {
     72    state = T_INTERRUPT_TEST_EARLY;
     73  } else if ( ctx->late ) {
     74    state = T_INTERRUPT_TEST_LATE;
     75  } else if (
     76    ctx->thread_queue_was_null
     77      && ctx->status_was_successful
     78      && ctx->status_was_timeout
     79  ) {
     80    state = T_INTERRUPT_TEST_DONE;
     81  } else {
     82    state = T_INTERRUPT_TEST_CONTINUE;
     83  }
     84
     85  return state;
     86}
     87
     88static void prepare(void *arg)
     89{
     90  test_context *ctx = arg;
     91
     92  ctx->early = true;
     93  ctx->late = false;
     94}
     95
     96static void action(void *arg)
     97{
     98  test_context *ctx = arg;
    7199  Per_CPU_Control *cpu_self;
    72100
    73101  cpu_self = _Thread_Dispatch_disable();
    74 
    75   rtems_test_assert(
    76     _Thread_Wait_get_status( ctx->semaphore_task_tcb ) == STATUS_SUCCESSFUL
    77   );
    78 
    79   /*
    80    * Spend some time to make it more likely that we hit the test condition
    81    * below.
    82    */
    83   for (busy = 0; busy < 1000; ++busy) {
    84     __asm__ volatile ("");
    85   }
     102  ctx->early = false;
     103
     104  T_quiet_rsc_success(_Thread_Wait_get_status( ctx->semaphore_task_tcb ));
    86105
    87106  if (ctx->semaphore_task_tcb->Wait.queue == NULL) {
     
    99118      break;
    100119    default:
    101       rtems_test_assert(0);
     120      T_unreachable();
    102121      break;
    103122  }
    104123
     124  ctx->late = true;
    105125  _Thread_Dispatch_enable(cpu_self);
    106126
    107   return ctx->thread_queue_was_null
    108     && ctx->status_was_successful
    109     && ctx->status_was_timeout;
    110 }
    111 
    112 static void Init(rtems_task_argument ignored)
    113 {
    114   test_context *ctx = &ctx_instance;
     127  T_interrupt_test_busy_wait_for_interrupt();
     128}
     129
     130static const T_interrupt_test_config config = {
     131  .prepare = prepare,
     132  .action = action,
     133  .interrupt = interrupt,
     134  .max_iteration_count = 10000
     135};
     136
     137T_TEST_CASE(SemaphoreObtainTimeoutInterrupt)
     138{
     139  test_context ctx;
    115140  rtems_status_code sc;
    116 
    117   TEST_BEGIN();
    118 
    119   ctx->master_task = rtems_task_self();
     141  T_interrupt_test_state state;
     142
     143  memset(&ctx, 0, sizeof(ctx));
     144  ctx.master_task = rtems_task_self();
    120145
    121146  sc = rtems_semaphore_create(
     
    124149    RTEMS_COUNTING_SEMAPHORE,
    125150    0,
    126     &ctx->semaphore_id
     151    &ctx.semaphore_id
    127152  );
    128   rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     153  T_assert_rsc_success(sc);
    129154
    130155  sc = rtems_task_create(
     
    134159    RTEMS_DEFAULT_MODES,
    135160    RTEMS_DEFAULT_ATTRIBUTES,
    136     &ctx->semaphore_task
     161    &ctx.semaphore_task
    137162  );
    138   rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     163  T_assert_rsc_success(sc);
    139164
    140165  sc = rtems_task_start(
    141     ctx->semaphore_task,
     166    ctx.semaphore_task,
    142167    semaphore_task,
    143     (rtems_task_argument) ctx
     168    (rtems_task_argument) &ctx
    144169  );
    145   rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    146 
    147   interrupt_critical_section_test(test_body, ctx, release_semaphore);
    148 
    149   rtems_test_assert(ctx->thread_queue_was_null);
    150   rtems_test_assert(ctx->status_was_successful);
    151   rtems_test_assert(ctx->status_was_timeout);
    152 
    153   TEST_END();
    154 
    155   rtems_test_exit(0);
     170  T_assert_rsc_success(sc);
     171
     172  state = T_interrupt_test(&config, &ctx);
     173  T_eq_int(state, T_INTERRUPT_TEST_DONE);
     174
     175  T_true(ctx.thread_queue_was_null);
     176  T_true(ctx.status_was_successful);
     177  T_true(ctx.status_was_timeout);
     178
     179  sc = rtems_task_delete(ctx.semaphore_task);
     180  T_rsc_success(sc);
     181
     182  sc = rtems_semaphore_delete(ctx.semaphore_id);
     183  T_rsc_success(sc);
     184}
     185
     186static rtems_task Init(rtems_task_argument argument)
     187{
     188  rtems_test_run(argument, TEST_STATE);
    156189}
    157190
     
    163196#define CONFIGURE_MAXIMUM_SEMAPHORES 1
    164197#define CONFIGURE_MAXIMUM_TASKS 2
    165 #define CONFIGURE_MAXIMUM_TIMERS 1
    166 #define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
    167198
    168199#define CONFIGURE_INIT_TASK_PRIORITY PRIORITY_MASTER
  • testsuites/sptests/spintrcritical20/spintrcritical20.scn

    raebdd1da r38636e23  
    1 *** TEST INTERRUPT CRITICAL SECTION 20 ***
     1*** BEGIN OF TEST SPINTRCRITICAL 20 ***
     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 20
     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:SemaphoreObtainTimeoutInterrupt
     17P:0:0:UI1:init.c:159
     18P:1:0:UI1:init.c:169
     19P:2:0:UI1:init.c:176
     20P:3:0:UI1:init.c:179
     21P:4:0:UI1:init.c:181
     22P:5:0:UI1:init.c:182
     23P:6:0:UI1:init.c:183
     24P:7:0:UI1:init.c:186
     25P:8:0:UI1:init.c:189
     26E:SemaphoreObtainTimeoutInterrupt:N:9:F:0:D:0.105419
     27Z:SPINTRCRITICAL 20:C:1:N:9:F:0:D:0.106593
     28Y:ReportHash:SHA256:8429590b312ac9e661529a4a932470feefd05747f60d30afaee1486259d26972
    229
    3 Support - rtems_timer_create - creating timer 1
    4 *** END OF TEST INTERRUPT CRITICAL SECTION 20 ***
     30*** END OF TEST SPINTRCRITICAL 20 ***
Note: See TracChangeset for help on using the changeset viewer.