Changeset 857a65d in rtems


Ignore:
Timestamp:
Jul 20, 2020, 9:50:53 AM (3 weeks ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
21f7333
Parents:
cc3fd8fc
git-author:
Sebastian Huber <sebastian.huber@…> (07/20/20 09:50:53)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/23/20 07:27:47)
Message:

psxintrcritical01: Use T_interrupt_test()

Location:
testsuites/psxtests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • testsuites/psxtests/Makefile.am

    rcc3fd8fc r857a65d  
    526526psx_screens += psxintrcritical01/psxintrcritical01.scn
    527527psx_docs += psxintrcritical01/psxintrcritical01.doc
    528 psxintrcritical01_SOURCES = psxintrcritical01/init.c \
    529         ../sptests/spintrcritical_support/intrcritical.c
     528psxintrcritical01_SOURCES = psxintrcritical01/init.c
    530529psxintrcritical01_CPPFLAGS = $(AM_CPPFLAGS) \
    531530        $(TEST_FLAGS_psxintrcritical01) $(support_includes) \
  • testsuites/psxtests/psxintrcritical01/init.c

    rcc3fd8fc r857a65d  
    11/*
     2 *  Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
     3 *
    24 *  COPYRIGHT (c) 1989-2012.
    35 *  On-Line Applications Research Corporation (OAR).
     
    1214#endif
    1315
    14 #include <tmacros.h>
    15 #include <intrcritical.h>
     16#include <string.h>
    1617#include <time.h>
     18
     19#include <rtems/test.h>
     20#include <rtems/simple-test.h>
    1721
    1822const char rtems_test_name[] = "PSXINTRCRITICAL 1";
    1923
    20 /* forward declarations to avoid warnings */
    21 rtems_task Init(rtems_task_argument ignored);
    22 
    23 #define TEST_NAME          "01"
    24 #define TEST_STRING        "POSIX Timer"
    25 
    26 static timer_t           Timer;
    27 static struct itimerspec TimerParams;
     24typedef struct {
     25  timer_t           timer;
     26  struct itimerspec spec;
     27  volatile bool early;
     28  volatile bool late;
     29  long early_count;
     30  long late_count;
     31  long potential_hits;
     32} test_context;
    2833
    2934#define POSIX_TIMER_RELATIVE 0
    3035
    31 static bool test_body( void *arg )
     36static void prepare(void *arg)
    3237{
     38  test_context *ctx;
     39
     40  ctx = arg;
     41  ctx->early = false;
     42  ctx->late = false;
     43}
     44
     45static void action(void *arg)
     46{
     47  test_context *ctx;
    3348  int rv;
    3449
    35   (void) arg;
     50  ctx = arg;
     51  ctx->early = true;
     52  rv = timer_settime(ctx->timer, POSIX_TIMER_RELATIVE, &ctx->spec, NULL);
     53  ctx->late = true;
     54  T_quiet_psx_success(rv);
    3655
    37   rv = timer_settime(Timer, POSIX_TIMER_RELATIVE, &TimerParams, NULL);
    38   rtems_test_assert( rv == 0 );
    39 
    40   return false;
     56  while (T_interrupt_test_get_state() == T_INTERRUPT_TEST_ACTION) {
     57    /* Wait */
     58  }
    4159}
    4260
    43 static rtems_timer_service_routine test_release_from_isr(
    44   rtems_id  timer,
    45   void     *arg
    46 )
     61static T_interrupt_test_state interrupt(void *arg)
    4762{
    48   test_body( NULL );
     63  test_context *ctx;
     64  T_interrupt_test_state state;
     65  int rv;
     66
     67  state = T_interrupt_test_get_state();
     68
     69  if (state != T_INTERRUPT_TEST_ACTION) {
     70    return T_INTERRUPT_TEST_EARLY;
     71  }
     72
     73  ctx = arg;
     74  rv = timer_settime(ctx->timer, POSIX_TIMER_RELATIVE, &ctx->spec, NULL);
     75  T_quiet_psx_success(rv);
     76
     77  if (ctx->late) {
     78    ++ctx->late_count;
     79    return T_INTERRUPT_TEST_LATE;
     80  } else if (ctx->early) {
     81    ++ctx->early_count;
     82    return T_INTERRUPT_TEST_EARLY;
     83  } else {
     84    ++ctx->potential_hits;
     85
     86    if (ctx->potential_hits > 13) {
     87      return T_INTERRUPT_TEST_DONE;
     88    } else {
     89      return T_INTERRUPT_TEST_CONTINUE;
     90    }
     91  }
    4992}
    5093
    51 rtems_task Init(
    52   rtems_task_argument ignored
    53 )
     94static const T_interrupt_test_config config = {
     95  .prepare = prepare,
     96  .action = action,
     97  .interrupt = interrupt,
     98  .max_iteration_count = 10000
     99};
     100
     101T_TEST_CASE(PSXSetTimerInterrupt)
    54102{
     103  test_context ctx;
    55104  int sc;
     105  T_interrupt_test_state state;
    56106
    57   TEST_BEGIN();
    58 
    59   puts( "Init - Trying to generate timer fire from ISR while firing" );
    60   puts( "Init - Variation is: " TEST_STRING );
    61 
    62   puts( "Init - There is no way for the test to know if it hits the case" );
     107  memset(&ctx, 0, sizeof(ctx));
    63108
    64109  /* create POSIX Timer */
    65   sc = timer_create (CLOCK_REALTIME, NULL, &Timer);
    66   if ( sc == -1 ) {
    67     perror ("Error in timer creation\n");
    68     rtems_test_exit(0);
    69   }
     110  sc = timer_create (CLOCK_REALTIME, NULL, &ctx.timer);
     111  T_psx_success(sc);
    70112
    71113  /* we don't care if it ever fires */
    72   TimerParams.it_interval.tv_sec  = 10;
    73   TimerParams.it_interval.tv_nsec = 0;
    74   TimerParams.it_value.tv_sec     = 10;
    75   TimerParams.it_value.tv_nsec    = 0;
     114  ctx.spec.it_interval.tv_sec  = 10;
     115  ctx.spec.it_value.tv_sec     = 10;
    76116
    77   interrupt_critical_section_test( test_body, NULL, test_release_from_isr );
     117  state = T_interrupt_test(&config, &ctx);
     118  T_eq_int(state, T_INTERRUPT_TEST_DONE);
    78119
    79   TEST_END();
    80   rtems_test_exit(0);
     120  T_log(T_NORMAL, "early count = %ld", ctx.early_count);
     121  T_log(T_NORMAL, "late count = %ld", ctx.late_count);
     122  T_log(T_NORMAL, "potential hits = %ld", ctx.potential_hits);
     123  T_gt_int(ctx.potential_hits, 0);
     124
     125  sc = timer_delete(ctx.timer);
     126  T_psx_success(sc);
     127}
     128
     129static rtems_task Init(rtems_task_argument arg)
     130{
     131  rtems_test_run(arg, TEST_STATE);
    81132}
    82133
     
    87138
    88139#define CONFIGURE_MAXIMUM_TASKS          1
    89 #define CONFIGURE_MAXIMUM_TIMERS         1
    90140#define CONFIGURE_MAXIMUM_POSIX_TIMERS   1
    91 #define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
    92141#define CONFIGURE_MICROSECONDS_PER_TICK  1000
    93142#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
  • testsuites/psxtests/psxintrcritical01/psxintrcritical01.scn

    rcc3fd8fc r857a65d  
    1 *** TEST POSIX INTERRUPT CRITICAL SECTION 01 ***
    2 Init - Trying to generate timer fire from ISR while firing
    3 Init - Variation is: POSIX Timer
    4 Init - There is no way for the test to know if it hits the case
    5 Support - rtems_timer_create - creating timer 1
     1*** BEGIN OF TEST PSXINTRCRITICAL 1 ***
     2*** TEST VERSION: 6.0.0.2f9fa5f36a632a7acbab8ac3e6fc40ad36115ca0
     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:PSXINTRCRITICAL 1
     7S:Platform:RTEMS
     8S:Compiler:10.0.1 20200406 (RTEMS 6, RSB bec88a6dd856892c3e66e4598252ea07d7a0d762, Newlib ece49e4)
     9S:Version:6.0.0.2f9fa5f36a632a7acbab8ac3e6fc40ad36115ca0
     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:PSXSetTimerInterrupt
     17P:0:0:UI1:init.c:111
     18P:1:0:UI1:init.c:118
     19L:early count = 13
     20L:late count = 46
     21L:potential hits = 14
     22P:2:0:UI1:init.c:123
     23P:3:0:UI1:init.c:126
     24E:PSXSetTimerInterrupt:N:4:F:0:D:0.117464
     25Z:PSXINTRCRITICAL 1:C:1:N:4:F:0:D:0.118703
     26Y:ReportHash:SHA256:ab4ae616216edb337cbe6b3adb8d62d1a98ff4f7422966689c6967cce78f9d69
     27
     28*** END OF TEST PSXINTRCRITICAL 1 ***
Note: See TracChangeset for help on using the changeset viewer.