source: rtems/testsuites/support/include/tmacros.h @ f96cb0b

4.104.114.84.95
Last change on this file since f96cb0b was f96cb0b, checked in by Joel Sherrill <joel.sherrill@…>, on 11/07/01 at 23:08:40

2001-11-07 Joel Sherrill <joel@…>

Tracked as PR72 but related to the object id problem (PR36)
reported by Todor.Todorov@….

  • include/tmacros.h: Added fatal_directive_check_status_only().
  • Property mode set to 100644
File size: 6.2 KB
Line 
1/*  tmacros.h
2 *
3 *  This include file contains macros which are useful in the RTEMS
4 *  test suites.
5 *
6 *  COPYRIGHT (c) 1989-1999.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *  $Id$
14 */
15
16#ifndef __TMACROS_h
17#define __TMACROS_h
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23#include <bsp.h>    /* includes <rtems.h> */
24
25#include <stdio.h>
26#include <stdlib.h>
27#include <string.h>
28#include <assert.h>
29#include <rtems/error.h>
30
31#define FOREVER 1                  /* infinite loop */
32
33#ifdef TEST_INIT
34#define TEST_EXTERN
35#define CONFIGURE_INIT
36#else
37#define TEST_EXTERN extern
38#endif
39
40#define check_dispatch_disable_level( _expect ) \
41  do { \
42    extern volatile rtems_unsigned32 _Thread_Dispatch_disable_level; \
43    if ( (_expect) != -1 && _Thread_Dispatch_disable_level != (_expect) ) { \
44      printf( "\n_Thread_Dispatch_disable_level is (%d) not %d\n", \
45              _Thread_Dispatch_disable_level, (_expect) ); \
46      fflush(stdout); \
47      exit( 1 ); \
48    } \
49  } while ( 0 )
50
51/*
52 *  These macros properly report errors within the Classic API
53 */
54
55#define directive_failed( _dirstat, _failmsg )  \
56 fatal_directive_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg )
57
58#define directive_failed_with_level( _dirstat, _failmsg, _level )  \
59 fatal_directive_status_with_level( \
60      _dirstat, RTEMS_SUCCESSFUL, _failmsg, _level )
61
62#define fatal_directive_status( _stat, _desired, _msg ) \
63  fatal_directive_status_with_level( _stat, _desired, _msg, 0 )
64
65#define fatal_directive_check_status_only( _stat, _desired, _msg ) \
66  do { \
67    if ( (_stat) != (_desired) ) { \
68      printf( "\n%s FAILED -- expected (%s) got (%s)\n", \
69              (_msg), rtems_status_text(_desired), rtems_status_text(_stat) ); \
70      fflush(stdout); \
71      exit( _stat ); \
72    } \
73  } while ( 0 )
74
75#define fatal_directive_status_with_level( _stat, _desired, _msg, _level ) \
76  do { \
77    check_dispatch_disable_level( _level ); \
78    fatal_directive_check_status_only( _stat, _desired, _msg ); \
79  } while ( 0 )
80
81/*
82 *  These macros properly report errors from the POSIX API
83 */
84
85#define posix_service_failed( _dirstat, _failmsg )  \
86 fatal_posix_service_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg )
87
88#define posix_service_failed_with_level( _dirstat, _failmsg, _level )  \
89 fatal_posix_service_status_with_level( \
90      _dirstat, RTEMS_SUCCESSFUL, _failmsg, _level )
91
92#define fatal_posix_service_status( _stat, _desired, _msg ) \
93  fatal_posix_service_status_with_level( _stat, _desired, _msg, 0 )
94
95#define fatal_posix_service_status_with_level( _stat, _desired, _msg, _level ) \
96  do { \
97    check_dispatch_disable_level( _level ); \
98    if ( (_stat) != (_desired) ) { \
99      printf( "\n%s FAILED -- expected (%d - %s) got (%d - %s)\n", \
100              (_msg), _desired, strerror(_desired), _stat, strerror(_stat) ); \
101      printf( "\n FAILED -- errno (%d - %s)\n", \
102              errno, strerror(errno) ); \
103      fflush(stdout); \
104      exit( _stat ); \
105    } \
106  } while ( 0 )
107
108/*
109 *  Generic integer version of the error reporting
110 */
111
112#define int_service_failed( _dirstat, _failmsg )  \
113 fatal_int_service_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg )
114
115#define int_service_failed_with_level( _dirstat, _failmsg, _level )  \
116 fatal_int_service_status_with_level( \
117      _dirstat, RTEMS_SUCCESSFUL, _failmsg, _level )
118
119#define fatal_int_service_status( _stat, _desired, _msg ) \
120  fatal_int_service_status_with_level( _stat, _desired, _msg, 0 )
121
122#define fatal_int_service_status_with_level( _stat, _desired, _msg, _level ) \
123  do { \
124    check_dispatch_disable_level( _level ); \
125    if ( (_stat) != (_desired) ) { \
126      printf( "\n%s FAILED -- expected (%d) got (%d)\n", \
127              (_msg), (_desired), (_stat) ); \
128      fflush(stdout); \
129      exit( _stat ); \
130    } \
131  } while ( 0 )
132
133
134/*
135 *  Print the time
136 */
137
138#define sprint_time(_str, _s1, _tb, _s2) \
139  do { \
140    sprintf( (str), "%s%02d:%02d:%02d   %02d/%02d/%04d%s", \
141       _s1, (_tb)->hour, (_tb)->minute, (_tb)->second, \
142       (_tb)->month, (_tb)->day, (_tb)->year, _s2 ); \
143  } while ( 0 )
144
145#define print_time(_s1, _tb, _s2) \
146  do { \
147    printf( "%s%02d:%02d:%02d   %02d/%02d/%04d%s", \
148       _s1, (_tb)->hour, (_tb)->minute, (_tb)->second, \
149       (_tb)->month, (_tb)->day, (_tb)->year, _s2 ); \
150    fflush(stdout); \
151  } while ( 0 )
152
153#define put_dot( _c ) \
154  do { \
155    putchar( _c ); \
156    fflush( stdout ); \
157  } while ( 0 )
158
159#define new_line  puts( "" )
160
161#define puts_nocr printf
162
163#ifdef RTEMS_TEST_NO_PAUSE
164#define rtems_test_pause() \
165    do { \
166      printf( "<pause>\n" ); fflush( stdout ); \
167  } while ( 0 )
168
169#define rtems_test_pause_and_screen_number( _screen ) \
170  do { \
171    printf( "<pause - screen %d>\n", (_screen) ); fflush( stdout ); \
172  } while ( 0 )
173#else
174#define rtems_test_pause() \
175  do { \
176    char buffer[ 80 ]; \
177    printf( "<pause>" ); fflush( stdout ); \
178    gets( buffer ); \
179    puts( "" ); \
180  } while ( 0 )
181
182#define rtems_test_pause_and_screen_number( _screen ) \
183  do { \
184    char buffer[ 80 ]; \
185    printf( "<pause - screen %d>", (_screen) ); fflush( stdout ); \
186    gets( buffer ); \
187    puts( "" ); \
188  } while ( 0 )
189#endif
190
191#define put_name( name, crlf ) \
192{ rtems_unsigned32 c0, c1, c2, c3; \
193  c0 = (name >> 24) & 0xff; \
194  c1 = (name >> 16) & 0xff; \
195  c2 = (name >> 8) & 0xff; \
196  c3 = name & 0xff; \
197  putchar( (char)c0 ); \
198  if ( c1 ) putchar( (char)c1 ); \
199  if ( c2 ) putchar( (char)c2 ); \
200  if ( c3 ) putchar( (char)c3 ); \
201  if ( crlf ) \
202    putchar( '\n' ); \
203}
204
205#ifndef build_time
206#define build_time( TB, MON, DAY, YR, HR, MIN, SEC, TK ) \
207  { (TB)->year   = YR;  \
208    (TB)->month  = MON; \
209    (TB)->day    = DAY; \
210    (TB)->hour   = HR;  \
211    (TB)->minute = MIN; \
212    (TB)->second = SEC; \
213    (TB)->ticks  = TK; }
214#endif
215
216#define task_number( tid ) \
217  ( rtems_get_index( tid ) - \
218     rtems_configuration_get_rtems_api_configuration()->number_of_initialization_tasks )
219
220static inline rtems_unsigned32 get_ticks_per_second( void )
221{
222  rtems_interval ticks_per_second;
223  (void) rtems_clock_get( RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_second );
224  return ticks_per_second;
225}
226
227#define TICKS_PER_SECOND get_ticks_per_second()
228
229#ifdef __cplusplus
230}
231#endif
232
233#endif
Note: See TracBrowser for help on using the repository browser.