1 #include <tools/ccanlint/ccanlint.h>
2 #include <tools/tools.h>
3 #include <ccan/talloc/talloc.h>
4 #include <ccan/str/str.h>
16 #include "reduce_features.h"
18 static const char *can_run(struct manifest *m)
21 return "Safe mode enabled";
25 static bool compile(struct manifest *m,
27 struct ccan_file *cfile,
29 enum compile_type ctype,
32 cfile->compiled[ctype] = maybe_temp_file(m, ".o", keep, cfile->fullname);
33 return compile_object(m, cfile->fullname, ccan_dir, compiler, flags,
34 cfile->compiled[ctype], output);
37 static void compile_test_helpers(struct manifest *m,
39 unsigned int *timeleft,
42 enum compile_type ctype)
45 bool errors = false, warnings = false;
47 if (list_empty(&m->other_test_c_files))
52 list_for_each(&m->other_test_c_files, i, list) {
55 if (!compile(m, keep, i, flags, ctype, &cmdout)) {
57 score_file_error(score, i, 0, "Compile failed:\n%s",
59 } else if (!streq(cmdout, "")) {
61 score_file_error(score, i, 0,
62 "Compile gave warnings:\n%s", cmdout);
68 score->score = score->total - warnings;
72 static void do_compile_test_helpers(struct manifest *m,
74 unsigned int *timeleft,
77 compile_test_helpers(m, keep, timeleft, score, cflags,
81 struct ccanlint tests_helpers_compile = {
82 .key = "tests_helpers_compile",
83 .name = "Module test helper objects compile",
84 .check = do_compile_test_helpers,
86 .needs = "depends_build tests_exist"
89 REGISTER_TEST(tests_helpers_compile);
91 static const char *features_reduced(struct manifest *m)
93 if (features_were_reduced)
95 return "No features to turn off";
98 static void do_compile_test_helpers_without_features(struct manifest *m,
100 unsigned int *timeleft,
105 flags = talloc_asprintf(score, "%s %s", cflags,
106 REDUCE_FEATURES_FLAGS);
108 compile_test_helpers(m, keep, timeleft, score, flags,
112 struct ccanlint tests_helpers_compile_without_features = {
113 .key = "tests_helpers_compile_without_features",
114 .name = "Module tests helpers compile (without features)",
115 .check = do_compile_test_helpers_without_features,
116 .can_run = features_reduced,
117 .needs = "depends_build_without_features tests_exist"
119 REGISTER_TEST(tests_helpers_compile_without_features);