]> git.ozlabs.org Git - ccan/blob - tools/ccanlint/tests/depends_build_without_features.c
ccanlint: clean up reduced feature handling.
[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 "../compulsory_tests/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                                                  bool keep,
28                                                  unsigned int *timeleft,
29                                                  struct score *score)
30 {
31         struct manifest *i;
32         char *flags;
33
34         flags = talloc_asprintf(score, "%s %s", cflags,
35                                 REDUCE_FEATURES_FLAGS);
36
37         list_for_each(&m->deps, i, list) {
38                 char *errstr = build_submodule(i, flags, COMPILE_NOFEAT);
39
40                 if (errstr) {
41                         score->error = talloc_asprintf(score,
42                                                        "Dependency %s"
43                                                        " did not build:\n%s",
44                                                        i->basename, errstr);
45                         return;
46                 }
47         }
48
49         score->pass = true;
50         score->score = score->total;
51 }
52
53 struct ccanlint depends_build_without_features = {
54         .key = "depends_build_without_features",
55         .name = "Module's CCAN dependencies can be found or built (reduced features)",
56         .check = check_depends_built_without_features,
57         .can_run = can_build,
58         .needs = "depends_exist"
59 };
60
61 REGISTER_TEST(depends_build_without_features);