Changeset 436a4b3 in rtems


Ignore:
Timestamp:
Jan 24, 2017, 8:43:20 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5, master
Children:
6af2221
Parents:
3d20f5fb
git-author:
Sebastian Huber <sebastian.huber@…> (01/24/17 08:43:20)
git-committer:
Sebastian Huber <sebastian.huber@…> (01/24/17 08:44:02)
Message:

smptests/smpsignal01: Check signal ISR level

Close #2751.

Location:
testsuites/smptests/smpsignal01
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • testsuites/smptests/smpsignal01/init.c

    r3d20f5fb r436a4b3  
    11/*
    2  * Copyright (c) 2013 embedded brains GmbH.  All rights reserved.
     2 * Copyright (c) 2013, 2017 embedded brains GmbH.  All rights reserved.
    33 *
    44 *  embedded brains GmbH
     
    3939  uint32_t consumer_processor;
    4040  uint32_t producer_processor;
     41  rtems_id timer;
     42  volatile bool done;
    4143} test_context;
    4244
     
    6163{
    6264  test_context *ctx = &ctx_instance;
     65
     66  rtems_test_assert(_ISR_Get_level() == 0);
    6367
    6468  switch (ctx->state) {
     
    120124}
    121125
    122 static void test(void)
    123 {
    124   test_context *ctx = &ctx_instance;
     126static void test_two_processors(test_context *ctx)
     127{
    125128  rtems_status_code sc;
    126129  rtems_mode mode;
    127 
    128   ctx->consumer = rtems_task_self();
    129   ctx->consumer_processor = rtems_get_current_processor();
    130130
    131131  sc = rtems_signal_catch(signal_handler, RTEMS_DEFAULT_MODES);
     
    152152  sc = rtems_task_mode(RTEMS_ASR, RTEMS_ASR_MASK, &mode);
    153153  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     154  rtems_test_assert(mode == RTEMS_NO_ASR);
    154155
    155156  wait_for_state(ctx, SIG_0_PROCESSED);
     
    163164}
    164165
     166static void isr_level_timer(rtems_id timer, void *arg)
     167{
     168  test_context *ctx = arg;
     169  rtems_status_code sc;
     170
     171  sc = rtems_signal_send(ctx->consumer, TEST_SIGNAL);
     172  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     173}
     174
     175static void isr_level_handler(rtems_signal_set signal)
     176{
     177  test_context *ctx = &ctx_instance;
     178
     179  rtems_test_assert(_ISR_Get_level() == 0);
     180
     181  ctx->done = true;
     182}
     183
     184static void test_isr_level(test_context *ctx)
     185{
     186  rtems_status_code sc;
     187  rtems_mode mode;
     188
     189  sc = rtems_task_mode(RTEMS_ASR, RTEMS_ASR_MASK, &mode);
     190  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     191  rtems_test_assert(mode == RTEMS_NO_ASR);
     192
     193  sc = rtems_timer_create(rtems_build_name('T', 'I', 'M', 'R'), &ctx->timer);
     194  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     195
     196  rtems_test_assert(!ctx->done);
     197
     198  sc = rtems_signal_catch(isr_level_handler, RTEMS_DEFAULT_MODES);
     199  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     200
     201  sc = rtems_timer_fire_after(ctx->timer, 1, isr_level_timer, ctx);
     202  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     203
     204  while (!ctx->done) {
     205    /* Wait for timer */
     206  }
     207
     208  sc = rtems_timer_delete(ctx->timer);
     209  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     210
     211  sc = rtems_task_mode(RTEMS_NO_ASR, RTEMS_ASR_MASK, &mode);
     212  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     213  rtems_test_assert(mode == RTEMS_ASR);
     214}
     215
    165216static void Init(rtems_task_argument arg)
    166217{
     218  test_context *ctx = &ctx_instance;
     219
    167220  TEST_BEGIN();
    168221
     222  ctx->consumer = rtems_task_self();
     223  ctx->consumer_processor = rtems_get_current_processor();
     224
     225  test_isr_level(ctx);
     226
    169227  if (rtems_get_processor_count() >= 2) {
    170     test();
     228    test_two_processors(ctx);
    171229  }
    172230
     
    184242#define CONFIGURE_MAXIMUM_TASKS 2
    185243
     244#define CONFIGURE_MAXIMUM_TIMERS 1
     245
    186246#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
    187247
Note: See TracChangeset for help on using the changeset viewer.