X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=tests%2Futils.h;fp=tests%2Futils.h;h=94891c0c64a3b2d8f29be1a922411f018466f677;hp=7650865dd57c64411840db21541454ecf5774967;hb=2d7e012dc1d47b55bf37e05d9c2a76bad7620e31;hpb=2f70b271351fe2b7befc4e327503f7c13a57dcd5 diff --git a/tests/utils.h b/tests/utils.h index 7650865dd..94891c0c6 100644 --- a/tests/utils.h +++ b/tests/utils.h @@ -16,10 +16,28 @@ */ #include +#include #define BRIGHT 1 #define GREEN 32 #define RED 31 -#define PRINT_OK() printf("%c[%d;%dmOK%c[%dm\n", 0x1B, BRIGHT, GREEN, 0x1B, 0); -#define PRINT_FAIL() printf("%c[%d;%dmFAIL%c[%dm\n", 0x1B, BRIGHT, RED, 0x1B, 0); +#define PRINT_OK() \ +do { \ + /* Check for color support */ \ + if (isatty(STDOUT_FILENO)) { \ + printf("%c[%d;%dmOK%c[%dm\n", 0x1B, BRIGHT, GREEN, 0x1B, 0); \ + } else { \ + printf("OK\n"); \ + } \ +} while (0) + +#define PRINT_FAIL() \ +do { \ + /* Check for color support */ \ + if (isatty(STDOUT_FILENO)) { \ + printf("%c[%d;%dmFAIL%c[%dm\n", 0x1B, BRIGHT, RED, 0x1B, 0); \ + } else { \ + printf("FAIL\n"); \ + } \ +} while (0)