summaryrefslogtreecommitdiff
path: root/tools/ccanlint/tests/depends_build_without_features.c
blob: f9f582aff79aada824d8d05465634b20506fd136 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <tools/ccanlint/ccanlint.h>
#include <tools/tools.h>
#include <ccan/str/str.h>
#include <ccan/foreach/foreach.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <limits.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <err.h>
#include <string.h>
#include <ctype.h>
#include "reduce_features.h"
#include "build.h"

static const char *can_build(struct manifest *m)
{
	if (safe_mode)
		return "Safe mode enabled";
	return NULL;
}

static void check_depends_built_without_features(struct manifest *m,
						 unsigned int *timeleft,
						 struct score *score)
{
	struct list_head *list;
	struct manifest *i;
	char *flags;

	flags = tal_fmt(score, "%s %s", cflags, REDUCE_FEATURES_FLAGS);

	foreach_ptr(list, &m->deps, &m->test_deps) {
		list_for_each(list, i, list) {
			char *errstr = build_submodule(i, flags,
						       COMPILE_NOFEAT);

			if (errstr) {
				score->error = tal_fmt(score,
						       "Dependency %s"
						       " did not build:\n%s",
						       i->modname,
						       errstr);
				return;
			}
		}
	}

	score->pass = true;
	score->score = score->total;
}

struct ccanlint depends_build_without_features = {
	.key = "depends_build_without_features",
	.name = "Module's CCAN dependencies can be found or built (reduced features)",
	.check = check_depends_built_without_features,
	.can_run = can_build,
	.needs = "depends_build reduce_features"
};

REGISTER_TEST(depends_build_without_features);