source: rtems/testsuites/sptests/sp67/init.c @ ae75429

4.115
Last change on this file since ae75429 was ae75429, checked in by Sebastian Huber <sebastian.huber@…>, on 08/06/13 at 14:10:26

PR766: Delete RTEMS_VIOLATE_KERNEL_VISIBILITY

  • Property mode set to 100644
File size: 3.1 KB
Line 
1/*
2 *  Based upon test code posted on the RTEMS User's Mailing List
3 *  by Sergio Faustino <sergio.faustino@edisoft.pt>:
4 *
5 *    http://www.rtems.org/pipermail/rtems-users/2009-June/005540.html
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 */
11
12
13#ifdef HAVE_CONFIG_H
14#include "config.h"
15#endif
16
17#include <tmacros.h>
18
19#include <rtems/score/watchdogimpl.h>
20
21/* forward declarations to avoid warnings */
22rtems_task Init(rtems_task_argument argument);
23rtems_timer_service_routine TIMER_service_routine(
24  rtems_id  ignored_id,
25  void     *user_data
26);
27
28volatile bool _timer_passage_1 = FALSE;
29volatile bool _timer_passage_2 = FALSE;
30
31/*timer Routine*/
32rtems_timer_service_routine TIMER_service_routine(
33  rtems_id  ignored_id,
34  void     *user_data
35)
36{
37  bool *passed = (bool *)user_data;
38  *passed = TRUE;
39}
40
41rtems_task Init(
42  rtems_task_argument argument
43)
44{
45  rtems_status_code status;
46  rtems_id          timer1;
47  rtems_id          timer2;
48
49  puts( "\n\n*** TEST 67 ***" );
50
51  /* build timer name*/
52
53  /* create Timer */
54  puts( "Init - create timer 1" );
55  status = rtems_timer_create( rtems_build_name('T', 'M', '1', ' '), &timer1 );
56  directive_failed( status, "rtems_timer_create #1" );
57
58  puts( "Init - create timer 2" );
59  status = rtems_timer_create( rtems_build_name('T', 'M', '2', ' '), &timer2 );
60  directive_failed( status, "rtems_timer_create #1" );
61
62  /* Manipulate the time */
63  _Watchdog_Ticks_since_boot = (Watchdog_Interval) -15;
64
65  /* initiate timer server */
66  puts( "Init - Initiate the timer server" );
67  status = rtems_timer_initiate_server(
68    RTEMS_MINIMUM_PRIORITY,
69    RTEMS_MINIMUM_STACK_SIZE,
70    RTEMS_DEFAULT_ATTRIBUTES
71  );
72  directive_failed( status, "rtems_timer_initiate_server" );
73
74  /* Give the timer server some time to initialize */
75  status = rtems_task_wake_after( 10 );
76  directive_failed( status, "task wake_after" );
77
78  status = rtems_timer_server_fire_after(
79    timer1,
80    10,
81    TIMER_service_routine,
82    (void*) &_timer_passage_1
83  );
84  directive_failed( status, "rtems_timer_server_fire_after" );
85
86  status = rtems_timer_server_fire_after(
87    timer2,
88    20,
89    TIMER_service_routine,
90    (void*) &_timer_passage_2
91  );
92  directive_failed( status, "rtems_timer_server_fire_after" );
93
94  status = rtems_task_wake_after( 15 );
95  directive_failed( status, "task wake_after" );
96
97  if (!_timer_passage_1) {
98    puts( "Timer 1 FAILED to fire after wrapping time");
99    rtems_test_exit(0);
100  }
101  puts( "Server Timer 1 fired after wrapping ticks since boot-- OK");
102
103  if (_timer_passage_2) {
104    puts( "Timer 2 fired and should not have after wrapping time");
105    rtems_test_exit(0);
106  }
107
108  puts( "*** END OF TEST 67 ***" );
109  rtems_test_exit(0);
110}
111
112/* configuration stuff */
113
114#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
115#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
116
117#define CONFIGURE_MAXIMUM_TASKS              2
118#define CONFIGURE_MAXIMUM_TIMERS             2
119
120#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
121
122#define CONFIGURE_INIT
123#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.