X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Fbuild-coverage.c;h=115ae94a15e50a7f4050f2b307e5bdb18295b944;hp=6eb6ab5de8f0a1c2b5761f8b221131ce73e0e55d;hb=2926cafb52b9d95646d9dafa877d53f2368d8b2c;hpb=90479c5a54b5c355b2f3ec6cd73f7c8c09a650a3 diff --git a/tools/ccanlint/tests/build-coverage.c b/tools/ccanlint/tests/build-coverage.c index 6eb6ab5d..115ae94a 100644 --- a/tools/ccanlint/tests/build-coverage.c +++ b/tools/ccanlint/tests/build-coverage.c @@ -18,9 +18,9 @@ static const char *can_run_coverage(struct manifest *m) { unsigned int timeleft = default_timeout_ms; - char *output = run_command(m, &timeleft, "gcov -h"); + char *output; - if (output) + if (!run_command(m, &timeleft, &output, "gcov -h")) return talloc_asprintf(m, "No gcov support: %s", output); return NULL; } @@ -37,9 +37,8 @@ static bool build_module_objs_with_coverage(struct manifest *m, bool keep, char *fullfile = talloc_asprintf(m, "%s/%s", m->dir, i->name); i->cov_compiled = maybe_temp_file(m, "", keep, fullfile); - err = compile_object(m, fullfile, ccan_dir, "", - i->cov_compiled); - if (err) { + if (!compile_object(m, fullfile, ccan_dir, "", + i->cov_compiled, &err)) { score_file_error(score, i, 0, err); talloc_free(i->cov_compiled); i->cov_compiled = NULL; @@ -51,16 +50,12 @@ static bool build_module_objs_with_coverage(struct manifest *m, bool keep, return true; } +/* FIXME: Merge this into one place. */ static char *obj_list(const struct manifest *m, const char *modobjs) { - char *list; + char *list = talloc_strdup(m, ""); struct ccan_file *i; - - /* We expect to be linked with tap, unless that's us. */ - if (!streq(m->basename, "tap")) - list = talloc_asprintf(m, "%s/ccan/tap.o", ccan_dir); - else - list = talloc_strdup(m, ""); + struct manifest *subm; /* Objects from any other C files. */ list_for_each(&m->other_test_c_files, i, list) @@ -70,9 +65,10 @@ static char *obj_list(const struct manifest *m, const char *modobjs) list = talloc_append_string(list, modobjs); /* Other ccan modules (don't need coverage versions of those). */ - list_for_each(&m->dep_dirs, i, list) { - if (i->compiled) - list = talloc_asprintf_append(list, " %s", i->compiled); + list_for_each(&m->deps, subm, list) { + if (subm->compiled) + list = talloc_asprintf_append(list, " %s", + subm->compiled); } return list; @@ -95,19 +91,18 @@ static char *cov_compile(const void *ctx, const char *modobjs, bool keep) { - char *errmsg; + char *output; file->cov_compiled = maybe_temp_file(ctx, "", keep, file->fullname); - errmsg = compile_and_link(ctx, file->fullname, ccan_dir, - obj_list(m, modobjs), - COVERAGE_CFLAGS, - lib_list(m), file->cov_compiled); - if (errmsg) { + if (!compile_and_link(ctx, file->fullname, ccan_dir, + obj_list(m, modobjs), + COVERAGE_CFLAGS, + lib_list(m), file->cov_compiled, &output)) { talloc_free(file->cov_compiled); file->cov_compiled = NULL; - return errmsg; + return output; } - + talloc_free(output); return NULL; } @@ -147,11 +142,12 @@ static void do_compile_coverage_tests(struct manifest *m, } } -struct ccanlint compile_coverage_tests = { - .key = "compile-coverage-tests", - .name = "Module tests compile with profiling", +struct ccanlint tests_compile_coverage = { + .key = "tests_compile_coverage", + .name = "Module tests compile with " COVERAGE_CFLAGS, .check = do_compile_coverage_tests, .can_run = can_run_coverage, + .needs = "tests_compile" }; -REGISTER_TEST(compile_coverage_tests, &compile_tests, NULL); +REGISTER_TEST(tests_compile_coverage);