[ac7d5ef0] | 1 | /* tmacros.h |
---|
| 2 | * |
---|
| 3 | * This include file contains macros which are useful in the RTEMS |
---|
| 4 | * test suites. |
---|
| 5 | * |
---|
| 6 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
| 7 | * On-Line Applications Research Corporation (OAR). |
---|
| 8 | * All rights assigned to U.S. Government, 1994. |
---|
| 9 | * |
---|
| 10 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
| 11 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
| 12 | * notice must appear in all copies of this file and its derivatives. |
---|
| 13 | * |
---|
[3235ad9] | 14 | * $Id$ |
---|
[ac7d5ef0] | 15 | */ |
---|
| 16 | |
---|
| 17 | #ifndef __TMACROS_h |
---|
| 18 | #define __TMACROS_h |
---|
| 19 | |
---|
| 20 | #ifdef __cplusplus |
---|
| 21 | extern "C" { |
---|
| 22 | #endif |
---|
| 23 | |
---|
[c64e4ed4] | 24 | #include <bsp.h> /* includes <rtems.h> */ |
---|
[8d47a15] | 25 | |
---|
| 26 | #include <stdio.h> |
---|
| 27 | #include <stdlib.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 | |
---|
[ac7d5ef0] | 38 | #define directive_failed( dirstat, failmsg ) \ |
---|
| 39 | fatal_directive_status( dirstat, RTEMS_SUCCESSFUL, failmsg ) |
---|
| 40 | |
---|
| 41 | #define fatal_directive_status( stat, desired, msg ) \ |
---|
[c64e4ed4] | 42 | do { \ |
---|
[ac7d5ef0] | 43 | if ( (stat) != (desired) ) { \ |
---|
| 44 | printf( "\n%s FAILED -- expected (%d) got (%d)\n", \ |
---|
| 45 | (msg), (desired), (stat) ); \ |
---|
[c64e4ed4] | 46 | fflush(stdout); \ |
---|
[ac7d5ef0] | 47 | exit( stat ); \ |
---|
| 48 | } \ |
---|
[c64e4ed4] | 49 | } while ( 0 ) |
---|
[ac7d5ef0] | 50 | |
---|
| 51 | #define sprint_time(str,s1,tb,s2) \ |
---|
[c64e4ed4] | 52 | do { \ |
---|
[ac7d5ef0] | 53 | sprintf( (str), "%s%02d:%02d:%02d %02d/%02d/%04d%s", \ |
---|
| 54 | s1, (tb)->hour, (tb)->minute, (tb)->second, \ |
---|
[c64e4ed4] | 55 | (tb)->month, (tb)->day, (tb)->year, s2 ); \ |
---|
| 56 | } while ( 0 ) |
---|
[ac7d5ef0] | 57 | |
---|
| 58 | #define print_time(s1,tb,s2) \ |
---|
[c64e4ed4] | 59 | do { \ |
---|
[ac7d5ef0] | 60 | printf( "%s%02d:%02d:%02d %02d/%02d/%04d%s", \ |
---|
| 61 | s1, (tb)->hour, (tb)->minute, (tb)->second, \ |
---|
[c64e4ed4] | 62 | (tb)->month, (tb)->day, (tb)->year, s2 ); \ |
---|
| 63 | fflush(stdout); \ |
---|
| 64 | } while ( 0 ) |
---|
[ac7d5ef0] | 65 | |
---|
| 66 | #define put_dot( c ) putchar( c ); fflush( stdout ) |
---|
| 67 | |
---|
| 68 | #define new_line puts( "" ) |
---|
| 69 | |
---|
| 70 | #define puts_nocr printf |
---|
| 71 | |
---|
[ba39113] | 72 | #define rtems_test_pause() \ |
---|
[ac7d5ef0] | 73 | do { \ |
---|
| 74 | char buffer[ 80 ]; \ |
---|
[8d47a15] | 75 | printf( "<pause>" ); fflush( stdout ); \ |
---|
[ac7d5ef0] | 76 | gets( buffer ); \ |
---|
| 77 | puts( "" ); \ |
---|
| 78 | } while ( 0 ) |
---|
| 79 | |
---|
[ba39113] | 80 | #define rtems_test_pause_and_screen_number( _screen ) \ |
---|
[ac7d5ef0] | 81 | do { \ |
---|
| 82 | char buffer[ 80 ]; \ |
---|
[4b374f36] | 83 | printf( "<pause - screen %d>", (_screen) ); fflush( stdout ); \ |
---|
[ac7d5ef0] | 84 | gets( buffer ); \ |
---|
| 85 | puts( "" ); \ |
---|
| 86 | } while ( 0 ) |
---|
| 87 | |
---|
| 88 | #define put_name( name, crlf ) \ |
---|
| 89 | { rtems_unsigned32 c0, c1, c2, c3; \ |
---|
| 90 | c0 = (name >> 24) & 0xff; \ |
---|
| 91 | c1 = (name >> 16) & 0xff; \ |
---|
| 92 | c2 = (name >> 8) & 0xff; \ |
---|
| 93 | c3 = name & 0xff; \ |
---|
| 94 | putchar( (char)c0 ); \ |
---|
| 95 | if ( c1 ) putchar( (char)c1 ); \ |
---|
| 96 | if ( c2 ) putchar( (char)c2 ); \ |
---|
| 97 | if ( c3 ) putchar( (char)c3 ); \ |
---|
| 98 | if ( crlf ) \ |
---|
| 99 | putchar( '\n' ); \ |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | #define build_time( TB, MON, DAY, YR, HR, MIN, SEC, TK ) \ |
---|
| 103 | { (TB)->year = YR; \ |
---|
| 104 | (TB)->month = MON; \ |
---|
| 105 | (TB)->day = DAY; \ |
---|
| 106 | (TB)->hour = HR; \ |
---|
| 107 | (TB)->minute = MIN; \ |
---|
| 108 | (TB)->second = SEC; \ |
---|
| 109 | (TB)->ticks = TK; } |
---|
| 110 | |
---|
| 111 | #define task_number( tid ) \ |
---|
[e6d4b1d] | 112 | ( rtems_get_index( tid ) - \ |
---|
| 113 | BSP_Configuration.RTEMS_api_configuration->number_of_initialization_tasks ) |
---|
[ac7d5ef0] | 114 | |
---|
| 115 | static inline rtems_unsigned32 get_ticks_per_second( void ) |
---|
| 116 | { |
---|
| 117 | rtems_interval ticks_per_second; |
---|
| 118 | (void) rtems_clock_get( RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_second ); |
---|
| 119 | return ticks_per_second; |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | #define TICKS_PER_SECOND get_ticks_per_second() |
---|
| 123 | |
---|
| 124 | #ifdef __cplusplus |
---|
| 125 | } |
---|
| 126 | #endif |
---|
| 127 | |
---|
| 128 | #endif |
---|