Changeset 23b9debe in rtems


Ignore:
Timestamp:
Jul 21, 2020, 5:32:10 AM (3 weeks ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
6b795cd7
Parents:
1414e71
git-author:
Sebastian Huber <sebastian.huber@…> (07/21/20 05:32:10)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/23/20 07:27:48)
Message:

spintrcritical23: Use T_interrupt_test()

Location:
testsuites/sptests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • testsuites/sptests/Makefile.am

    r1414e71 r23b9debe  
    13711371sp_screens += spintrcritical23/spintrcritical23.scn
    13721372sp_docs += spintrcritical23/spintrcritical23.doc
    1373 spintrcritical23_SOURCES = spintrcritical23/init.c \
    1374         spintrcritical_support/intrcritical.h \
    1375         spintrcritical_support/intrcritical.c
     1373spintrcritical23_SOURCES = spintrcritical23/init.c
    13761374spintrcritical23_CPPFLAGS = $(AM_CPPFLAGS) \
    13771375        $(TEST_FLAGS_spintrcritical23) $(support_includes) \
  • testsuites/sptests/spintrcritical23/init.c

    r1414e71 r23b9debe  
    11/*
    2  * Copyright (c) 2015, 2017 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) 2015, 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
    2216#include <string.h>
     
    3428  rtems_task_priority priority_task;
    3529  rtems_task_priority priority_interrupt;
    36   bool done;
     30  volatile bool early;
     31  volatile bool late;
    3732} test_context;
    3833
    39 static test_context ctx_instance;
    40 
    41 static void change_priority(rtems_id timer, void *arg)
     34static T_interrupt_test_state interrupt(void *arg)
    4235{
    43   /* The arg is NULL */
    44   test_context *ctx = &ctx_instance;
     36  test_context *ctx = arg;
     37  T_interrupt_test_state state;
    4538  rtems_interrupt_lock_context lock_context;
    4639  unsigned int next_priority;
     40
     41  state = T_interrupt_test_get_state();
     42
     43  if (state != T_INTERRUPT_TEST_ACTION) {
     44    return T_INTERRUPT_TEST_CONTINUE;
     45  }
    4746
    4847  rtems_interrupt_lock_acquire(&ctx->lock, &lock_context);
     
    6867      &previous
    6968    );
    70     rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    71     rtems_test_assert(previous == priority_task);
     69    T_quiet_rsc_success(sc);
     70    T_quiet_eq_u32(previous, priority_task);
    7271
    73     ctx->done = true;
     72    state = T_INTERRUPT_TEST_DONE;
    7473  } else {
    7574    rtems_interrupt_lock_release(&ctx->lock, &lock_context);
     75
     76    if ( ctx->early ) {
     77      state = T_INTERRUPT_TEST_EARLY;
     78    } else if ( ctx->late ) {
     79      state = T_INTERRUPT_TEST_LATE;
     80    } else {
     81      state = T_INTERRUPT_TEST_CONTINUE;
     82    }
    7683  }
     84
     85  return state;
    7786}
    7887
    79 static bool test_body(void *arg)
     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)
    8097{
    8198  test_context *ctx = arg;
     
    97114  rtems_interrupt_lock_release(&ctx->lock, &lock_context);
    98115
     116  ctx->early = false;
    99117  sc = rtems_task_set_priority(
    100118    ctx->task_id,
     
    102120    &previous
    103121  );
    104   rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    105   rtems_test_assert(previous == priority_last);
     122  T_quiet_rsc_success(RTEMS_SUCCESSFUL);
     123  T_quiet_eq_u32(previous, priority_last);
     124  ctx->late = true;
    106125
    107   if (ctx->done) {
     126  if (T_interrupt_test_get_state() == T_INTERRUPT_TEST_DONE) {
    108127    sc = rtems_task_set_priority(
    109128      ctx->task_id,
     
    111130      &previous
    112131    );
    113     rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    114     rtems_test_assert(previous == priority_interrupt);
     132    T_quiet_rsc_success(sc);
     133    T_quiet_eq_u32(previous, priority_interrupt);
    115134  }
    116 
    117   return ctx->done;
    118135}
    119136
    120 static void Init(rtems_task_argument arg)
     137static const T_interrupt_test_config config = {
     138  .prepare = prepare,
     139  .action = action,
     140  .interrupt = interrupt,
     141  .max_iteration_count = 10000
     142};
     143
     144T_TEST_CASE(TaskSetPriorityInterrupt)
    121145{
    122   test_context *ctx = &ctx_instance;
     146  test_context ctx;
     147  T_interrupt_test_state state;
    123148
    124   TEST_BEGIN();
    125 
    126   rtems_interrupt_lock_initialize(&ctx->lock, "Test");
    127   ctx->priority_task = 1;
    128   ctx->task_id = rtems_task_self();
    129   ctx->scheduler_node =
     149  memset(&ctx, 0, sizeof(ctx));
     150  rtems_interrupt_lock_initialize(&ctx.lock, "Test");
     151  ctx.priority_task = 1;
     152  ctx.task_id = rtems_task_self();
     153  ctx.scheduler_node =
    130154    _Scheduler_priority_Thread_get_node(_Thread_Get_executing());
    131155
    132   interrupt_critical_section_test(test_body, ctx, change_priority);
    133   rtems_test_assert(ctx->done);
     156  state = T_interrupt_test(&config, &ctx);
     157  T_eq_int(state, T_INTERRUPT_TEST_DONE);
    134158
    135   TEST_END();
    136   rtems_test_exit(0);
     159  rtems_interrupt_lock_destroy(&ctx.lock);
     160}
     161
     162static rtems_task Init(rtems_task_argument argument)
     163{
     164  rtems_test_run(argument, TEST_STATE);
    137165}
    138166
     
    143171
    144172#define CONFIGURE_MAXIMUM_TASKS 1
    145 #define CONFIGURE_MAXIMUM_TIMERS 1
    146 #define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
    147173
    148174/* We use internal data structures of this scheduler in this test */
  • testsuites/sptests/spintrcritical23/spintrcritical23.scn

    r1414e71 r23b9debe  
    11*** BEGIN OF TEST SPINTRCRITICAL 23 ***
     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 23
     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:TaskSetPriorityInterrupt
     17P:0:0:UI1:init.c:166
     18E:TaskSetPriorityInterrupt:N:1:F:0:D:0.914959
     19Z:SPINTRCRITICAL 23:C:1:N:1:F:0:D:0.916110
     20Y:ReportHash:SHA256:b4aa098c47f8352ac00c37c1b61aabebd8770febfa4fd8821a1121a59b3c2b80
     21
    222*** END OF TEST SPINTRCRITICAL 23 ***
Note: See TracChangeset for help on using the changeset viewer.