source: rtems/testsuites/smptests/smpfatal03/init.c @ 73f9c2c

5
Last change on this file since 73f9c2c was 73f9c2c, checked in by Sebastian Huber <sebastian.huber@…>, on 11/23/16 at 12:38:25

smptests/smpfatal03: Use timer to provoke error

Avoid use of internal _Thread_Dispatch_disable() function.

Update #2825.

  • Property mode set to 100644
File size: 2.1 KB
RevLine 
[3a27248]1/*
2 * Copyright (c) 2016 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Dornierstr. 4
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.com/license/LICENSE.
13 */
14
15#ifdef HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#define TESTS_USE_PRINTK
20#include "tmacros.h"
21
22const char rtems_test_name[] = "SMPFATAL 3";
23
[73f9c2c]24static void bad( rtems_id timer_id, void *arg )
[3a27248]25{
26  rtems_id *sem_id;
27
[73f9c2c]28  sem_id = arg;
[3a27248]29
[73f9c2c]30  rtems_semaphore_obtain( *sem_id, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
31  rtems_test_assert( 0 );
[3a27248]32}
33
[73f9c2c]34static void Init( rtems_task_argument arg )
[3a27248]35{
36  rtems_status_code sc;
[73f9c2c]37  rtems_id          timer_id;
38  rtems_id          sem_id;
[3a27248]39
40  TEST_BEGIN();
41
42  sc = rtems_semaphore_create(
43    rtems_build_name('M', 'R', 'S', 'P'),
44    1,
45    RTEMS_MULTIPROCESSOR_RESOURCE_SHARING
46      | RTEMS_BINARY_SEMAPHORE,
47    1,
48    &sem_id
49  );
[73f9c2c]50  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
[3a27248]51
[73f9c2c]52  sc = rtems_timer_create(
53    rtems_build_name( 'E', 'V', 'I', 'L' ),
54    &timer_id
[3a27248]55  );
[73f9c2c]56  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
[3a27248]57
[73f9c2c]58  sc = rtems_semaphore_obtain( sem_id, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
59  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
[3a27248]60
[73f9c2c]61  sc = rtems_timer_fire_after( timer_id, 1, bad, &sem_id );
62  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
[3a27248]63
[73f9c2c]64  rtems_task_wake_after( 2 );
65  rtems_test_assert( 0 );
[3a27248]66}
67
68static void fatal_extension(
69  rtems_fatal_source source,
70  bool is_internal,
71  rtems_fatal_code code
72)
73{
74  if (
75    source == INTERNAL_ERROR_CORE
76      && !is_internal
77      && code == INTERNAL_ERROR_THREAD_QUEUE_ENQUEUE_STICKY_FROM_BAD_STATE
78  ) {
79    TEST_END();
80  }
81}
82
[73f9c2c]83#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
[3a27248]84#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
85
86#define CONFIGURE_INITIAL_EXTENSIONS \
87  { .fatal = fatal_extension }, \
88  RTEMS_TEST_INITIAL_EXTENSION
89
[73f9c2c]90#define CONFIGURE_MAXIMUM_TASKS 1
91#define CONFIGURE_MAXIMUM_TIMERS 1
[3a27248]92#define CONFIGURE_MAXIMUM_MRSP_SEMAPHORES 1
93
94#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
95
96#define CONFIGURE_INIT
97
98#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.