X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Ftests_compile.c;h=911f310caf5e1d9800f37996600c427483c758b8;hb=87c679ff36d7b198862cd2652a384d90f89f3b2b;hp=2e7cd2640eec2a1022e50d00906294aee5825077;hpb=8af0812be4b3fcb82d82b70ea1b571225a76ca19;p=ccan diff --git a/tools/ccanlint/tests/tests_compile.c b/tools/ccanlint/tests/tests_compile.c index 2e7cd264..911f310c 100644 --- a/tools/ccanlint/tests/tests_compile.c +++ b/tools/ccanlint/tests/tests_compile.c @@ -69,7 +69,6 @@ static bool compile(const void *ctx, struct ccan_file *file, bool fail, bool link_with_module, - bool keep, enum compile_type ctype, char **output) { @@ -78,9 +77,10 @@ static bool compile(const void *ctx, flags = talloc_asprintf(ctx, "%s%s%s", fail ? "-DFAIL " : "", cflags, - ctype == COMPILE_NOFEAT ? " -I." : ""); + ctype == COMPILE_NOFEAT + ? " "REDUCE_FEATURES_FLAGS : ""); - fname = maybe_temp_file(ctx, "", keep, file->fullname); + fname = temp_file(ctx, "", file->fullname); if (!compile_and_link(ctx, file->fullname, ccan_dir, test_obj_list(m, link_with_module, ctype, ctype), @@ -94,30 +94,56 @@ static bool compile(const void *ctx, return true; } -static void compile_tests(struct manifest *m, bool keep, +static void compile_async(const void *ctx, + struct manifest *m, + struct ccan_file *file, + bool link_with_module, + enum compile_type ctype, + unsigned int time_ms) +{ + char *flags; + + file->compiled[ctype] = temp_file(ctx, "", file->fullname); + flags = talloc_asprintf(ctx, "%s%s", + cflags, + ctype == COMPILE_NOFEAT + ? " "REDUCE_FEATURES_FLAGS : ""); + + compile_and_link_async(file, time_ms, file->fullname, ccan_dir, + test_obj_list(m, link_with_module, ctype, ctype), + compiler, flags, lib_list(m, ctype), + file->compiled[ctype]); +} + +static void compile_tests(struct manifest *m, struct score *score, - enum compile_type ctype) + enum compile_type ctype, + unsigned int time_ms) { char *cmdout; struct ccan_file *i; struct list_head *list; - bool errors = false, warnings = false; + bool errors = false, warnings = false, ok; foreach_ptr(list, &m->compile_ok_tests, &m->run_tests, &m->api_tests) { list_for_each(list, i, list) { - if (!compile(score, m, i, false, - list == &m->api_tests, keep, - ctype, &cmdout)) { - score_file_error(score, i, 0, - "Compile failed:\n%s", - cmdout); - errors = true; - } else if (!streq(cmdout, "")) { - score_file_error(score, i, 0, - "Compile gave warnings:\n%s", - cmdout); - warnings = true; - } + compile_async(score, m, i, + list == &m->api_tests, + ctype, time_ms); + } + } + + while ((i = collect_command(&ok, &cmdout)) != NULL) { + if (!ok) { + score_file_error(score, i, 0, + "Compile failed:\n%s", + cmdout); + errors = true; + } else if (!streq(cmdout, "")) { + score_file_error(score, i, 0, + "Compile gave warnings:\n%s", + cmdout); + warnings = true; } } @@ -127,8 +153,7 @@ static void compile_tests(struct manifest *m, bool keep, /* For historical reasons, "fail" often means "gives warnings" */ list_for_each(&m->compile_fail_tests, i, list) { - if (!compile(score, m, i, false, false, false, - ctype, &cmdout)) { + if (!compile(score, m, i, false, false, ctype, &cmdout)) { score_file_error(score, i, 0, "Compile without -DFAIL failed:\n%s", cmdout); @@ -141,8 +166,7 @@ static void compile_tests(struct manifest *m, bool keep, cmdout); return; } - if (compile(score, m, i, true, false, false, - ctype, &cmdout) + if (compile(score, m, i, true, false, ctype, &cmdout) && streq(cmdout, "")) { score_file_error(score, i, 0, "Compiled successfully with -DFAIL?"); @@ -155,11 +179,11 @@ static void compile_tests(struct manifest *m, bool keep, score->score = score->total - warnings; } +/* FIXME: If we time out, set *timeleft to 0 */ static void do_compile_tests(struct manifest *m, - bool keep, unsigned int *timeleft, struct score *score) { - compile_tests(m, keep, score, COMPILE_NORMAL); + compile_tests(m, score, COMPILE_NORMAL, *timeleft); } struct ccanlint tests_compile = { @@ -180,11 +204,10 @@ static const char *features_reduced(struct manifest *m) } static void do_compile_tests_without_features(struct manifest *m, - bool keep, unsigned int *timeleft, struct score *score) { - compile_tests(m, keep, score, COMPILE_NOFEAT); + compile_tests(m, score, COMPILE_NOFEAT, *timeleft); } struct ccanlint tests_compile_without_features = { @@ -192,6 +215,6 @@ struct ccanlint tests_compile_without_features = { .name = "Module tests compile (without features)", .check = do_compile_tests_without_features, .can_run = features_reduced, - .needs = "tests_helpers_compile_without_features reduce_features" + .needs = "module_builds tests_helpers_compile_without_features objects_build_without_features" }; REGISTER_TEST(tests_compile_without_features);