source: rtems/c/src/tests/support/include/tmacros.h @ 08311cc3

4.104.114.84.95
Last change on this file since 08311cc3 was 08311cc3, checked in by Joel Sherrill <joel.sherrill@…>, on Nov 17, 1999 at 5:51:34 PM

Updated copyright notice.

  • Property mode set to 100644
File size: 4.1 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 <assert.h>
28
29#define FOREVER 1                  /* infinite loop */
30
31#ifdef TEST_INIT
32#define TEST_EXTERN
33#define CONFIGURE_INIT
34#else
35#define TEST_EXTERN extern
36#endif
37
38#define check_dispatch_disable_level( _expect ) \
39  do { \
40    extern volatile rtems_unsigned32 _Thread_Dispatch_disable_level; \
41    if ( (_expect) != -1 && _Thread_Dispatch_disable_level != (_expect) ) { \
42      printf( "\n_Thread_Dispatch_disable_level is (%d) not %d\n", \
43              _Thread_Dispatch_disable_level, (_expect) ); \
44      fflush(stdout); \
45      exit( 1 ); \
46    } \
47  } while ( 0 )
48
49#define directive_failed( _dirstat, _failmsg )  \
50 fatal_directive_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg )
51
52#define directive_failed_with_level( _dirstat, _failmsg, _level )  \
53 fatal_directive_status_with_level( \
54      _dirstat, RTEMS_SUCCESSFUL, _failmsg, _level )
55
56#define fatal_directive_status( _stat, _desired, _msg ) \
57  fatal_directive_status_with_level( _stat, _desired, _msg, 0 )
58
59#define fatal_directive_status_with_level( _stat, _desired, _msg, _level ) \
60  do { \
61    check_dispatch_disable_level( _level ); \
62    if ( (_stat) != (_desired) ) { \
63      printf( "\n%s FAILED -- expected (%d) got (%d)\n", \
64              (_msg), (_desired), (_stat) ); \
65      fflush(stdout); \
66      exit( _stat ); \
67    } \
68  } while ( 0 )
69
70#define sprint_time(_str, _s1, _tb, _s2) \
71  do { \
72    sprintf( (str), "%s%02d:%02d:%02d   %02d/%02d/%04d%s", \
73       _s1, (_tb)->hour, (_tb)->minute, (_tb)->second, \
74       (_tb)->month, (_tb)->day, (_tb)->year, _s2 ); \
75  } while ( 0 )
76
77#define print_time(_s1, _tb, _s2) \
78  do { \
79    printf( "%s%02d:%02d:%02d   %02d/%02d/%04d%s", \
80       _s1, (_tb)->hour, (_tb)->minute, (_tb)->second, \
81       (_tb)->month, (_tb)->day, (_tb)->year, _s2 ); \
82    fflush(stdout); \
83  } while ( 0 )
84
85#define put_dot( _c ) \
86  do { \
87    putchar( _c ); \
88    fflush( stdout ); \
89  } while ( 0 )
90
91#define new_line  puts( "" )
92
93#define puts_nocr printf
94
95#ifdef RTEMS_TEST_NO_PAUSE
96#define rtems_test_pause() \
97    do { \
98      printf( "<pause>\n" ); fflush( stdout ); \
99  } while ( 0 )
100
101#define rtems_test_pause_and_screen_number( _screen ) \
102  do { \
103    printf( "<pause - screen %d>\n", (_screen) ); fflush( stdout ); \
104  } while ( 0 )
105#else
106#define rtems_test_pause() \
107  do { \
108    char buffer[ 80 ]; \
109    printf( "<pause>" ); fflush( stdout ); \
110    gets( buffer ); \
111    puts( "" ); \
112  } while ( 0 )
113
114#define rtems_test_pause_and_screen_number( _screen ) \
115  do { \
116    char buffer[ 80 ]; \
117    printf( "<pause - screen %d>", (_screen) ); fflush( stdout ); \
118    gets( buffer ); \
119    puts( "" ); \
120  } while ( 0 )
121#endif
122
123#define put_name( name, crlf ) \
124{ rtems_unsigned32 c0, c1, c2, c3; \
125  c0 = (name >> 24) & 0xff; \
126  c1 = (name >> 16) & 0xff; \
127  c2 = (name >> 8) & 0xff; \
128  c3 = name & 0xff; \
129  putchar( (char)c0 ); \
130  if ( c1 ) putchar( (char)c1 ); \
131  if ( c2 ) putchar( (char)c2 ); \
132  if ( c3 ) putchar( (char)c3 ); \
133  if ( crlf ) \
134    putchar( '\n' ); \
135}
136
137#define build_time( TB, MON, DAY, YR, HR, MIN, SEC, TK ) \
138  { (TB)->year   = YR;  \
139    (TB)->month  = MON; \
140    (TB)->day    = DAY; \
141    (TB)->hour   = HR;  \
142    (TB)->minute = MIN; \
143    (TB)->second = SEC; \
144    (TB)->ticks  = TK; }
145
146#define task_number( tid ) \
147  ( rtems_get_index( tid ) - \
148     rtems_configuration_get_rtems_api_configuration()->number_of_initialization_tasks )
149
150static inline rtems_unsigned32 get_ticks_per_second( void )
151{
152  rtems_interval ticks_per_second;
153  (void) rtems_clock_get( RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_second );
154  return ticks_per_second;
155}
156
157#define TICKS_PER_SECOND get_ticks_per_second()
158
159#ifdef __cplusplus
160}
161#endif
162
163#endif
Note: See TracBrowser for help on using the repository browser.