]> git.ozlabs.org Git - ccan/blobdiff - tools/ccanlint/tests/tests_compile_coverage.c
ccanlint: keep separate array of compiled versions.
[ccan] / tools / ccanlint / tests / tests_compile_coverage.c
index 508057fa0d3b2d9ad61361211c01e92a94c48dc8..89c786e2a6ec36301c92afb63539503dde48a448 100644 (file)
@@ -38,7 +38,7 @@ 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);
-               if (!compile_object(m, fullfile, ccan_dir, "",
+               if (!compile_object(m, fullfile, ccan_dir, compiler, cflags,
                                    i->cov_compiled, &err)) {
                        score_file_error(score, i, 0, "%s", err);
                        talloc_free(i->cov_compiled);
@@ -60,16 +60,18 @@ static char *obj_list(const struct manifest *m, const char *modobjs)
 
        /* Objects from any other C files. */
        list_for_each(&m->other_test_c_files, i, list)
-               list = talloc_asprintf_append(list, " %s", i->compiled);
+               list = talloc_asprintf_append(list, " %s",
+                                             i->compiled[COMPILE_NORMAL]);
 
        if (modobjs)
                list = talloc_append_string(list, modobjs);
 
        /* Other ccan modules (don't need coverage versions of those). */
        list_for_each(&m->deps, subm, list) {
-               if (subm->compiled)
+               if (subm->compiled[COMPILE_NORMAL])
                        list = talloc_asprintf_append(list, " %s",
-                                                     subm->compiled);
+                                                     subm->compiled
+                                                     [COMPILE_NORMAL]);
        }
 
        return list;
@@ -78,7 +80,8 @@ static char *obj_list(const struct manifest *m, const char *modobjs)
 static char *lib_list(const struct manifest *m)
 {
        unsigned int i, num;
-       char **libs = get_libs(m, m->dir, &num, &m->info_file->compiled);
+       char **libs = get_libs(m, m->dir, &num,
+                              &m->info_file->compiled[COMPILE_NORMAL]);
        char *ret = talloc_strdup(m, "");
 
        for (i = 0; i < num; i++)
@@ -93,11 +96,12 @@ static char *cov_compile(const void *ctx,
                         bool keep)
 {
        char *output;
+       char *f = talloc_asprintf(ctx, "%s %s", cflags, COVERAGE_CFLAGS);
 
        file->cov_compiled = maybe_temp_file(ctx, "", keep, file->fullname);
        if (!compile_and_link(ctx, file->fullname, ccan_dir,
                              obj_list(m, modobjs),
-                             COVERAGE_CFLAGS,
+                             compiler, f,
                              lib_list(m), file->cov_compiled, &output)) {
                talloc_free(file->cov_compiled);
                file->cov_compiled = NULL;
@@ -126,7 +130,10 @@ static void do_compile_coverage_tests(struct manifest *m,
 
        foreach_ptr(h, &m->run_tests, &m->api_tests) {
                list_for_each(h, i, list) {
-                       cmdout = cov_compile(m, m, i, NULL, keep);
+                       cmdout = cov_compile(m, m, i,
+                                            h == &m->api_tests
+                                            ? modobjs : NULL,
+                                            keep);
                        if (cmdout) {
                                score_file_error(score, i, 0,
                                  "Failed to compile test with coverage: %s",