From 156dfda864bc2a0fe2ba63f69c22864b2348876f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 25 Sep 2009 15:01:46 +0930 Subject: [PATCH] ccanlint: don't use total_score to separate kinds of tests; we have subdirs --- .bzrignore | 3 ++- tools/ccanlint/Makefile | 19 +++++++++++-------- tools/ccanlint/ccanlint.c | 21 ++++++++++----------- tools/ccanlint/ccanlint.h | 5 +++-- tools/ccanlint/tests/build_objs.c | 2 -- tools/ccanlint/tests/compile_tests.c | 2 -- tools/ccanlint/tests/run_tests.c | 2 -- tools/tools.h | 2 +- 8 files changed, 27 insertions(+), 29 deletions(-) diff --git a/.bzrignore b/.bzrignore index 3dfba6e9..10cbbc33 100644 --- a/.bzrignore +++ b/.bzrignore @@ -6,7 +6,8 @@ tools/doc_extract tools/namespacize tools/run_tests tools/ccanlint/ccanlint -tools/ccanlint/generated-init-tests +tools/ccanlint/generated-compulsory-tests +tools/ccanlint/generated-normal-tests inter-depends test-depends lib-depends diff --git a/tools/ccanlint/Makefile b/tools/ccanlint/Makefile index a99a6aeb..dcbd6f9c 100644 --- a/tools/ccanlint/Makefile +++ b/tools/ccanlint/Makefile @@ -1,6 +1,6 @@ -TEST_CFILES := $(wildcard tools/ccanlint/compulsory_tests/*.c) \ - $(wildcard tools/ccanlint/tests/*.c) -TEST_OBJS := $(TEST_CFILES:.c=.o) +COMPULSORY_TEST_CFILES := $(wildcard tools/ccanlint/compulsory_tests/*.c) +NORMAL_TEST_CFILES := $(wildcard tools/ccanlint/tests/*.c) +TEST_OBJS := $(NORMAL_TEST_CFILES:.c=.o) $(COMPULSORY_TEST_CFILES:.c=.o) CORE_OBJS := tools/ccanlint/ccanlint.o \ tools/ccanlint/file_analysis.o \ @@ -13,17 +13,20 @@ CORE_OBJS := tools/ccanlint/ccanlint.o \ OBJS := $(CORE_OBJS) $(TEST_OBJS) # FIXME: write a trivial C program to do this -tools/ccanlint/generated-init-tests: $(TEST_CFILES) - cat $(TEST_CFILES) | grep ^REGISTER_TEST > $@ +tools/ccanlint/generated-normal-tests: $(NORMAL_TEST_CFILES) + cat $^ | grep ^REGISTER_TEST > $@ +tools/ccanlint/generated-compulsory-tests: $(COMPULSORY_TEST_CFILES) + cat $^ | grep ^REGISTER_TEST > $@ -$(TEST_OBJS): tools/ccanlint/generated-init-tests +$(TEST_OBJS): tools/ccanlint/generated-normal-tests tools/ccanlint/generated-compulsory-tests # Otherwise, ccanlint.c et al. may fail to build -$(CORE_OBJS): tools/ccanlint/generated-init-tests +$(CORE_OBJS): tools/ccanlint/generated-normal-tests tools/ccanlint/generated-compulsory-tests tools/ccanlint/ccanlint: $(OBJS) ccanlint-clean: - $(RM) tools/ccanlint/generated-init-tests + $(RM) tools/ccanlint/generated-compulsory-tests + $(RM) tools/ccanlint/generated-normal-tests $(RM) tools/ccanlint/ccanlint diff --git a/tools/ccanlint/ccanlint.c b/tools/ccanlint/ccanlint.c index be6829c0..1399edcb 100644 --- a/tools/ccanlint/ccanlint.c +++ b/tools/ccanlint/ccanlint.c @@ -160,16 +160,13 @@ static bool run_test(struct ccanlint *i, return false; } -static void register_test(struct ccanlint *test, ...) +static void register_test(struct list_head *h, struct ccanlint *test, ...) { va_list ap; struct ccanlint *depends; struct dependent *dchild; - if (!test->total_score) - list_add(&compulsory_tests, &test->list); - else - list_add(&normal_tests, &test->list); + list_add(h, &test->list); va_start(ap, test); /* Careful: we might have been initialized by a dependent. */ @@ -211,8 +208,11 @@ static void init_tests(void) const struct ccanlint *i; #undef REGISTER_TEST -#define REGISTER_TEST(name, ...) register_test(&name, __VA_ARGS__) -#include "generated-init-tests" +#define REGISTER_TEST(name, ...) register_test(&normal_tests, &name, __VA_ARGS__) +#include "generated-normal-tests" +#undef REGISTER_TEST +#define REGISTER_TEST(name, ...) register_test(&compulsory_tests, &name, __VA_ARGS__) +#include "generated-compulsory-tests" if (!verbose) return; @@ -289,10 +289,9 @@ int main(int argc, char *argv[]) if (verbose) printf("\nNormal tests:\n"); score = total_score = 0; - while ((i = get_next_test(&normal_tests)) != NULL) { - if (i->total_score) - run_test(i, summary, &score, &total_score, m); - } + while ((i = get_next_test(&normal_tests)) != NULL) + run_test(i, summary, &score, &total_score, m); + printf("Total score: %u/%u\n", score, total_score); return 0; } diff --git a/tools/ccanlint/ccanlint.h b/tools/ccanlint/ccanlint.h index 271fba95..c4ae191f 100644 --- a/tools/ccanlint/ccanlint.h +++ b/tools/ccanlint/ccanlint.h @@ -5,7 +5,8 @@ #include "../doc_extract.h" #define REGISTER_TEST(name, ...) extern struct ccanlint name -#include "generated-init-tests" +#include "generated-compulsory-tests" +#include "generated-normal-tests" #undef REGISTER_TEST #define REGISTER_TEST(name, ...) @@ -41,7 +42,7 @@ struct ccanlint { /* Unique name of test */ const char *name; - /* Total score that this test is worth. 0 means compulsory tests. */ + /* Total score that this test is worth. */ unsigned int total_score; /* Can we run this test? Return string explaining why, if not. */ diff --git a/tools/ccanlint/tests/build_objs.c b/tools/ccanlint/tests/build_objs.c index dc6e4d35..d932ec74 100644 --- a/tools/ccanlint/tests/build_objs.c +++ b/tools/ccanlint/tests/build_objs.c @@ -49,7 +49,6 @@ static void *check_objs_build(struct manifest *m) struct ccan_file *i; /* One point for each obj file. */ - build_objs.total_score = 0; list_for_each(&m->c_files, i, list) build_objs.total_score++; @@ -71,7 +70,6 @@ static const char *describe_objs_build(struct manifest *m, void *check_result) struct ccanlint build_objs = { .name = "Module object files can be built", - .total_score = 1, .check = check_objs_build, .describe = describe_objs_build, .can_run = can_build, diff --git a/tools/ccanlint/tests/compile_tests.c b/tools/ccanlint/tests/compile_tests.c index c9ace30d..7f0338a4 100644 --- a/tools/ccanlint/tests/compile_tests.c +++ b/tools/ccanlint/tests/compile_tests.c @@ -83,7 +83,6 @@ static void *do_compile_tests(struct manifest *m) list_head_init(list); - compile_tests.total_score = 0; list_for_each(&m->compile_ok_tests, i, list) { compile_tests.total_score++; cmdout = compile(list, m, i, false, false); @@ -178,7 +177,6 @@ static const char *describe_compile_tests(struct manifest *m, struct ccanlint compile_tests = { .name = "Compile tests succeed", - .total_score = 1, .score = score_compile_tests, .check = do_compile_tests, .describe = describe_compile_tests, diff --git a/tools/ccanlint/tests/run_tests.c b/tools/ccanlint/tests/run_tests.c index e996c4e2..875ba758 100644 --- a/tools/ccanlint/tests/run_tests.c +++ b/tools/ccanlint/tests/run_tests.c @@ -29,7 +29,6 @@ static void *do_run_tests(struct manifest *m) list_head_init(list); - run_tests.total_score = 0; list_for_each(&m->run_tests, i, list) { char *testout; run_tests.total_score++; @@ -80,7 +79,6 @@ static const char *describe_run_tests(struct manifest *m, struct ccanlint run_tests = { .name = "run and api tests run successfully", - .total_score = 1, .score = score_run_tests, .check = do_run_tests, .describe = describe_run_tests, diff --git a/tools/tools.h b/tools/tools.h index 9fd1e1f6..431a018a 100644 --- a/tools/tools.h +++ b/tools/tools.h @@ -9,7 +9,7 @@ #define SPACE_CHARS " \f\n\r\t\v" /* FIXME: Remove some -I */ -#define CFLAGS "-O3 -Wall -Wundef -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Werror -Iccan/ -I. -I../.." +#define CFLAGS "-O3 -Wall -Wundef -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Werror -Iccan/ -I.. -I../.." /* This actually compiles and runs the info file to get dependencies. */ char **get_deps(const void *ctx, const char *dir, const char *name, -- 2.39.2