aboutsummaryrefslogtreecommitdiffstats
path: root/utils/cec-compliance/cec-compliance.h
diff options
context:
space:
mode:
authorPhilipp Zabel <p.zabel@pengutronix.de>2019-04-09 16:49:58 +0200
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2019-04-24 09:15:59 +0200
commit7cc65c29bd38b76b8b2af2dba80ea0158605021a (patch)
tree4915e05188d6ec2dc333da1037190df29f10bcf5 /utils/cec-compliance/cec-compliance.h
parentf20d813c5cbbab9e180e8c9b374895cba5dbd40d (diff)
cec-compliance: add colors
Use color codes to mark OK, warn, and FAIL messages with green, bold, and bright red accents, respectively. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Diffstat (limited to 'utils/cec-compliance/cec-compliance.h')
-rw-r--r--utils/cec-compliance/cec-compliance.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/utils/cec-compliance/cec-compliance.h b/utils/cec-compliance/cec-compliance.h
index 2ebf2d5d..d7460b62 100644
--- a/utils/cec-compliance/cec-compliance.h
+++ b/utils/cec-compliance/cec-compliance.h
@@ -111,6 +111,7 @@ struct short_audio_desc {
#define SAD_EXT_TYPE_LPCM_3D_AUDIO 13
extern bool show_info;
+extern bool show_colors;
extern bool show_warnings;
extern bool exit_on_fail;
extern bool exit_on_warn;
@@ -192,6 +193,10 @@ struct remote_subtest {
#define cec_phys_addr_exp(pa) \
((pa) >> 12), ((pa) >> 8) & 0xf, ((pa) >> 4) & 0xf, (pa) & 0xf
+#define COLOR_GREEN(s) "\033[32m" s "\033[0m"
+#define COLOR_RED(s) "\033[1;31m" s "\033[0m"
+#define COLOR_BOLD(s) "\033[1m" s "\033[0m"
+
#define info(fmt, args...) \
do { \
if (show_info) \
@@ -218,7 +223,9 @@ struct remote_subtest {
({ \
warnings++; \
if (show_warnings) \
- printf("\t\twarn: %s(%d): " fmt, __FILE__, __LINE__, ##args); \
+ printf("\t\%s: %s(%d): " fmt, \
+ show_colors ? COLOR_BOLD("warn") : "warn", \
+ __FILE__, __LINE__, ##args); \
if (exit_on_warn) \
exit(1); \
0; \
@@ -236,7 +243,8 @@ struct remote_subtest {
#define fail(fmt, args...) \
({ \
- printf("\t\tfail: %s(%d): " fmt, __FILE__, __LINE__, ##args); \
+ printf("\t\t%s: %s(%d): " fmt, show_colors ? \
+ COLOR_RED("fail") : "fail", __FILE__, __LINE__, ##args); \
if (exit_on_fail) \
exit(1); \
FAIL; \

Privacy Policy