source: rtems/testsuites/support/include/buffer_test_io.h @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 3.7 KB
Line 
1/*
2 *  Support for running the test output through a buffer
3 */
4
5#ifndef __BUFFER_TEST_IO_h
6#define __BUFFER_TEST_IO_h
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12/*
13 *  Uncomment this to get buffered test output.  When commented out,
14 *  test output behaves as it always has and is printed using stdio.
15 */
16
17/* #define TESTS_BUFFER_OUTPUT */
18#if defined(__AVR__)
19#define TESTS_USE_PRINTK
20#endif
21
22/*
23 *  USE PRINTK TO MINIMIZE SIZE
24 */
25#if defined(TESTS_USE_PRINTK)
26
27#include <rtems/bspIo.h>
28
29  #undef printf
30  #define printf(...) \
31    do { \
32       printk( __VA_ARGS__); \
33    } while (0)
34
35  #undef puts
36  #define puts(_s) \
37    do { \
38       printk( "%s\n", _s); \
39    } while (0)
40
41  #undef putchar
42  #define putchar(_c) \
43    do { \
44       printk( "%c", _c ); \
45    } while (0)
46
47  /* Do not call exit() since it closes stdin, etc and pulls in stdio code */
48  #define rtems_test_exit(_s) \
49    do { \
50      rtems_shutdown_executive(0); \
51    } while (0)
52
53  #define FLUSH_OUTPUT() \
54    do { \
55    } while (0)
56
57/*
58 *  BUFFER TEST OUTPUT
59 */
60#elif defined(TESTS_BUFFER_OUTPUT)
61
62  #include <stdio.h>
63  #include <stdlib.h>
64
65  #define _TEST_OUTPUT_BUFFER_SIZE 2048
66  extern char _test_output_buffer[_TEST_OUTPUT_BUFFER_SIZE];
67  void _test_output_append(char *);
68  void _test_output_flush(void);
69
70  #define rtems_test_exit(_s) \
71    do { \
72      _test_output_flush(); \
73      exit(_s); \
74    } while (0)
75
76  #undef printf
77  #define printf(...) \
78    do { \
79       char _buffer[128]; \
80       sprintf( _buffer, __VA_ARGS__); \
81       _test_output_append( _buffer ); \
82    } while (0)
83
84  #undef puts
85  #define puts(_string) \
86    do { \
87       char _buffer[128]; \
88       sprintf( _buffer, "%s\n", _string ); \
89       _test_output_append( _buffer ); \
90    } while (0)
91
92  #undef putchar
93  #define putchar(_c) \
94    do { \
95       char _buffer[2]; \
96       _buffer[0] = _c; \
97       _buffer[1] = '\0'; \
98       _test_output_append( _buffer ); \
99    } while (0)
100
101  /* we write to stderr when there is a pause() */
102  #define FLUSH_OUTPUT() _test_output_flush()
103
104  #if defined(TEST_INIT) || defined(CONFIGURE_INIT)
105
106    char _test_output_buffer[_TEST_OUTPUT_BUFFER_SIZE];
107    int _test_output_buffer_index = 0;
108
109    void _test_output_append(char *_buffer)
110    {
111      char *p;
112
113      for ( p=_buffer ; *p ; p++ ) {
114        _test_output_buffer[_test_output_buffer_index++] = *p;
115        _test_output_buffer[_test_output_buffer_index]   = '\0';
116        #if 0
117          if ( *p == '\n' ) {
118            fprintf( stderr, "BUFFER -- %s", _test_output_buffer );
119            _test_output_buffer_index = 0;
120           _test_output_buffer[0]   = '\0';
121          }
122        #endif
123        if ( _test_output_buffer_index >= (_TEST_OUTPUT_BUFFER_SIZE - 80) )
124          _test_output_flush();
125      }
126    }
127
128    #include <termios.h>
129    #include <unistd.h>
130
131    void _test_output_flush(void)
132    {
133      fprintf( stderr, "%s", _test_output_buffer );
134      _test_output_buffer_index = 0;
135      tcdrain( 2 );
136    }
137
138    #endif
139/*
140 *  USE IPRINT
141 */
142#else
143
144  #include <stdio.h>
145  #include <stdlib.h>
146
147  /* do not use iprintf if strict ansi mode */
148  #if defined(_NEWLIB_VERSION) && !defined(__STRICT_ANSI__)
149    #undef printf
150    #define printf(...) \
151      do { \
152         fiprintf( stderr, __VA_ARGS__ ); \
153      } while (0)
154  #else
155    #undef printf
156    #define printf(...) \
157      do { \
158         fprintf( stderr, __VA_ARGS__ ); \
159      } while (0)
160  #endif
161
162  #undef puts
163  #define puts(_s) \
164      do { \
165         printf( "%s\n", _s ); \
166      } while (0)
167
168  #undef putchar
169  #define putchar(_c) \
170    do { \
171       printf( "%c", _c ); \
172    } while (0)
173
174  #define rtems_test_exit(_s) \
175    do { \
176      exit(_s); \
177    } while (0)
178
179  #define FLUSH_OUTPUT() \
180    do { \
181      fflush(stdout); \
182    } while (0)
183
184#endif
185
186#ifdef __cplusplus
187};
188#endif
189
190#endif
Note: See TracBrowser for help on using the repository browser.