source: rtems/testsuites/sptests/spintrcritical06/init.c @ 6c0301d

4.115
Last change on this file since 6c0301d was 6c0301d, checked in by Sebastian Huber <sebastian.huber@…>, on 03/25/14 at 07:06:21

tests/sptests: Use <rtems/test.h>

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2012.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.org/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <tmacros.h>
15#include <intrcritical.h>
16
17/* forward declarations to avoid warnings */
18rtems_task Init(rtems_task_argument argument);
19rtems_timer_service_routine test_release_from_isr(rtems_id  timer, void *arg);
20rtems_task Secondary_task(rtems_task_argument arg);
21
22/* common parameters */
23#define SEMAPHORE_ATTRIBUTES     RTEMS_PRIORITY
24
25#if defined(PRIORITY_NO_TIMEOUT_FORWARD)
26  #define TEST_NAME          "6"
27  #define TEST_STRING        "Priority/Restart Search Task (Forward)"
28
29  #define INIT_PRIORITY      2
30  #define BLOCKER_PRIORITY   1
31  #define SEMAPHORE_OBTAIN_TIMEOUT 2
32
33#elif defined(PRIORITY_NO_TIMEOUT_REVERSE)
34  #define TEST_NAME          "7"
35  #define TEST_STRING        "Priority/Restart Search Task (Backward)"
36  #define INIT_PRIORITY      126
37  #define BLOCKER_PRIORITY   127
38  #define SEMAPHORE_OBTAIN_TIMEOUT 0
39
40#else
41
42  #error "Test Mode not defined"
43#endif
44
45const char rtems_test_name[] = "SPINTRCRITICAL " TEST_NAME;
46
47rtems_id Secondary_task_id;
48rtems_id Semaphore;
49
50rtems_timer_service_routine test_release_from_isr(
51  rtems_id  timer,
52  void     *arg
53)
54{
55  (void) rtems_task_restart( Secondary_task_id, 1 );
56}
57
58rtems_task Secondary_task(
59  rtems_task_argument arg
60)
61{
62  if ( arg )
63    (void) rtems_semaphore_flush( Semaphore );
64
65  (void) rtems_semaphore_obtain(
66    Semaphore,
67    RTEMS_DEFAULT_OPTIONS,
68    RTEMS_NO_TIMEOUT
69  );
70
71  rtems_test_assert(0);
72}
73
74rtems_task Init(
75  rtems_task_argument ignored
76)
77{
78  rtems_status_code     status;
79  int                   resets;
80
81  TEST_BEGIN();
82
83  puts( "Init - Trying to generate semaphore release from ISR while blocking" );
84  puts( "Init - There is no way for the test to know if it hits the case" );
85  puts( "Init - Variation is: " TEST_STRING );
86  status = rtems_semaphore_create(
87    rtems_build_name( 'S', 'M', '1', ' ' ),
88    0,
89    SEMAPHORE_ATTRIBUTES,
90    RTEMS_NO_PRIORITY,
91    &Semaphore
92  );
93  directive_failed( status, "rtems_semaphore_create of SM1" );
94
95  status = rtems_task_create(
96    rtems_build_name( 'B', 'L', 'C', 'K' ),
97    BLOCKER_PRIORITY,
98    RTEMS_MINIMUM_STACK_SIZE,
99    RTEMS_NO_PREEMPT,
100    RTEMS_DEFAULT_ATTRIBUTES,
101    &Secondary_task_id
102  );
103  directive_failed( status, "rtems_task_create" );
104
105  status = rtems_task_start( Secondary_task_id, Secondary_task, 0 );
106  directive_failed( status, "rtems_task_start" );
107
108  interrupt_critical_section_test_support_initialize( test_release_from_isr );
109
110  for (resets=0 ; resets< 2 ;) {
111    if ( interrupt_critical_section_test_support_delay() )
112      resets++;
113
114    status = rtems_semaphore_obtain(
115      Semaphore,
116      RTEMS_DEFAULT_OPTIONS,
117      SEMAPHORE_OBTAIN_TIMEOUT
118    );
119  }
120
121  TEST_END();
122  rtems_test_exit(0);
123}
124
125/* configuration information */
126
127#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
128#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
129
130#define CONFIGURE_MAXIMUM_TASKS       2
131#define CONFIGURE_MAXIMUM_TIMERS      1
132#define CONFIGURE_MAXIMUM_SEMAPHORES  1
133#define CONFIGURE_INIT_TASK_PRIORITY  INIT_PRIORITY
134#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_PREEMPT
135#define CONFIGURE_MICROSECONDS_PER_TICK  2000
136#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
137
138#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
139
140#define CONFIGURE_INIT
141#include <rtems/confdefs.h>
142
143/* global variables */
Note: See TracBrowser for help on using the repository browser.