Use constants for coloured strings, which have a ugly format. Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@xxxxxxxxx> --- tests/nft-parsing-test.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/nft-parsing-test.c b/tests/nft-parsing-test.c index 5eaaa1e..5333dbd 100644 --- a/tests/nft-parsing-test.c +++ b/tests/nft-parsing-test.c @@ -33,6 +33,9 @@ enum { TEST_JSON_RULESET, }; +#define FAILED_STR "\033[31mFAILED\e[0m" +#define OK_STR "\033[32mOK\e[0m" + #if defined(XML_PARSING) || defined(JSON_PARSING) static void print_detail_error(char *a, char *b) { @@ -160,8 +163,7 @@ static int compare_test(uint32_t type, void *input, const char *filename) if (strncmp(orig, out, strlen(out)) == 0) return 0; - printf("validating %s: ", filename); - printf("\033[31mFAILED\e[0m\n"); + printf("parsing and validating %s: %s\n", filename, FAILED_STR); print_detail_error(orig, out); return -1; } @@ -245,8 +247,7 @@ static int test_json(const char *filename) return ret; failparsing: - printf("parsing %s: ", filename); - printf("\033[31mFAILED\e[0m (%s)\n", strerror(errno)); + printf("parsing %s: %s (%s)\n", filename, FAILED_STR, strerror(errno)); free(json); json_decref(root); return -1; @@ -340,8 +341,8 @@ static int test_xml(const char *filename) failparsing: mxmlDelete(tree); - printf("parsing %s: ", filename); - printf("\033[31mFAILED\e[0m (%s)\n", strerror(errno)); + printf("parsing and validating %s: %s (%s)\n", filename, FAILED_STR, + strerror(errno)); return -1; #else errno = EOPNOTSUPP; @@ -379,14 +380,14 @@ int main(int argc, char *argv[]) if (strcmp(&dent->d_name[len-4], ".xml") == 0) { if ((ret = test_xml(path)) == 0) { printf("parsing and validating %s: ", path); - printf("\033[32mOK\e[0m\n"); + printf("%s\n", OK_STR); } exit_code += ret; } if (strcmp(&dent->d_name[len-5], ".json") == 0) { if ((ret = test_json(path)) == 0) { printf("parsing and validating %s: ", path); - printf("\033[32mOK\e[0m\n"); + printf("%s\n", OK_STR); } exit_code += ret; } -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html