Skip to content

Commit 755d6c5

Browse files
committed
tests/unit-test.h.in, tests/unit-test-client.c: introduce FLUSHOUT to help with console logs on WIN32 test runs
Signed-off-by: Jim Klimov <[email protected]>
1 parent 3d43877 commit 755d6c5

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

tests/unit-test-client.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ static char last_test_title[256];
4141

4242
#define ASSERT_TRUE(_cond, _format, __args...) \
4343
{ \
44+
FLUSHOUT; \
4445
if (_cond) { \
4546
printf("%s: OK\n", last_test_title); \
47+
FLUSHOUT; \
4648
} else { \
4749
printf("%s: FAILED\n", last_test_title); \
4850
BUG_REPORT(_cond, _format, ##__args); \
@@ -52,10 +54,12 @@ static char last_test_title[256];
5254

5355
#define TEST_TITLE(_format, _args...) \
5456
{ \
57+
FLUSHOUT; \
5558
snprintf(last_test_title, sizeof(last_test_title), \
5659
_format, ##_args); \
5760
printf("\n=== Test at line %4d: %s :\n", \
5861
__LINE__, last_test_title); \
62+
FLUSHOUT; \
5963
};
6064

6165
int is_memory_equal(const void *s1, const void *s2, size_t size)

tests/unit-test.h.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,13 @@ const uint16_t UT_IREAL_DCBA[] = {0x0020, 0xF147};
8888
const uint16_t UT_IREAL_BADC[] = {0xF147, 0x0020};
8989
const uint16_t UT_IREAL_CDAB[] = {0x2000, 0x47F1};
9090

91+
#ifdef _WIN32
92+
// It may also help to view console logs of the client+server
93+
// on WIN32 builds without intermixing, by piping to "cat":
94+
// make -j 8 && ( ./tests/unit-test-server|cat & sleep 1 ; ./tests/unit-test-client|cat )
95+
# define FLUSHOUT do { fflush(stdout); } while(0)
96+
#else
97+
# define FLUSHOUT (void)0
98+
#endif
99+
91100
#endif /* _UNIT_TEST_H_ */

0 commit comments

Comments
 (0)