source: rtems/c/src/tests/support/include/tmacros.h @ 4b960e5

4.104.114.84.95
Last change on this file since 4b960e5 was 4b960e5, checked in by Joel Sherrill <joel.sherrill@…>, on 11/16/99 at 16:21:00

Added code to the macros which checked directive status to also
check that the _Thread_Dispatch_disable_level is set to the
proper value (0 99% of the time). This automatic check significantly
reduces the chance of mismatching disable/enable dispatch pairs
while doing internal RTEMS work.

  • 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-1998.
7 *  On-Line Applications Research Corporation (OAR).
8 *  Copyright assigned to U.S. Government, 1994.
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.OARcorp.com/rtems/license.html.
13 *
14 *  $Id$
15 */
16
17#ifndef __TMACROS_h
18#define __TMACROS_h
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#include <bsp.h>    /* includes <rtems.h> */
25
26#include <stdio.h>
27#include <stdlib.h>
28#include <assert.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 ( _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 (%d) got (%d)\n", \
65              (_msg), (_desired), (_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#define build_time( TB, MON, DAY, YR, HR, MIN, SEC, TK ) \
139  { (TB)->year   = YR;  \
140    (TB)->month  = MON; \
141    (TB)->day    = DAY; \
142    (TB)->hour   = HR;  \
143    (TB)->minute = MIN; \
144    (TB)->second = SEC; \
145    (TB)->ticks  = TK; }
146
147#define task_number( tid ) \
148  ( rtems_get_index( tid ) - \
149     rtems_configuration_get_rtems_api_configuration()->number_of_initialization_tasks )
150
151static inline rtems_unsigned32 get_ticks_per_second( void )
152{
153  rtems_interval ticks_per_second;
154  (void) rtems_clock_get( RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_second );
155  return ticks_per_second;
156}
157
158#define TICKS_PER_SECOND get_ticks_per_second()
159
160#ifdef __cplusplus
161}
162#endif
163
164#endif
Note: See TracBrowser for help on using the repository browser.