ccanlint: clean up reduced feature handling.
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 30 Aug 2011 04:31:25 +0000 (14:01 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 30 Aug 2011 04:31:25 +0000 (14:01 +0930)
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.

tools/ccanlint/tests/depends_build_without_features.c
tools/ccanlint/tests/objects_build_without_features.c
tools/ccanlint/tests/reduce_features.c
tools/ccanlint/tests/reduce_features.h
tools/ccanlint/tests/tests_compile.c
tools/ccanlint/tests/tests_helpers_compile.c

index 65728fc8f1fee779de2163175a880e035b1ff714..cf7185be0d80fc2f79aa5cf776663e0b7639eca9 100644 (file)
@@ -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);
index 8174541cd51271680dcff50d9a123489fdf73b33..477d3025ce3aaa2cabd3337c87e9bc2b09402f58 100644 (file)
@@ -1,5 +1,6 @@
 #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);
 }
 
index aaeba75170f78a7b33b60355f97292c7b7c61908..39a2bde067a96dbc0072514f5633eebff39974aa 100644 (file)
@@ -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;
 }
index f646941afed0d088de9d0df8bf6740bf3d4089bf..09f4c79822c5c328a00f3c1762499834237b3f9a 100644 (file)
@@ -1,4 +1,6 @@
 #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 */
index 2e7cd2640eec2a1022e50d00906294aee5825077..db5ea33e4f7467e9c9266674541625d71b8d1903 100644 (file)
@@ -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);
index d7c8f0ae75ccd7282c0c39726ee639f04f8a7ee1..baa5309f08c50a6c4c4b245452f382ee33376267 100644 (file)
@@ -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);