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

Last change on this file since b3a6713 was b3a6713, checked in by Joel Sherrill <joel.sherrill@…>, on 08/16/01 at 21:36:15

2001-08-16 Joel Sherrill <joel@…>

  • src/mqueuesendsupp.c: Account for possibly blocking during the core send operation.

2001-08-16 Joel Sherrill <joel@…>

  • src/msgqsubmit.c: Add a comment indicating that we do not have to account for possibly blocking during the core send operation because Classic API message queue send is always non-blocking.

2001-08-16 Joel Sherrill <joel@…>

  • include/rtems/score/coremsg.h, src/coremsgsubmit.c: Add a new return status to account for blocking sends. Otherwise, the caller will think that the returned message status will have the ultimate results of the operation. If the send times out, the final status will be in the return_code of the thread.

2001-08-16 Joel Sherrill <joel@…>

  • src/coremutexsurrender.c: Use holder thread not executing thread because even though they may and often are the same it is not guaranteed unless the proper attribute is set.

2001-08-16 Joel Sherrill <joel@…>

  • startup/linkcmds: Modified to work better with gcc 2.8.1 and gnat 3.13p.

2001-08-16 Joel Sherrill <joel@…>

  • tools/runtest.in: Recognize debug variant of monitor test.

2001-08-16 Joel Sherrill <joel@…>

  • sp13/sp13.scn: Id in screen had wrong class field value.
  • sp13/system.h: Account for message buffer memory.
  • sp13/task2.c: Remove unnecessary check for failure.

2001-08-16 Joel Sherrill <joel@…>

  • sp20/system.h: Account for extra task stacks properly.

2001-08-16 Joel Sherrill <joel@…>

  • include/tmacros.h: Attempt to print errno as further information.
  • Property mode set to 100644
File size: 6.1 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 <string.h>
28#include <assert.h>
29#include <rtems/error.h>
30
31#define FOREVER 1                  /* infinite loop */
32
33#ifdef TEST_INIT
34#define TEST_EXTERN
35#define CONFIGURE_INIT
36#else
37#define TEST_EXTERN extern
38#endif
39
40#define check_dispatch_disable_level( _expect ) \
41  do { \
42    extern volatile rtems_unsigned32 _Thread_Dispatch_disable_level; \
43    if ( (_expect) != -1 && _Thread_Dispatch_disable_level != (_expect) ) { \
44      printf( "\n_Thread_Dispatch_disable_level is (%d) not %d\n", \
45              _Thread_Dispatch_disable_level, (_expect) ); \
46      fflush(stdout); \
47      exit( 1 ); \
48    } \
49  } while ( 0 )
50
51/*
52 *  These macros properly report errors within the Classic API
53 */
54
55#define directive_failed( _dirstat, _failmsg )  \
56 fatal_directive_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg )
57
58#define directive_failed_with_level( _dirstat, _failmsg, _level )  \
59 fatal_directive_status_with_level( \
60      _dirstat, RTEMS_SUCCESSFUL, _failmsg, _level )
61
62#define fatal_directive_status( _stat, _desired, _msg ) \
63  fatal_directive_status_with_level( _stat, _desired, _msg, 0 )
64
65#define fatal_directive_status_with_level( _stat, _desired, _msg, _level ) \
66  do { \
67    check_dispatch_disable_level( _level ); \
68    if ( (_stat) != (_desired) ) { \
69      printf( "\n%s FAILED -- expected (%s) got (%s)\n", \
70              (_msg), rtems_status_text(_desired), rtems_status_text(_stat) ); \
71      fflush(stdout); \
72      exit( _stat ); \
73    } \
74  } while ( 0 )
75
76/*
77 *  These macros properly report errors from the POSIX API
78 */
79
80#define posix_service_failed( _dirstat, _failmsg )  \
81 fatal_posix_service_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg )
82
83#define posix_service_failed_with_level( _dirstat, _failmsg, _level )  \
84 fatal_posix_service_status_with_level( \
85      _dirstat, RTEMS_SUCCESSFUL, _failmsg, _level )
86
87#define fatal_posix_service_status( _stat, _desired, _msg ) \
88  fatal_posix_service_status_with_level( _stat, _desired, _msg, 0 )
89
90#define fatal_posix_service_status_with_level( _stat, _desired, _msg, _level ) \
91  do { \
92    check_dispatch_disable_level( _level ); \
93    if ( (_stat) != (_desired) ) { \
94      printf( "\n%s FAILED -- expected (%d - %s) got (%d - %s)\n", \
95              (_msg), _desired, strerror(_desired), _stat, strerror(_stat) ); \
96      printf( "\n FAILED -- errno (%d - %s)\n", \
97              errno, strerror(errno) ); \
98      fflush(stdout); \
99      exit( _stat ); \
100    } \
101  } while ( 0 )
102
103/*
104 *  Generic integer version of the error reporting
105 */
106
107#define int_service_failed( _dirstat, _failmsg )  \
108 fatal_int_service_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg )
109
110#define int_service_failed_with_level( _dirstat, _failmsg, _level )  \
111 fatal_int_service_status_with_level( \
112      _dirstat, RTEMS_SUCCESSFUL, _failmsg, _level )
113
114#define fatal_int_service_status( _stat, _desired, _msg ) \
115  fatal_int_service_status_with_level( _stat, _desired, _msg, 0 )
116
117#define fatal_int_service_status_with_level( _stat, _desired, _msg, _level ) \
118  do { \
119    check_dispatch_disable_level( _level ); \
120    if ( (_stat) != (_desired) ) { \
121      printf( "\n%s FAILED -- expected (%d) got (%d)\n", \
122              (_msg), (_desired), (_stat) ); \
123      fflush(stdout); \
124      exit( _stat ); \
125    } \
126  } while ( 0 )
127
128
129/*
130 *  Print the time
131 */
132
133#define sprint_time(_str, _s1, _tb, _s2) \
134  do { \
135    sprintf( (str), "%s%02d:%02d:%02d   %02d/%02d/%04d%s", \
136       _s1, (_tb)->hour, (_tb)->minute, (_tb)->second, \
137       (_tb)->month, (_tb)->day, (_tb)->year, _s2 ); \
138  } while ( 0 )
139
140#define print_time(_s1, _tb, _s2) \
141  do { \
142    printf( "%s%02d:%02d:%02d   %02d/%02d/%04d%s", \
143       _s1, (_tb)->hour, (_tb)->minute, (_tb)->second, \
144       (_tb)->month, (_tb)->day, (_tb)->year, _s2 ); \
145    fflush(stdout); \
146  } while ( 0 )
147
148#define put_dot( _c ) \
149  do { \
150    putchar( _c ); \
151    fflush( stdout ); \
152  } while ( 0 )
153
154#define new_line  puts( "" )
155
156#define puts_nocr printf
157
158#ifdef RTEMS_TEST_NO_PAUSE
159#define rtems_test_pause() \
160    do { \
161      printf( "<pause>\n" ); fflush( stdout ); \
162  } while ( 0 )
163
164#define rtems_test_pause_and_screen_number( _screen ) \
165  do { \
166    printf( "<pause - screen %d>\n", (_screen) ); fflush( stdout ); \
167  } while ( 0 )
168#else
169#define rtems_test_pause() \
170  do { \
171    char buffer[ 80 ]; \
172    printf( "<pause>" ); fflush( stdout ); \
173    gets( buffer ); \
174    puts( "" ); \
175  } while ( 0 )
176
177#define rtems_test_pause_and_screen_number( _screen ) \
178  do { \
179    char buffer[ 80 ]; \
180    printf( "<pause - screen %d>", (_screen) ); fflush( stdout ); \
181    gets( buffer ); \
182    puts( "" ); \
183  } while ( 0 )
184#endif
185
186#define put_name( name, crlf ) \
187{ rtems_unsigned32 c0, c1, c2, c3; \
188  c0 = (name >> 24) & 0xff; \
189  c1 = (name >> 16) & 0xff; \
190  c2 = (name >> 8) & 0xff; \
191  c3 = name & 0xff; \
192  putchar( (char)c0 ); \
193  if ( c1 ) putchar( (char)c1 ); \
194  if ( c2 ) putchar( (char)c2 ); \
195  if ( c3 ) putchar( (char)c3 ); \
196  if ( crlf ) \
197    putchar( '\n' ); \
198}
199
200#ifndef build_time
201#define build_time( TB, MON, DAY, YR, HR, MIN, SEC, TK ) \
202  { (TB)->year   = YR;  \
203    (TB)->month  = MON; \
204    (TB)->day    = DAY; \
205    (TB)->hour   = HR;  \
206    (TB)->minute = MIN; \
207    (TB)->second = SEC; \
208    (TB)->ticks  = TK; }
209#endif
210
211#define task_number( tid ) \
212  ( rtems_get_index( tid ) - \
213     rtems_configuration_get_rtems_api_configuration()->number_of_initialization_tasks )
214
215static inline rtems_unsigned32 get_ticks_per_second( void )
216{
217  rtems_interval ticks_per_second;
218  (void) rtems_clock_get( RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_second );
219  return ticks_per_second;
220}
221
222#define TICKS_PER_SECOND get_ticks_per_second()
223
224#ifdef __cplusplus
225}
226#endif
227
228#endif
Note: See TracBrowser for help on using the repository browser.