X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Ftests_helpers_compile.c;h=0f728fb9420160b7bf852ce8210289056d59a163;hp=67ca8d8ae332f192f568272909befb7ac2281aaa;hb=HEAD;hpb=7bb7cd58c2d9df126dd6072e5f3bec1eb4dc916b diff --git a/tools/ccanlint/tests/tests_helpers_compile.c b/tools/ccanlint/tests/tests_helpers_compile.c index 67ca8d8a..0f728fb9 100644 --- a/tools/ccanlint/tests/tests_helpers_compile.c +++ b/tools/ccanlint/tests/tests_helpers_compile.c @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -13,8 +12,9 @@ #include #include #include +#include "reduce_features.h" -static const char *can_run(struct manifest *m) +static const char *can_run(struct manifest *m UNNEEDED) { if (safe_mode) return "Safe mode enabled"; @@ -22,19 +22,21 @@ static const char *can_run(struct manifest *m) } static bool compile(struct manifest *m, - bool keep, struct ccan_file *cfile, + const char *flags, + enum compile_type ctype, char **output) { - cfile->compiled = maybe_temp_file(m, ".o", keep, cfile->fullname); - return compile_object(m, cfile->fullname, ccan_dir, "", - cfile->compiled, output); + cfile->compiled[ctype] = temp_file(m, ".o", cfile->fullname); + return compile_object(m, cfile->fullname, ccan_dir, compiler, flags, + cfile->compiled[ctype], output); } -static void do_compile_test_helpers(struct manifest *m, - bool keep, - unsigned int *timeleft, - struct score *score) +static void compile_test_helpers(struct manifest *m, + unsigned int *timeleft UNNEEDED, + struct score *score, + const char *flags, + enum compile_type ctype) { struct ccan_file *i; bool errors = false, warnings = false; @@ -47,7 +49,7 @@ static void do_compile_test_helpers(struct manifest *m, list_for_each(&m->other_test_c_files, i, list) { char *cmdout; - if (!compile(m, keep, i, &cmdout)) { + if (!compile(m, i, flags, ctype, &cmdout)) { errors = true; score_file_error(score, i, 0, "Compile failed:\n%s", cmdout); @@ -64,6 +66,13 @@ static void do_compile_test_helpers(struct manifest *m, } } +static void do_compile_test_helpers(struct manifest *m, + unsigned int *timeleft, + struct score *score) +{ + compile_test_helpers(m, timeleft, score, cflags, COMPILE_NORMAL); +} + struct ccanlint tests_helpers_compile = { .key = "tests_helpers_compile", .name = "Module test helper objects compile", @@ -73,3 +82,30 @@ struct ccanlint tests_helpers_compile = { }; REGISTER_TEST(tests_helpers_compile); + +static const char *features_reduced(struct manifest *m UNNEEDED) +{ + if (features_were_reduced) + return NULL; + return "No features to turn off"; +} + +static void do_compile_test_helpers_without_features(struct manifest *m, + unsigned int *timeleft, + struct score *score) +{ + char *flags; + + flags = tal_fmt(score, "%s %s", cflags, REDUCE_FEATURES_FLAGS); + + compile_test_helpers(m, timeleft, score, flags, COMPILE_NOFEAT); +} + +struct ccanlint tests_helpers_compile_without_features = { + .key = "tests_helpers_compile_without_features", + .name = "Module tests helpers compile (without features)", + .check = do_compile_test_helpers_without_features, + .can_run = features_reduced, + .needs = "depends_build_without_features tests_exist" +}; +REGISTER_TEST(tests_helpers_compile_without_features);