]> git.ozlabs.org Git - ccan/blob - tools/ccanlint/tests/depends_build_without_features.c
533f4f318ce869cfb48f83882aa713bea5457dfa
[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 "reduce_features.h"
17 #include "build.h"
18
19 static const char *can_build(struct manifest *m)
20 {
21         if (safe_mode)
22                 return "Safe mode enabled";
23         return NULL;
24 }
25
26 static void check_depends_built_without_features(struct manifest *m,
27                                                  unsigned int *timeleft,
28                                                  struct score *score)
29 {
30         struct manifest *i;
31         char *flags;
32
33         flags = talloc_asprintf(score, "%s %s", cflags,
34                                 REDUCE_FEATURES_FLAGS);
35
36         list_for_each(&m->deps, i, list) {
37                 char *errstr = build_submodule(i, flags, COMPILE_NOFEAT);
38
39                 if (errstr) {
40                         score->error = talloc_asprintf(score,
41                                                        "Dependency %s"
42                                                        " did not build:\n%s",
43                                                        i->basename, errstr);
44                         return;
45                 }
46         }
47
48         score->pass = true;
49         score->score = score->total;
50 }
51
52 struct ccanlint depends_build_without_features = {
53         .key = "depends_build_without_features",
54         .name = "Module's CCAN dependencies can be found or built (reduced features)",
55         .check = check_depends_built_without_features,
56         .can_run = can_build,
57         .needs = "depends_build reduce_features"
58 };
59
60 REGISTER_TEST(depends_build_without_features);