Commit 939fab34 authored by Rusty Russell's avatar Rusty Russell

ccanlint: clean up reduced feature handling.

Putting the reduced config.h in the current directory means that it's
actually being picked up by other tests, such as the string checks.
So move it to a sub-directory where we need an explicit -I.

We also fix the dependencies, so that "--target
tests_pass_without_features" works.
parent 728d98e8
......@@ -13,6 +13,7 @@
#include <err.h>
#include <string.h>
#include <ctype.h>
#include "reduce_features.h"
#include "../compulsory_tests/build.h"
static const char *can_build(struct manifest *m)
......@@ -30,7 +31,8 @@ static void check_depends_built_without_features(struct manifest *m,
struct manifest *i;
char *flags;
flags = talloc_asprintf(score, "%s -I.", cflags);
flags = talloc_asprintf(score, "%s %s", cflags,
REDUCE_FEATURES_FLAGS);
list_for_each(&m->deps, i, list) {
char *errstr = build_submodule(i, flags, COMPILE_NOFEAT);
......
#include <tools/ccanlint/ccanlint.h>
#include <ccan/talloc/talloc.h>
#include "reduce_features.h"
#include "../compulsory_tests/build.h"
static void check_objs_build_without_features(struct manifest *m,
......@@ -7,7 +8,8 @@ static void check_objs_build_without_features(struct manifest *m,
unsigned int *timeleft,
struct score *score)
{
const char *flags = talloc_asprintf(score, "-I. %s", cflags);
const char *flags = talloc_asprintf(score, "%s %s",
REDUCE_FEATURES_FLAGS, cflags);
build_objects(m, keep, score, flags, COMPILE_NOFEAT);
}
......
......@@ -160,11 +160,14 @@ static void do_reduce_features(struct manifest *m,
hdr = talloc_asprintf_append
(hdr, "#undef %s\n#define %s 0\n", sym, sym);
}
fd = open("config.h", O_EXCL|O_CREAT|O_RDWR, 0600);
if (mkdir("reduced-features", 0700) != 0)
err(1, "Creating reduced-features directory");
fd = open("reduced-features/config.h", O_EXCL|O_CREAT|O_RDWR, 0600);
if (fd < 0)
err(1, "Creating config.h");
err(1, "Creating reduced-features/config.h");
if (!write_all(fd, hdr, strlen(hdr)))
err(1, "Writing config.h");
err(1, "Writing reduced-features/config.h");
close(fd);
features_were_reduced = true;
}
......
#ifndef CCANLINT_REDUCE_FEATURES_H
#define CCANLINT_REDUCE_FEATURES_H
extern bool features_were_reduced;
#define REDUCE_FEATURES_FLAGS "-Ireduced-features"
#endif /* CCANLINT_REDUCE_FEATURES_H */
......@@ -78,7 +78,8 @@ static bool compile(const void *ctx,
flags = talloc_asprintf(ctx, "%s%s%s",
fail ? "-DFAIL " : "",
cflags,
ctype == COMPILE_NOFEAT ? " -I." : "");
ctype == COMPILE_NOFEAT
? " "REDUCE_FEATURES_FLAGS : "");
fname = maybe_temp_file(ctx, "", keep, file->fullname);
if (!compile_and_link(ctx, file->fullname, ccan_dir,
......@@ -192,6 +193,6 @@ struct ccanlint tests_compile_without_features = {
.name = "Module tests compile (without features)",
.check = do_compile_tests_without_features,
.can_run = features_reduced,
.needs = "tests_helpers_compile_without_features reduce_features"
.needs = "tests_helpers_compile_without_features objects_build_without_features"
};
REGISTER_TEST(tests_compile_without_features);
......@@ -102,7 +102,8 @@ static void do_compile_test_helpers_without_features(struct manifest *m,
{
char *flags;
flags = talloc_asprintf(score, "%s -I.", cflags);
flags = talloc_asprintf(score, "%s %s", cflags,
REDUCE_FEATURES_FLAGS);
compile_test_helpers(m, keep, timeleft, score, flags,
COMPILE_NOFEAT);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment