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