Esempio n. 1
0
File: init.c Progetto: Dipupo/rtems
static void any_satisfy_before_timeout(rtems_id timer, void *arg)
{
  rtems_status_code sc;
  test_context *ctx = arg;
  Thread_Control *thread = ctx->thread;
  Thread_Wait_flags flags = _Thread_Wait_flags_get(thread);

  if (blocks_for_event(flags)) {
    ctx->hit = interrupts_blocking_op(flags);

    rtems_test_assert(
      *(rtems_event_set *) thread->Wait.return_argument == DEADBEEF
    );
    rtems_test_assert(thread->Wait.return_code == RTEMS_SUCCESSFUL);

    sc = rtems_event_send(thread->Object.id, GREEN);
    rtems_test_assert(sc == RTEMS_SUCCESSFUL);

    rtems_test_assert(
      *(rtems_event_set *) thread->Wait.return_argument == GREEN
    );
    rtems_test_assert(thread->Wait.return_code == RTEMS_SUCCESSFUL);

    sc = rtems_event_send(thread->Object.id, RED);
    rtems_test_assert(sc == RTEMS_SUCCESSFUL);

    rtems_test_assert(
      *(rtems_event_set *) thread->Wait.return_argument == GREEN
    );
    rtems_test_assert(thread->Wait.return_code == RTEMS_SUCCESSFUL);

    _Thread_Timeout(&thread->Timer.Watchdog);

    rtems_test_assert(
      *(rtems_event_set *) thread->Wait.return_argument == GREEN
    );
    rtems_test_assert(thread->Wait.return_code == RTEMS_SUCCESSFUL);

    if (ctx->hit) {
      rtems_test_assert(
        _Thread_Wait_flags_get(thread)
          == (THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_READY_AGAIN)
      );
    }

    rtems_test_assert(thread->Wait.count == EVENTS);
  }

  sc = rtems_timer_reset(timer);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}
Esempio n. 2
0
static bool test_body(void *arg)
{
  test_context *ctx = arg;
  int busy;

  _Thread_Disable_dispatch();

  rtems_test_assert(
    ctx->semaphore_task_tcb->Wait.return_code
      == CORE_SEMAPHORE_STATUS_SUCCESSFUL
  );

  /*
   * Spend some time to make it more likely that we hit the test condition
   * below.
   */
  for (busy = 0; busy < 1000; ++busy) {
    __asm__ volatile ("");
  }

  if (ctx->semaphore_task_tcb->Wait.queue == NULL) {
    ctx->thread_queue_was_null = true;
  }

  _Thread_Timeout(0, ctx->semaphore_task_tcb);

  switch (ctx->semaphore_task_tcb->Wait.return_code) {
    case CORE_SEMAPHORE_STATUS_SUCCESSFUL:
      ctx->status_was_successful = true;
      break;
    case CORE_SEMAPHORE_TIMEOUT:
      ctx->status_was_timeout = true;
      break;
    default:
      rtems_test_assert(0);
      break;
  }

  _Thread_Enable_dispatch();

  return ctx->thread_queue_was_null
    && ctx->status_was_successful
    && ctx->status_was_timeout;
}
Esempio n. 3
0
static bool test_body(void *arg)
{
  test_context *ctx = arg;
  int busy;
  Per_CPU_Control *cpu_self;

  cpu_self = _Thread_Dispatch_disable();

  rtems_test_assert(
    _Thread_Wait_get_status( ctx->semaphore_task_tcb ) == STATUS_SUCCESSFUL
  );

  /*
   * Spend some time to make it more likely that we hit the test condition
   * below.
   */
  for (busy = 0; busy < 1000; ++busy) {
    __asm__ volatile ("");
  }

  if (ctx->semaphore_task_tcb->Wait.queue == NULL) {
    ctx->thread_queue_was_null = true;
  }

  _Thread_Timeout(&ctx->semaphore_task_tcb->Timer.Watchdog);

  switch (_Thread_Wait_get_status(ctx->semaphore_task_tcb)) {
    case STATUS_SUCCESSFUL:
      ctx->status_was_successful = true;
      break;
    case STATUS_TIMEOUT:
      ctx->status_was_timeout = true;
      break;
    default:
      rtems_test_assert(0);
      break;
  }

  _Thread_Dispatch_enable(cpu_self);

  return ctx->thread_queue_was_null
    && ctx->status_was_successful
    && ctx->status_was_timeout;
}