Changeset 6b795cd7 in rtems


Ignore:
Timestamp:
Jul 20, 2020, 5:45:51 AM (3 weeks ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
b2ff5fe
Parents:
23b9debe
git-author:
Sebastian Huber <sebastian.huber@…> (07/20/20 05:45:51)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/23/20 07:27:48)
Message:

spintrcritical24: Use T_interrupt_test()

Location:
testsuites/sptests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • testsuites/sptests/Makefile.am

    r23b9debe r6b795cd7  
    13811381sp_screens += spintrcritical24/spintrcritical24.scn
    13821382sp_docs += spintrcritical24/spintrcritical24.doc
    1383 spintrcritical24_SOURCES = spintrcritical24/init.c \
    1384         spintrcritical_support/intrcritical.h \
    1385         spintrcritical_support/intrcritical.c
     1383spintrcritical24_SOURCES = spintrcritical24/init.c
    13861384spintrcritical24_CPPFLAGS = $(AM_CPPFLAGS) \
    13871385        $(TEST_FLAGS_spintrcritical24) $(support_includes) \
  • testsuites/sptests/spintrcritical24/init.c

    r23b9debe r6b795cd7  
    11/*
    2  * Copyright (c) 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) 2017, 2020 embedded brains GmbH (http://www.embedded-brains.de)
    93 *
    104 * The license and distribution terms for this file may be
     
    1812
    1913#include <sys/stat.h>
     14#include <errno.h>
    2015#include <fcntl.h>
     16#include <string.h>
    2117#include <unistd.h>
    22 #include <errno.h>
    2318
    2419#include <rtems/imfs.h>
    25 
    26 #include <tmacros.h>
    27 #include <intrcritical.h>
     20#include <rtems/libio_.h>
     21#include <rtems/test-info.h>
     22#include <rtems/test.h>
    2823
    2924const char rtems_test_name[] = "SPINTRCRITICAL 24";
     
    3126typedef struct {
    3227  int fd;
     28  rtems_libio_t *iop;
     29  long early_count;
     30  long late_count;
     31  long potential_hit_count;
    3332  long append_count;
    3433  long no_append_count;
     34  volatile bool closed;
    3535} test_context;
    3636
    37 static test_context test_instance;
    38 
    3937static const char path[] = "generic";
    4038
     
    4442
    4543  ctx = IMFS_generic_get_context_by_iop(iop);
     44  ctx->closed = true;
    4645
    4746  if (rtems_libio_iop_is_append(iop)) {
     
    6867};
    6968
    70 static void do_fcntl(rtems_id timer, void *arg)
    71 {
    72   /* The arg is NULL */
    73   test_context *ctx;
     69static T_interrupt_test_state interrupt(void *arg)
     70{
     71  test_context *ctx;
     72  T_interrupt_test_state state;
    7473  int rv;
    75 
    76   ctx = &test_instance;
     74  unsigned int flags;
     75
     76  state = T_interrupt_test_get_state();
     77
     78  if (state != T_INTERRUPT_TEST_ACTION) {
     79    return T_INTERRUPT_TEST_CONTINUE;
     80  }
     81
     82  ctx = arg;
     83  flags = rtems_libio_iop_flags_set(ctx->iop, 0);
     84
     85  if ((flags & LIBIO_FLAGS_OPEN) != 0) {
     86    ++ctx->early_count;
     87    state = T_INTERRUPT_TEST_EARLY;
     88  } else if (ctx->closed) {
     89    ++ctx->late_count;
     90    state = T_INTERRUPT_TEST_LATE;
     91  } else {
     92    ++ctx->potential_hit_count;
     93
     94    if (ctx->potential_hit_count >= 13) {
     95      state = T_INTERRUPT_TEST_DONE;
     96    } else {
     97      state = T_INTERRUPT_TEST_CONTINUE;
     98    }
     99  }
    77100
    78101  rv = fcntl(ctx->fd, F_SETFL, O_APPEND);
    79102
    80103  if (rv != 0) {
    81     rtems_test_assert(rv == -1);
    82     rtems_test_assert(errno == EBADF);
    83   }
    84 }
    85 
    86 static bool test_body(void *arg)
     104    T_quiet_psx_error(rv, EBADF);
     105  }
     106
     107  return state;
     108}
     109
     110static void prepare(void *arg)
     111{
     112  test_context *ctx;
     113
     114  ctx = arg;
     115
     116  ctx->fd = open(path, O_RDWR);
     117  T_quiet_ge_int(ctx->fd, 0);
     118
     119  ctx->closed = false;
     120  ctx->iop = rtems_libio_iop(ctx->fd);
     121}
     122
     123static void action(void *arg)
    87124{
    88125  test_context *ctx;
     
    91128  ctx = arg;
    92129
    93   ctx->fd = open(path, O_RDWR);
    94   rtems_test_assert(ctx->fd >= 0);
    95 
    96130  rv = close(ctx->fd);
    97   rtems_test_assert(rv == 0);
    98 
    99   return false;
    100 }
    101 
    102 static void test(test_context *ctx)
    103 {
     131  T_quiet_psx_success(rv);
     132
     133  T_interrupt_test_busy_wait_for_interrupt();
     134}
     135
     136static const T_interrupt_test_config config = {
     137  .prepare = prepare,
     138  .action = action,
     139  .interrupt = interrupt,
     140  .max_iteration_count = 10000
     141};
     142
     143T_TEST_CASE(CloseInterrupt)
     144{
     145  test_context ctx;
    104146  const char *path = "generic";
    105147  int rv;
     148  T_interrupt_test_state state;
     149
     150  memset(&ctx, 0, sizeof(ctx));
    106151
    107152  rv = IMFS_make_generic_node(
     
    109154    S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO,
    110155    &node_control,
    111     ctx
     156    &ctx
    112157  );
    113   rtems_test_assert(rv == 0);
    114 
    115   interrupt_critical_section_test(test_body, ctx, do_fcntl);
     158  T_psx_success(rv);
     159
     160  state = T_interrupt_test(&config, &ctx);
     161  T_eq_int(state, T_INTERRUPT_TEST_DONE);
     162
     163  T_log(T_NORMAL, "early count = %ld", ctx.early_count);
     164  T_log(T_NORMAL, "late count = %ld", ctx.late_count);
     165  T_log(T_NORMAL, "potential hit count = %ld", ctx.potential_hit_count);
     166  T_log(T_NORMAL, "append count = %ld", ctx.append_count);
     167  T_log(T_NORMAL, "no append count = %ld", ctx.no_append_count);
    116168
    117169  /* There is no reliable indicator if the test case has been hit */
    118   rtems_test_assert(ctx->append_count > 0);
    119   rtems_test_assert(ctx->no_append_count > 0);
     170  T_gt_int(ctx.early_count, 0);
     171  T_gt_int(ctx.late_count, 0);
     172  T_gt_int(ctx.potential_hit_count, 0);
     173  T_gt_int(ctx.append_count, 0);
     174  T_gt_int(ctx.no_append_count, 0);
    120175
    121176  rv = unlink(path);
    122   rtems_test_assert(rv == 0);
     177  T_psx_success(rv);
    123178}
    124179
    125180static void Init(rtems_task_argument arg)
    126181{
    127   TEST_BEGIN();
    128   test(&test_instance);
    129   TEST_END();
    130   rtems_test_exit(0);
     182  rtems_test_run(arg, TEST_STATE);
    131183}
    132184
     
    139191
    140192#define CONFIGURE_MAXIMUM_TASKS 1
    141 #define CONFIGURE_MAXIMUM_TIMERS 1
    142 #define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
    143193
    144194#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
  • testsuites/sptests/spintrcritical24/spintrcritical24.scn

    r23b9debe r6b795cd7  
    11*** BEGIN OF TEST SPINTRCRITICAL 24 ***
     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 24
     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:CloseInterrupt
     17P:0:0:UI1:init.c:164
     18P:1:0:UI1:init.c:167
     19L:early count = 743
     20L:late count = 805
     21L:potential hit count = 13
     22L:append count = 743
     23L:no append count = 818
     24P:2:0:UI1:init.c:176
     25P:3:0:UI1:init.c:177
     26P:4:0:UI1:init.c:178
     27P:5:0:UI1:init.c:179
     28P:6:0:UI1:init.c:180
     29P:7:0:UI1:init.c:183
     30E:CloseInterrupt:N:8:F:0:D:2.052931
     31Z:SPINTRCRITICAL 24:C:1:N:8:F:0:D:2.054026
     32Y:ReportHash:SHA256:950758e81490ad319486e6dc135fe5634bc9c9e7b19537346335e759f932fb56
     33
    234*** END OF TEST SPINTRCRITICAL 24 ***
Note: See TracChangeset for help on using the changeset viewer.