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,
26 struct ccan_file *cfile,
28 enum compile_type ctype,
31 cfile->compiled[ctype] = temp_file(m, ".o", cfile->fullname);
32 return compile_object(m, cfile->fullname, ccan_dir, compiler, flags,
33 cfile->compiled[ctype], output);
36 static void compile_test_helpers(struct manifest *m,
37 unsigned int *timeleft,
40 enum compile_type ctype)
43 bool errors = false, warnings = false;
45 if (list_empty(&m->other_test_c_files))
50 list_for_each(&m->other_test_c_files, i, list) {
53 if (!compile(m, i, flags, ctype, &cmdout)) {
55 score_file_error(score, i, 0, "Compile failed:\n%s",
57 } else if (!streq(cmdout, "")) {
59 score_file_error(score, i, 0,
60 "Compile gave warnings:\n%s", cmdout);
66 score->score = score->total - warnings;
70 static void do_compile_test_helpers(struct manifest *m,
71 unsigned int *timeleft,
74 compile_test_helpers(m, timeleft, score, cflags, COMPILE_NORMAL);
77 struct ccanlint tests_helpers_compile = {
78 .key = "tests_helpers_compile",
79 .name = "Module test helper objects compile",
80 .check = do_compile_test_helpers,
82 .needs = "depends_build tests_exist"
85 REGISTER_TEST(tests_helpers_compile);
87 static const char *features_reduced(struct manifest *m)
89 if (features_were_reduced)
91 return "No features to turn off";
94 static void do_compile_test_helpers_without_features(struct manifest *m,
95 unsigned int *timeleft,
100 flags = talloc_asprintf(score, "%s %s", cflags,
101 REDUCE_FEATURES_FLAGS);
103 compile_test_helpers(m, timeleft, score, flags, COMPILE_NOFEAT);
106 struct ccanlint tests_helpers_compile_without_features = {
107 .key = "tests_helpers_compile_without_features",
108 .name = "Module tests helpers compile (without features)",
109 .check = do_compile_test_helpers_without_features,
110 .can_run = features_reduced,
111 .needs = "depends_build_without_features tests_exist"
113 REGISTER_TEST(tests_helpers_compile_without_features);