Commit 6fa66e4e authored by Rusty Russell's avatar Rusty Russell

ccanlint: compile tests with coverage in parallel

Measuring ccanlint -d ccan/tdb2 on my dual core hyperthread laptop gives:
Before: 5:59
After: 5:30
parent 4640e61b
...@@ -28,30 +28,24 @@ static const char *can_run_coverage(struct manifest *m) ...@@ -28,30 +28,24 @@ static const char *can_run_coverage(struct manifest *m)
return NULL; return NULL;
} }
static char *cov_compile(const void *ctx, static void cov_compile(const void *ctx,
struct manifest *m, unsigned int time_ms,
struct ccan_file *file, struct manifest *m,
bool link_with_module, struct ccan_file *file,
bool keep) bool link_with_module,
bool keep)
{ {
char *output;
char *flags = talloc_asprintf(ctx, "%s %s", cflags, COVERAGE_CFLAGS); char *flags = talloc_asprintf(ctx, "%s %s", cflags, COVERAGE_CFLAGS);
file->compiled[COMPILE_COVERAGE] file->compiled[COMPILE_COVERAGE]
= maybe_temp_file(ctx, "", keep, file->fullname); = maybe_temp_file(ctx, "", keep, file->fullname);
if (!compile_and_link(ctx, file->fullname, ccan_dir, compile_and_link_async(file, time_ms, file->fullname, ccan_dir,
test_obj_list(m, link_with_module, test_obj_list(m, link_with_module,
COMPILE_NORMAL, COMPILE_NORMAL,
COMPILE_COVERAGE), COMPILE_COVERAGE),
compiler, flags, compiler, flags,
lib_list(m, COMPILE_NORMAL), lib_list(m, COMPILE_NORMAL),
file->compiled[COMPILE_COVERAGE], &output)) { file->compiled[COMPILE_COVERAGE]);
talloc_free(file->compiled[COMPILE_COVERAGE]);
file->compiled[COMPILE_COVERAGE] = NULL;
return output;
}
talloc_free(output);
return NULL;
} }
/* FIXME: Coverage from testable examples as well. */ /* FIXME: Coverage from testable examples as well. */
...@@ -63,6 +57,7 @@ static void do_compile_coverage_tests(struct manifest *m, ...@@ -63,6 +57,7 @@ static void do_compile_coverage_tests(struct manifest *m,
char *cmdout; char *cmdout;
struct ccan_file *i; struct ccan_file *i;
struct list_head *h; struct list_head *h;
bool ok;
char *f = talloc_asprintf(score, "%s %s", cflags, COVERAGE_CFLAGS); char *f = talloc_asprintf(score, "%s %s", cflags, COVERAGE_CFLAGS);
/* For API tests, we need coverage version of module. */ /* For API tests, we need coverage version of module. */
...@@ -77,14 +72,16 @@ static void do_compile_coverage_tests(struct manifest *m, ...@@ -77,14 +72,16 @@ static void do_compile_coverage_tests(struct manifest *m,
foreach_ptr(h, &m->run_tests, &m->api_tests) { foreach_ptr(h, &m->run_tests, &m->api_tests) {
list_for_each(h, i, list) { list_for_each(h, i, list) {
cmdout = cov_compile(m, m, i, cov_compile(m, *timeleft, m, i, h == &m->api_tests,
h == &m->api_tests, keep);
keep); }
if (cmdout) { }
score_file_error(score, i, 0,
"Failed to compile test with coverage: %s", while ((i = collect_command(&ok, &cmdout)) != NULL) {
cmdout); if (!ok) {
} score_file_error(score, i, 0,
"Failed to compile test with coverage:"
" %s", cmdout);
} }
} }
if (!score->error) { if (!score->error) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment