65728fc8f1fee779de2163175a880e035b1ff714
[ccan] / tools / ccanlint / tests / depends_build_without_features.c
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 <sys/types.h>
6 #include <sys/stat.h>
7 #include <fcntl.h>
8 #include <unistd.h>
9 #include <limits.h>
10 #include <errno.h>
11 #include <stdlib.h>
12 #include <stdio.h>
13 #include <err.h>
14 #include <string.h>
15 #include <ctype.h>
16 #include "../compulsory_tests/build.h"
17
18 static const char *can_build(struct manifest *m)
19 {
20         if (safe_mode)
21                 return "Safe mode enabled";
22         return NULL;
23 }
24
25 static void check_depends_built_without_features(struct manifest *m,
26                                                  bool keep,
27                                                  unsigned int *timeleft,
28                                                  struct score *score)
29 {
30         struct manifest *i;
31         char *flags;
32
33         flags = talloc_asprintf(score, "%s -I.", cflags);
34
35         list_for_each(&m->deps, i, list) {
36                 char *errstr = build_submodule(i, flags, COMPILE_NOFEAT);
37
38                 if (errstr) {
39                         score->error = talloc_asprintf(score,
40                                                        "Dependency %s"
41                                                        " did not build:\n%s",
42                                                        i->basename, errstr);
43                         return;
44                 }
45         }
46
47         score->pass = true;
48         score->score = score->total;
49 }
50
51 struct ccanlint depends_build_without_features = {
52         .key = "depends_build_without_features",
53         .name = "Module's CCAN dependencies can be found or built (reduced features)",
54         .check = check_depends_built_without_features,
55         .can_run = can_build,
56         .needs = "depends_exist"
57 };
58
59 REGISTER_TEST(depends_build_without_features);