source: rtems/testsuites/support/include/buffer_test_io.h @ 258bda3

5
Last change on this file since 258bda3 was 258bda3, checked in by Chris Johns <chrisj@…>, on 04/03/17 at 22:11:24

testsuite: Add a common test configuration. Fix configure.ac and Makefile.am errors.

  • Add a top level test configuration file for test states that are common to all BSPs. This saves adding a test configuration (tcfg) file for every BSP.
  • Add the test states 'user-input' and 'benchmark'. This lets 'rtems-test' stop the test rather than waiting for a timeout or letting a benchmark run without the user asking for it to run.
  • Implement rtems-test-check in Python to make it faster. The shell script had grown to a point it was noticably slowing the build down.
  • Fix the configure.ac and Makefile.am files for a number of the test directories. The files are difficiult to keep in sync with the number of tests and mistakes can happen such as tests being left out of the build. The test fsrofs01 is an example. Also a there was a mix of SUBDIRS and _SUBDIRS being used and only _SUBDIRS should be used.
  • Fix the test fsrofs01 so it compiles.

Closes #2963.

  • Property mode set to 100644
File size: 5.5 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#include <rtems/bspIo.h>
9#include <rtems/test.h>
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15/*
16 *  Uncomment this to get buffered test output.  When commented out,
17 *  test output behaves as it always has and is printed using stdio.
18 */
19
20/* #define TESTS_BUFFER_OUTPUT */
21/* #define TESTS_USE_PRINTK */
22
23/*
24 * Test states. No state string is an expected pass.
25 */
26#if (TEST_STATE_EXPECTED_FAIL && TEST_STATE_USER_INPUT) || \
27    (TEST_STATE_EXPECTED_FAIL && TEST_STATE_INDETERMINATE) || \
28    (TEST_STATE_EXPECTED_FAIL && TEST_STATE_BENCHMARK) || \
29    (TEST_STATE_USER_INPUT    && TEST_STATE_INDETERMINATE) || \
30    (TEST_STATE_USER_INPUT    && TEST_STATE_BENCHMARK) || \
31    (TEST_STATE_INDETERMINATE && TEST_STATE_BENCHMARK)
32  #error Test states must be unique
33#endif
34
35#if TEST_STATE_EXPECTED_FAIL
36  #define TEST_STATE_STRING "*** TEST STATE: EXPECTED-FAIL\n"
37#elif TEST_STATE_USER_INPUT
38  #define TEST_STATE_STRING "*** TEST STATE: USER_INPUT\n"
39#elif TEST_STATE_INDETERMINATE
40  #define TEST_STATE_STRING "*** TEST STATE: INDETERMINATE\n"
41#elif TEST_STATE_BENCHMARK
42  #define TEST_STATE_STRING "*** TEST STATE: BENCHMARK\n"
43#endif
44
45/*
46 *  USE PRINTK TO MINIMIZE SIZE
47 */
48#if defined(TESTS_USE_PRINTK)
49
50#include <rtems/print.h>
51
52  #undef printf
53  #define printf(...) \
54    do { \
55       printk( __VA_ARGS__); \
56    } while (0)
57
58  #undef puts
59  #define puts(_s) \
60    do { \
61       printk( "%s\n", _s); \
62    } while (0)
63
64  #undef putchar
65  #define putchar(_c) \
66    do { \
67       printk( "%c", _c ); \
68    } while (0)
69
70  /* Do not call exit() since it closes stdin, etc and pulls in stdio code */
71  #define rtems_test_exit(_s) \
72    do { \
73      rtems_shutdown_executive(0); \
74    } while (0)
75
76  #define FLUSH_OUTPUT() \
77    do { \
78    } while (0)
79
80  #if defined(TEST_STATE_STRING)
81    #define TEST_BEGIN() printk(TEST_BEGIN_STRING); printk(TEST_STATE_STRING);
82  #else
83    #define TEST_BEGIN() printk(TEST_BEGIN_STRING)
84  #endif
85
86  #define TEST_END() printk(TEST_END_STRING)
87
88/*
89 *  BUFFER TEST OUTPUT
90 */
91#elif defined(TESTS_BUFFER_OUTPUT)
92
93  #include <stdio.h>
94  #include <stdlib.h>
95
96  #define _TEST_OUTPUT_BUFFER_SIZE 2048
97  extern char _test_output_buffer[_TEST_OUTPUT_BUFFER_SIZE];
98  void _test_output_append(char *);
99  void _test_output_flush(void);
100
101  #define rtems_test_exit(_s) \
102    do { \
103      _test_output_flush(); \
104      exit(_s); \
105    } while (0)
106
107  #undef printf
108  #define printf(...) \
109    do { \
110       char _buffer[128]; \
111       sprintf( _buffer, __VA_ARGS__); \
112       _test_output_append( _buffer ); \
113    } while (0)
114
115  #undef puts
116  #define puts(_string) \
117    do { \
118       char _buffer[128]; \
119       sprintf( _buffer, "%s\n", _string ); \
120       _test_output_append( _buffer ); \
121    } while (0)
122
123  #undef putchar
124  #define putchar(_c) \
125    do { \
126       char _buffer[2]; \
127       _buffer[0] = _c; \
128       _buffer[1] = '\0'; \
129       _test_output_append( _buffer ); \
130    } while (0)
131
132  /* we write to stderr when there is a pause() */
133  #define FLUSH_OUTPUT() _test_output_flush()
134
135  #if defined(TEST_INIT) || defined(CONFIGURE_INIT)
136
137    char _test_output_buffer[_TEST_OUTPUT_BUFFER_SIZE];
138    int _test_output_buffer_index = 0;
139
140    void _test_output_append(char *_buffer)
141    {
142      char *p;
143
144      for ( p=_buffer ; *p ; p++ ) {
145        _test_output_buffer[_test_output_buffer_index++] = *p;
146        _test_output_buffer[_test_output_buffer_index]   = '\0';
147        #if 0
148          if ( *p == '\n' ) {
149            fprintf( stderr, "BUFFER -- %s", _test_output_buffer );
150            _test_output_buffer_index = 0;
151           _test_output_buffer[0]   = '\0';
152          }
153        #endif
154        if ( _test_output_buffer_index >= (_TEST_OUTPUT_BUFFER_SIZE - 80) )
155          _test_output_flush();
156      }
157    }
158
159    #include <termios.h>
160    #include <unistd.h>
161
162    void _test_output_flush(void)
163    {
164      fprintf( stderr, "%s", _test_output_buffer );
165      _test_output_buffer_index = 0;
166      tcdrain( 2 );
167    }
168
169    #endif
170
171#elif defined(TESTS_USE_PRINTF)
172
173  #include <stdio.h>
174  #include <stdlib.h>
175
176  #define rtems_test_exit(_s) \
177    do { \
178      exit(_s); \
179    } while (0)
180
181  #define FLUSH_OUTPUT() \
182    do { \
183      fflush(stdout); \
184    } while (0)
185
186  #if defined(TEST_STATE_STRING)
187    #define TEST_BEGIN() printf(TEST_BEGIN_STRING); printf(TEST_STATE_STRING)
188  #else
189    #define TEST_BEGIN() printf(TEST_BEGIN_STRING)
190  #endif
191
192  #define TEST_END() printf(TEST_END_STRING)
193
194/*
195 *  USE IPRINT
196 */
197#else
198
199  #include <stdio.h>
200  #include <stdlib.h>
201
202  /* do not use iprintf if strict ansi mode */
203  #if defined(_NEWLIB_VERSION) && !defined(__STRICT_ANSI__)
204    #undef printf
205    #define printf(...) \
206      do { \
207         fiprintf( stderr, __VA_ARGS__ ); \
208      } while (0)
209  #else
210    #undef printf
211    #define printf(...) \
212      do { \
213         fprintf( stderr, __VA_ARGS__ ); \
214      } while (0)
215  #endif
216
217  #undef puts
218  #define puts(_s) \
219      do { \
220         printf( "%s\n", _s ); \
221      } while (0)
222
223  #undef putchar
224  #define putchar(_c) \
225    do { \
226       printf( "%c", _c ); \
227    } while (0)
228
229  #define rtems_test_exit(_s) \
230    do { \
231      exit(_s); \
232    } while (0)
233
234  #define FLUSH_OUTPUT() \
235    do { \
236      fflush(stdout); \
237    } while (0)
238
239  #if defined(TEST_STATE_STRING)
240    #define TEST_BEGIN() fiprintf(stderr, TEST_BEGIN_STRING); fiprintf(stderr, TEST_STATE_STRING)
241  #else
242    #define TEST_BEGIN() fiprintf(stderr, TEST_BEGIN_STRING)
243  #endif
244
245  #define TEST_END()  fiprintf( stderr, TEST_END_STRING)
246
247#endif
248
249#ifdef __cplusplus
250};
251#endif
252
253#endif
Note: See TracBrowser for help on using the repository browser.