X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=tools%2Fccanlint%2Fcompulsory_tests%2Fcheck_depends_built.c;h=41e5d8885e52aea5026d73d426c10eee9c592e99;hb=83cfe17fd85efb7f5d8e8b1edb1f3c28b180a2ce;hp=c261315ddf47a243d425c2317d5b740134a0712c;hpb=304652023042670b3173de0ad5dc0eb7c836618c;p=ccan diff --git a/tools/ccanlint/compulsory_tests/check_depends_built.c b/tools/ccanlint/compulsory_tests/check_depends_built.c index c261315d..41e5d888 100644 --- a/tools/ccanlint/compulsory_tests/check_depends_built.c +++ b/tools/ccanlint/compulsory_tests/check_depends_built.c @@ -35,28 +35,26 @@ static bool expect_obj_file(const char *dir) return has_c_files; } -static void *check_depends_built(struct manifest *m, unsigned int *timeleft) +static void check_depends_built(struct manifest *m, + bool keep, + unsigned int *timeleft, struct score *score) { struct ccan_file *i; struct stat st; - char *report = NULL; list_for_each(&m->dep_dirs, i, list) { - char *objfile; - if (!expect_obj_file(i->fullname)) continue; - objfile = talloc_asprintf(m, "%s.o", i->fullname); - if (stat(objfile, &st) != 0) { - report = talloc_asprintf_append(report, - "object file %s\n", - objfile); - } else { - struct ccan_file *f = new_ccan_file(m, "", objfile); - list_add_tail(&m->dep_objs, &f->list); - } - + i->compiled = talloc_asprintf(i, "%s.o", i->fullname); + if (stat(i->compiled, &st) != 0) { + score->error = "Dependencies are not built"; + score_file_error(score, i, 0, + talloc_asprintf(score, + "object file %s", + i->compiled)); + i->compiled = NULL; + } } /* We may need libtap for testing, unless we're "tap" */ @@ -64,30 +62,21 @@ static void *check_depends_built(struct manifest *m, unsigned int *timeleft) && (!list_empty(&m->run_tests) || !list_empty(&m->api_tests))) { char *tapobj = talloc_asprintf(m, "%s/ccan/tap.o", ccan_dir); if (stat(tapobj, &st) != 0) { - report = talloc_asprintf_append(report, - "object file %s" - " (for tests)\n", - tapobj); + score->error = talloc_asprintf(score, + "tap object file not built"); } } - return talloc_steal(m, report); -} - -static const char *describe_depends_built(struct manifest *m, - void *check_result) -{ - return talloc_asprintf(check_result, - "The following dependencies are not built:\n" - "%s", (char *)check_result); + if (!score->error) { + score->pass = true; + score->score = score->total; + } } struct ccanlint depends_built = { .key = "depends-built", .name = "Module's CCAN dependencies are already built", - .total_score = 1, .check = check_depends_built, - .describe = describe_depends_built, .can_run = can_build, };