diff options
Diffstat (limited to 'testmacros.h')
-rw-r--r-- | testmacros.h | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/testmacros.h b/testmacros.h new file mode 100644 index 0000000..fe0f044 --- /dev/null +++ b/testmacros.h @@ -0,0 +1,81 @@ +/* testmacros.h + * + * This include file contains some commonly used test macros. + * + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef __TEST_MACROS_h +#define __TEST_MACROS_h + +/* + * Handy macros and static inline functions + */ + +/* + * Macro to hide the ugliness of printing the time. + */ + +#define print_time(_s1, _tb, _s2) \ + do { \ + printf( "%s%02d:%02d:%02d %02d/%02d/%04d%s", \ + _s1, (int) (_tb)->hour, (int) (_tb)->minute, (int) (_tb)->second, \ + (int) (_tb)->month, (int) (_tb)->day, (int) (_tb)->year, _s2 ); \ + fflush(stdout); \ + } while ( 0 ) + +/* + * Macro to print an task name that is composed of ASCII characters. + * + */ + +#define put_name( _name, _crlf ) \ + do { \ + uint32_t c0, c1, c2, c3; \ + \ + c0 = ((_name) >> 24) & 0xff; \ + c1 = ((_name) >> 16) & 0xff; \ + c2 = ((_name) >> 8) & 0xff; \ + c3 = (_name) & 0xff; \ + putchar( (char)c0 ); \ + if ( c1 ) putchar( (char)c1 ); \ + if ( c2 ) putchar( (char)c2 ); \ + if ( c3 ) putchar( (char)c3 ); \ + if ( (_crlf) ) \ + putchar( '\n' ); \ + } while (0) + +/* + * static inline routine to make obtaining ticks per second easier. + */ + +static inline uint32_t get_ticks_per_second( void ) +{ + rtems_interval ticks_per_second; + (void) rtems_clock_get( RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_second ); return ticks_per_second; +} + + +/* + * This allows us to view the "Test_task" instantiations as a set + * of numbered tasks by eliminating the number of application + * tasks created. + * + * In reality, this is too complex for the purposes of this + * example. It would have been easier to pass a task argument. :) + * But it shows how rtems_id's can sometimes be used. + */ + +#define task_number( tid ) \ + ( rtems_object_id_get_index( tid ) - \ + rtems_configuration_get_rtems_api_configuration()->number_of_initialization_tasks ) + +#endif +/* end of include file */ |