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

4.104.114.84.95
Last change on this file since f388d36 was f388d36, checked in by Joel Sherrill <joel.sherrill@…>, on Jan 5, 2000 at 6:17:01 PM

Now print strings -- not error numbers.

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