1 #include <tools/ccanlint/ccanlint.h>
2 #include <tools/tools.h>
3 #include <ccan/talloc/talloc.h>
4 #include <ccan/str/str.h>
5 #include <ccan/str_talloc/str_talloc.h>
6 #include <ccan/foreach/foreach.h>
19 static bool has_dep(struct manifest *m, const char *depname)
23 /* We can include ourselves, of course. */
24 if (streq(depname, m->basename))
27 list_for_each(&m->deps, i, list) {
28 if (streq(i->basename, depname))
34 static void check_depends_accurate(struct manifest *m,
35 unsigned int *timeleft, struct score *score)
37 struct list_head *list;
39 foreach_ptr(list, &m->c_files, &m->h_files,
40 &m->run_tests, &m->api_tests,
41 &m->compile_ok_tests, &m->compile_fail_tests,
42 &m->other_test_c_files) {
45 list_for_each(list, f, list) {
47 char **lines = get_ccan_file_lines(f);
48 struct line_info *li = get_ccan_line_info(f);
50 for (i = 0; lines[i]; i++) {
52 if (!strreg(f, lines[i],
53 "^[ \t]*#[ \t]*include[ \t]*[<\"]"
54 "ccan/+([^/]+)/", &mod))
60 /* FIXME: we can't be sure about
61 * conditional includes, so don't
64 score_file_error(score, f, i+1,
65 "%s not listed in _info",
73 score->score = score->total;
78 struct ccanlint depends_accurate = {
79 .key = "depends_accurate",
80 .name = "Module's CCAN dependencies are the only CCAN files #included",
81 .check = check_depends_accurate,
82 .needs = "depends_exist"
85 REGISTER_TEST(depends_accurate);