[ac7d5ef0] | 1 | /* tmacros.h |
---|
| 2 | * |
---|
| 3 | * This include file contains macros which are useful in the RTEMS |
---|
| 4 | * test suites. |
---|
| 5 | * |
---|
[08311cc3] | 6 | * COPYRIGHT (c) 1989-1999. |
---|
[ac7d5ef0] | 7 | * On-Line Applications Research Corporation (OAR). |
---|
| 8 | * |
---|
[98e4ebf5] | 9 | * The license and distribution terms for this file may be |
---|
| 10 | * found in the file LICENSE in this distribution or at |
---|
[03f2154e] | 11 | * http://www.OARcorp.com/rtems/license.html. |
---|
[ac7d5ef0] | 12 | * |
---|
[3235ad9] | 13 | * $Id$ |
---|
[ac7d5ef0] | 14 | */ |
---|
| 15 | |
---|
| 16 | #ifndef __TMACROS_h |
---|
| 17 | #define __TMACROS_h |
---|
| 18 | |
---|
| 19 | #ifdef __cplusplus |
---|
| 20 | extern "C" { |
---|
| 21 | #endif |
---|
| 22 | |
---|
[c64e4ed4] | 23 | #include <bsp.h> /* includes <rtems.h> */ |
---|
[8d47a15] | 24 | |
---|
| 25 | #include <stdio.h> |
---|
| 26 | #include <stdlib.h> |
---|
[4b960e5] | 27 | #include <assert.h> |
---|
[ac7d5ef0] | 28 | |
---|
| 29 | #define FOREVER 1 /* infinite loop */ |
---|
| 30 | |
---|
[3a4ae6c] | 31 | #ifdef TEST_INIT |
---|
| 32 | #define TEST_EXTERN |
---|
| 33 | #define CONFIGURE_INIT |
---|
| 34 | #else |
---|
| 35 | #define TEST_EXTERN extern |
---|
| 36 | #endif |
---|
| 37 | |
---|
[4b960e5] | 38 | #define check_dispatch_disable_level( _expect ) \ |
---|
| 39 | do { \ |
---|
| 40 | extern volatile rtems_unsigned32 _Thread_Dispatch_disable_level; \ |
---|
[96c2db6] | 41 | if ( (_expect) != -1 && _Thread_Dispatch_disable_level != (_expect) ) { \ |
---|
[4b960e5] | 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) \ |
---|
[c64e4ed4] | 71 | do { \ |
---|
[ac7d5ef0] | 72 | sprintf( (str), "%s%02d:%02d:%02d %02d/%02d/%04d%s", \ |
---|
[4b960e5] | 73 | _s1, (_tb)->hour, (_tb)->minute, (_tb)->second, \ |
---|
| 74 | (_tb)->month, (_tb)->day, (_tb)->year, _s2 ); \ |
---|
[c64e4ed4] | 75 | } while ( 0 ) |
---|
[ac7d5ef0] | 76 | |
---|
[4b960e5] | 77 | #define print_time(_s1, _tb, _s2) \ |
---|
[c64e4ed4] | 78 | do { \ |
---|
[ac7d5ef0] | 79 | printf( "%s%02d:%02d:%02d %02d/%02d/%04d%s", \ |
---|
[4b960e5] | 80 | _s1, (_tb)->hour, (_tb)->minute, (_tb)->second, \ |
---|
| 81 | (_tb)->month, (_tb)->day, (_tb)->year, _s2 ); \ |
---|
[c64e4ed4] | 82 | fflush(stdout); \ |
---|
| 83 | } while ( 0 ) |
---|
[ac7d5ef0] | 84 | |
---|
[4b960e5] | 85 | #define put_dot( _c ) \ |
---|
| 86 | do { \ |
---|
| 87 | putchar( _c ); \ |
---|
| 88 | fflush( stdout ); \ |
---|
| 89 | } while ( 0 ) |
---|
[ac7d5ef0] | 90 | |
---|
| 91 | #define new_line puts( "" ) |
---|
| 92 | |
---|
| 93 | #define puts_nocr printf |
---|
| 94 | |
---|
[2a3d1fd] | 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 |
---|
[ba39113] | 106 | #define rtems_test_pause() \ |
---|
[ac7d5ef0] | 107 | do { \ |
---|
| 108 | char buffer[ 80 ]; \ |
---|
[8d47a15] | 109 | printf( "<pause>" ); fflush( stdout ); \ |
---|
[ac7d5ef0] | 110 | gets( buffer ); \ |
---|
| 111 | puts( "" ); \ |
---|
| 112 | } while ( 0 ) |
---|
| 113 | |
---|
[ba39113] | 114 | #define rtems_test_pause_and_screen_number( _screen ) \ |
---|
[ac7d5ef0] | 115 | do { \ |
---|
| 116 | char buffer[ 80 ]; \ |
---|
[4b374f36] | 117 | printf( "<pause - screen %d>", (_screen) ); fflush( stdout ); \ |
---|
[ac7d5ef0] | 118 | gets( buffer ); \ |
---|
| 119 | puts( "" ); \ |
---|
| 120 | } while ( 0 ) |
---|
[2a3d1fd] | 121 | #endif |
---|
[ac7d5ef0] | 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 | |
---|
[b8cda5a6] | 137 | #ifndef build_time |
---|
[ac7d5ef0] | 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; } |
---|
[b8cda5a6] | 146 | #endif |
---|
[ac7d5ef0] | 147 | |
---|
| 148 | #define task_number( tid ) \ |
---|
[e6d4b1d] | 149 | ( rtems_get_index( tid ) - \ |
---|
[458bd34] | 150 | rtems_configuration_get_rtems_api_configuration()->number_of_initialization_tasks ) |
---|
[ac7d5ef0] | 151 | |
---|
| 152 | static inline rtems_unsigned32 get_ticks_per_second( void ) |
---|
| 153 | { |
---|
| 154 | rtems_interval ticks_per_second; |
---|
| 155 | (void) rtems_clock_get( RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_second ); |
---|
| 156 | return ticks_per_second; |
---|
| 157 | } |
---|
| 158 | |
---|
| 159 | #define TICKS_PER_SECOND get_ticks_per_second() |
---|
| 160 | |
---|
| 161 | #ifdef __cplusplus |
---|
| 162 | } |
---|
| 163 | #endif |
---|
| 164 | |
---|
| 165 | #endif |
---|