X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Ftests_compile_coverage.c;h=c8bc35d93b1ab1fe37320b18fb79f2bb7023ef0b;hp=0d3e7e1db5f87342296643563c9b4e90afeba009;hb=HEAD;hpb=af5b1a18948345c5f9f9abf4eda3ab9fe0aa9a9f diff --git a/tools/ccanlint/tests/tests_compile_coverage.c b/tools/ccanlint/tests/tests_compile_coverage.c index 0d3e7e1d..c8bc35d9 100644 --- a/tools/ccanlint/tests/tests_compile_coverage.c +++ b/tools/ccanlint/tests/tests_compile_coverage.c @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -20,12 +19,28 @@ /* Note: we already test safe_mode in run_tests.c */ static const char *can_run_coverage(struct manifest *m) { - unsigned int timeleft = default_timeout_ms; - char *output; + return gcov_unavailable(m); +} + +static char *cflags_list(const struct manifest *m) +{ + unsigned int i; + char *ret = tal_strdup(m, cflags); + + char **flags = get_cflags(m, m->dir, get_or_compile_info); + for (i = 0; flags[i]; i++) + tal_append_fmt(&ret, " %s", flags[i]); + return ret; +} + +static char *cflags_list_append(const struct manifest *m, char *iflags) +{ + unsigned int i; - if (!run_command(m, &timeleft, &output, "gcov -h")) - return talloc_asprintf(m, "No gcov support: %s", output); - return NULL; + char **flags = get_cflags(m, m->dir, get_or_compile_info); + for (i = 0; flags[i]; i++) + tal_append_fmt(&iflags, " %s", flags[i]); + return iflags; } static void cov_compile(const void *ctx, @@ -34,7 +49,8 @@ static void cov_compile(const void *ctx, struct ccan_file *file, bool link_with_module) { - char *flags = talloc_asprintf(ctx, "%s %s", cflags, COVERAGE_CFLAGS); + char *flags = tal_fmt(ctx, "%s %s", cflags, COVERAGE_CFLAGS); + flags = cflags_list_append(m, flags); file->compiled[COMPILE_COVERAGE] = temp_file(ctx, "", file->fullname); compile_and_link_async(file, time_ms, file->fullname, ccan_dir, @@ -42,7 +58,7 @@ static void cov_compile(const void *ctx, COMPILE_NORMAL, COMPILE_COVERAGE), compiler, flags, - lib_list(m, COMPILE_NORMAL), + test_lib_list(m, COMPILE_NORMAL), file->compiled[COMPILE_COVERAGE]); } @@ -55,13 +71,14 @@ static void do_compile_coverage_tests(struct manifest *m, struct ccan_file *i; struct list_head *h; bool ok; - char *f = talloc_asprintf(score, "%s %s", cflags, COVERAGE_CFLAGS); + char *f = cflags_list(m); + tal_append_fmt(&f, " %s", COVERAGE_CFLAGS); /* For API tests, we need coverage version of module. */ if (!list_empty(&m->api_tests)) { build_objects(m, score, f, COMPILE_COVERAGE); if (!score->pass) { - score->error = talloc_strdup(score, + score->error = tal_strdup(score, "Failed to compile module objects with coverage"); return; }