summaryrefslogtreecommitdiffstats
path: root/testsuites/support/include/buffer_test_io.h
blob: 1ff15f6ca8200df70530f54fcfa69a4710134e3e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
 *  Support for running the test output through a buffer
 */

#ifndef __BUFFER_TEST_IO_h
#define __BUFFER_TEST_IO_h

#include <rtems/test.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
 * Test states. No state string is an expected pass.
 */
#if (TEST_STATE_EXPECTED_FAIL && TEST_STATE_USER_INPUT) || \
    (TEST_STATE_EXPECTED_FAIL && TEST_STATE_INDETERMINATE) || \
    (TEST_STATE_EXPECTED_FAIL && TEST_STATE_BENCHMARK) || \
    (TEST_STATE_USER_INPUT    && TEST_STATE_INDETERMINATE) || \
    (TEST_STATE_USER_INPUT    && TEST_STATE_BENCHMARK) || \
    (TEST_STATE_INDETERMINATE && TEST_STATE_BENCHMARK)
  #error Test states must be unique
#endif

#if TEST_STATE_EXPECTED_FAIL
  #define TEST_STATE_STRING "*** TEST STATE: EXPECTED-FAIL\n"
#elif TEST_STATE_USER_INPUT
  #define TEST_STATE_STRING "*** TEST STATE: USER_INPUT\n"
#elif TEST_STATE_INDETERMINATE
  #define TEST_STATE_STRING "*** TEST STATE: INDETERMINATE\n"
#elif TEST_STATE_BENCHMARK
  #define TEST_STATE_STRING "*** TEST STATE: BENCHMARK\n"
#endif

#undef printf
#define printf(...) \
  do { \
     rtems_printf( &rtems_test_printer, __VA_ARGS__ ); \
  } while (0)

#undef puts
#define puts(_s) \
  do { \
     rtems_printf( &rtems_test_printer, "%s\n", _s ); \
  } while (0)

#undef putchar
#define putchar(_c) \
  do { \
     rtems_printf( &rtems_test_printer, "%c", _c ); \
  } while (0)

/* Do not call exit() since it closes stdin, etc and pulls in stdio code */
#define rtems_test_exit(_s) \
  do { \
    rtems_shutdown_executive(0); \
  } while (0)

#define FLUSH_OUTPUT() \
  do { \
  } while (0)

#if defined(TEST_STATE_STRING)
  #define TEST_BEGIN() \
  do { \
    rtems_printf( &rtems_test_printer, "\n"); \
    rtems_printf( &rtems_test_printer, TEST_BEGIN_STRING ); \
    rtems_printf( &rtems_test_printer, TEST_STATE_STRING ); \
  } while (0)
#else
  #define TEST_BEGIN() \
  do { \
    rtems_printf( &rtems_test_printer, "\n" ); \
    rtems_printf( &rtems_test_printer, TEST_BEGIN_STRING ); \
  } while (0)
#endif

#define TEST_END() \
  do { \
     rtems_printf( &rtems_test_printer, "\n" ); \
     rtems_printf( &rtems_test_printer, TEST_END_STRING ); \
     rtems_printf( &rtems_test_printer, "\n" ); \
  } while (0)

#ifdef __cplusplus
};
#endif

#endif