Changeset 7e102915 in rtems for testsuites/support
- Timestamp:
- Oct 26, 2017, 11:59:09 AM (2 years ago)
- Branches:
- master
- Children:
- acc9d064
- Parents:
- 46ddc3c5
- git-author:
- Sebastian Huber <sebastian.huber@…> (10/26/17 11:59:09)
- git-committer:
- Sebastian Huber <sebastian.huber@…> (10/28/17 11:33:55)
- Location:
- testsuites/support
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
testsuites/support/include/buffer_test_io.h
r46ddc3c5 r7e102915 6 6 #define __BUFFER_TEST_IO_h 7 7 8 #include <rtems/bspIo.h>9 8 #include <rtems/test.h> 10 9 … … 35 34 #endif 36 35 37 /* 38 * USE PRINTK TO MINIMIZE SIZE 39 */ 40 #if defined(TESTS_USE_PRINTK) 36 #undef printf 37 #define printf(...) \ 38 do { \ 39 rtems_printf( &rtems_test_printer, __VA_ARGS__ ); \ 40 } while (0) 41 41 42 #include <rtems/print.h> 42 #undef puts 43 #define puts(_s) \ 44 do { \ 45 rtems_printf( &rtems_test_printer, "%s\n", _s ); \ 46 } while (0) 43 47 44 #undef printf 45 #define printf(...) \46 47 printk( __VA_ARGS__); \48 48 #undef putchar 49 #define putchar(_c) \ 50 do { \ 51 rtems_printf( &rtems_test_printer, "%c", _c ); \ 52 } while (0) 49 53 50 #undef puts 51 #define puts(_s) \52 53 printk( "%s\n", _s); \54 54 /* Do not call exit() since it closes stdin, etc and pulls in stdio code */ 55 #define rtems_test_exit(_s) \ 56 do { \ 57 rtems_shutdown_executive(0); \ 58 } while (0) 55 59 56 #undef putchar 57 #define putchar(_c) \ 58 do { \ 59 printk( "%c", _c ); \ 60 } while (0) 60 #define FLUSH_OUTPUT() \ 61 do { \ 62 } while (0) 61 63 62 /* Do not call exit() since it closes stdin, etc and pulls in stdio code */ 63 #define rtems_test_exit(_s) \ 64 do { \ 65 rtems_shutdown_executive(0); \ 66 } while (0) 64 #if defined(TEST_STATE_STRING) 65 #define TEST_BEGIN() \ 66 do { \ 67 rtems_printf( &rtems_test_printer, "\n"); \ 68 rtems_printf( &rtems_test_printer, TEST_BEGIN_STRING ); \ 69 rtems_printf( &rtems_test_printer, TEST_STATE_STRING ); \ 70 } while (0) 71 #else 72 #define TEST_BEGIN() \ 73 do { \ 74 rtems_printf( &rtems_test_printer, "\n" ); \ 75 rtems_printf( &rtems_test_printer, TEST_BEGIN_STRING ); \ 76 } while (0) 77 #endif 67 78 68 #define FLUSH_OUTPUT() \ 69 do { \ 70 } while (0) 71 72 #if defined(TEST_STATE_STRING) 73 #define TEST_BEGIN() \ 74 do { \ 75 printk("\n"); \ 76 printk(TEST_BEGIN_STRING); \ 77 printk(TEST_STATE_STRING); \ 78 } while (0) 79 #else 80 #define TEST_BEGIN() \ 81 do { \ 82 printk("\n"); \ 83 printk(TEST_BEGIN_STRING); \ 84 } while (0) 85 #endif 86 87 #define TEST_END() \ 88 do { \ 89 printk( "\n" ); \ 90 printk(TEST_END_STRING); \ 91 printk( "\n" ); \ 92 } while (0) 93 94 /* 95 * BUFFER TEST OUTPUT 96 */ 97 #else 98 99 #include <stdio.h> 100 #include <stdlib.h> 101 102 #define TEST_PRINT__FORMAT(_fmtpos, _appos) \ 103 __attribute__((__format__(__printf__, _fmtpos, _appos))) 104 105 #define _TEST_OUTPUT_BUFFER_SIZE 2048 106 107 extern char _test_output_buffer[_TEST_OUTPUT_BUFFER_SIZE]; 108 109 void _test_output_printf(const char *, ...) TEST_PRINT__FORMAT(1, 2); 110 void _test_output_append(const char *); 111 void _test_output_flush(void); 112 113 #define rtems_test_exit(_s) \ 114 do { \ 115 fflush(stdout); \ 116 fflush(stderr); \ 117 _test_output_flush(); \ 118 exit(_s); \ 119 } while (0) 120 121 #undef printf 122 #define printf(...) _test_output_printf( __VA_ARGS__ ) 123 124 #undef puts 125 #define puts(_string) \ 126 do { \ 127 _test_output_append( _string ); \ 128 _test_output_append( "\n" ); \ 129 } while (0) 130 131 #undef putchar 132 #define putchar(_c) \ 133 do { \ 134 char _buffer[2]; \ 135 _buffer[0] = _c; \ 136 _buffer[1] = '\0'; \ 137 _test_output_append( _buffer ); \ 138 } while (0) 139 140 /* we write to stderr when there is a pause() */ 141 #define FLUSH_OUTPUT() _test_output_flush() 142 143 #if defined(TEST_STATE_STRING) 144 #define TEST_BEGIN() \ 145 do { \ 146 _test_output_append( "\n" ); \ 147 _test_output_printf(TEST_BEGIN_STRING); \ 148 _test_output_append(TEST_STATE_STRING); \ 149 _test_output_append( "\n" ); \ 150 } while (0) 151 #else 152 #define TEST_BEGIN() \ 153 do { \ 154 _test_output_append( "\n" ); \ 155 _test_output_printf(TEST_BEGIN_STRING); \ 156 _test_output_append( "\n" ); \ 157 } while (0) 158 #endif 159 160 #define TEST_END() \ 161 do { \ 162 _test_output_append( "\n" ); \ 163 _test_output_printf(TEST_END_STRING); \ 164 _test_output_append( "\n" ); \ 165 } while (0) 166 167 /* 168 * Inline the tests this way because adding the code to the support directory 169 * requires all the makefile files to changed. 170 */ 171 #if defined(TEST_INIT) 172 173 char _test_output_buffer[_TEST_OUTPUT_BUFFER_SIZE]; 174 int _test_output_buffer_index = 0; 175 176 void _test_output_printf(const char* format, ...) 177 { 178 va_list args; 179 char* in; 180 size_t size; 181 bool lf; 182 va_start(args, format); 183 in = _test_output_buffer + _test_output_buffer_index; 184 size = vsniprintf(in, 185 _TEST_OUTPUT_BUFFER_SIZE - _test_output_buffer_index, 186 format, args); 187 lf = memchr(in, '\n', size); 188 _test_output_buffer_index += size; 189 if ( lf || _test_output_buffer_index >= (_TEST_OUTPUT_BUFFER_SIZE - 80) ) 190 _test_output_flush(); 191 va_end(args); 192 } 193 194 void _test_output_append(const char *_buffer) 195 { 196 char* in; 197 size_t size; 198 bool lf; 199 in = _test_output_buffer + _test_output_buffer_index; 200 size = strlcpy(in, _buffer, _TEST_OUTPUT_BUFFER_SIZE - _test_output_buffer_index); 201 lf = memchr(in, '\n', size); 202 if ( lf || _test_output_buffer_index >= (_TEST_OUTPUT_BUFFER_SIZE - 80) ) 203 _test_output_flush(); 204 } 205 206 void _test_output_flush(void) 207 { 208 printk( _test_output_buffer ); 209 _test_output_buffer_index = 0; 210 _test_output_buffer[0] = '\0'; 211 } 212 213 #endif 214 215 #endif 79 #define TEST_END() \ 80 do { \ 81 rtems_printf( &rtems_test_printer, "\n" ); \ 82 rtems_printf( &rtems_test_printer, TEST_END_STRING ); \ 83 rtems_printf( &rtems_test_printer, "\n" ); \ 84 } while (0) 216 85 217 86 #ifdef __cplusplus -
testsuites/support/include/tmacros.h
r46ddc3c5 r7e102915 61 61 || ((!_Thread_Dispatch_is_enabled()) && (_expect) == 0)) \ 62 62 ) { \ 63 print k( \63 printf( \ 64 64 "\n_Thread_Dispatch_disable_level is (%i)" \ 65 65 " not %d detected at %s:%d\n", \ … … 78 78 do { \ 79 79 if ( _RTEMS_Allocator_is_owner() ) { \ 80 print k( \80 printf( \ 81 81 "\nRTEMS Allocator Mutex is owned by executing thread " \ 82 82 "and should not be.\n" \ -
testsuites/support/src/locked_print.c
r46ddc3c5 r7e102915 14 14 #include "test_support.h" 15 15 #include "tmacros.h" 16 17 #include <rtems/bspIo.h> 16 18 17 19 static rtems_id locked_print_semaphore; /* synchronisation semaphore */
Note: See TracChangeset
for help on using the changeset viewer.