From b6425505ff03ea9336692adf0ebd5fa14560fb5f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 6 Oct 2010 13:59:08 +1030 Subject: [PATCH 1/1] ccanlint: really fix failing test logic. Some of the compulsory tests don't have a total_score; treat that as "1". And don't print out a score if the total is <= 1. --- tools/ccanlint/ccanlint.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/tools/ccanlint/ccanlint.c b/tools/ccanlint/ccanlint.c index 00d5363e..d19ede62 100644 --- a/tools/ccanlint/ccanlint.c +++ b/tools/ccanlint/ccanlint.c @@ -107,7 +107,7 @@ static bool run_test(struct ccanlint *i, struct manifest *m) { void *result; - unsigned int this_score, timeleft; + unsigned int this_score, max_score, timeleft; const struct dependent *d; const char *skip; bool bad, good; @@ -143,22 +143,25 @@ static bool run_test(struct ccanlint *i, goto skip; } + max_score = i->total_score; + if (!max_score) + max_score = 1; + if (!result) - this_score = i->total_score ? i->total_score : 1; + this_score = max_score; else if (i->score) this_score = i->score(m, result); else this_score = 0; - bad = (this_score == 0 && i->total_score != 0); - good = (this_score >= i->total_score); + bad = (this_score == 0); + good = (this_score >= max_score); - if (verbose || (bad && !quiet)) { + if (verbose || (!good && !quiet)) { printf(" %s: %s", i->name, bad ? "FAIL" : good ? "PASS" : "PARTIAL"); - if (i->total_score) - printf(" (+%u/%u)", - this_score, i->total_score); + if (max_score > 1) + printf(" (+%u/%u)", this_score, max_score); printf("\n"); } @@ -185,7 +188,7 @@ static bool run_test(struct ccanlint *i, d->dependent->skip_fail = true; } } - return !bad; + return good; } static void register_test(struct list_head *h, struct ccanlint *test, ...) -- 2.39.2