ccanlint: fix _info option handling
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 18 Jan 2011 01:47:17 +0000 (12:17 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 18 Jan 2011 01:47:17 +0000 (12:17 +1030)
Two places were using a bogus ccanlint struct: the side-effect was
that valgrind options didn't work, nor did license fixups.

Make REGISTER_TEST do the extern declaration, and remove the bogus
ones.

tools/ccanlint/ccanlint.h
tools/ccanlint/tests/info_documentation_exists.c
tools/ccanlint/tests/license_exists.c
tools/ccanlint/tests/tests_exist.c
tools/ccanlint/tests/tests_pass_valgrind.c

index 40cb4195ffc65263ee2ef2bbb936fa3fd9e31707..41aaec9353ae9b1d09bf063f38b4e9cd24507881 100644 (file)
@@ -4,7 +4,7 @@
 #include <stdbool.h>
 #include "../doc_extract.h"
 
 #include <stdbool.h>
 #include "../doc_extract.h"
 
-#define REGISTER_TEST(name, ...) 
+#define REGISTER_TEST(name, ...) extern struct ccanlint name
 
 /* 0 == Describe failed tests.
    1 == Describe results for partial failures.
 
 /* 0 == Describe failed tests.
    1 == Describe results for partial failures.
index 108f57f1e935255ff9bf00e48c611e0b68f523b7..9caa966f15ef09cc87d16724d6ba460454b2ec40 100644 (file)
@@ -15,7 +15,7 @@
 #include <ccan/noerr/noerr.h>
 #include <ccan/grab_file/grab_file.h>
 
 #include <ccan/noerr/noerr.h>
 #include <ccan/grab_file/grab_file.h>
 
-extern struct ccanlint info_documentation_exists;
+REGISTER_TEST(info_documentation_exists);
 
 static void create_info_template_doc(struct manifest *m, struct score *score)
 {
 
 static void create_info_template_doc(struct manifest *m, struct score *score)
 {
@@ -101,4 +101,3 @@ struct ccanlint info_documentation_exists = {
        .needs = "info_exists"
 };
 
        .needs = "info_exists"
 };
 
-REGISTER_TEST(info_documentation_exists);
index 72461bec6d40ab4b3534385dc1c1c3bc932c3c9f..1ae27dd35266e6a7ca1fd9f55626dae69587a37e 100644 (file)
@@ -11,7 +11,7 @@
 #include <ccan/talloc/talloc.h>
 #include <ccan/str/str.h>
 
 #include <ccan/talloc/talloc.h>
 #include <ccan/str/str.h>
 
-struct ccanlint has_license;
+REGISTER_TEST(license_exists);
 
 static struct doc_section *find_license(const struct manifest *m)
 {
 
 static struct doc_section *find_license(const struct manifest *m)
 {
@@ -114,7 +114,7 @@ static void check_has_license(struct manifest *m,
                        score->error = talloc_strdup(score,
                                                     "LICENSE does not exist");
                        if (expected)
                        score->error = talloc_strdup(score,
                                                     "LICENSE does not exist");
                        if (expected)
-                               has_license.handle = handle_license_link;
+                               license_exists.handle = handle_license_link;
                        return;
                }
                err(1, "readlink on %s", license);
                        return;
                }
                err(1, "readlink on %s", license);
@@ -156,5 +156,3 @@ struct ccanlint license_exists = {
        .check = check_has_license,
        .needs = "info_exists"
 };
        .check = check_has_license,
        .needs = "info_exists"
 };
-
-REGISTER_TEST(license_exists);
index 64b2691e0eaceba570e0e7595cda0a543b3e134d..86f7ef27e816e902c406c2a92aec44dba26a20dc 100644 (file)
@@ -10,7 +10,7 @@
 #include <err.h>
 #include <ccan/talloc/talloc.h>
 
 #include <err.h>
 #include <ccan/talloc/talloc.h>
 
-extern struct ccanlint tests_exist;
+REGISTER_TEST(tests_exist);
 
 static void handle_no_tests(struct manifest *m, struct score *score)
 {
 
 static void handle_no_tests(struct manifest *m, struct score *score)
 {
@@ -135,4 +135,3 @@ struct ccanlint tests_exist = {
        .needs = ""
 };
 
        .needs = ""
 };
 
-REGISTER_TEST(tests_exist);
index 4c4338b6c1c6d3ab20ad9e93a61cdf3da8361c78..33eb6b1f6f083ee258b06460f5b1593357405eec 100644 (file)
@@ -17,7 +17,7 @@
 #include <string.h>
 #include <ctype.h>
 
 #include <string.h>
 #include <ctype.h>
 
-struct ccanlint run_tests_vg;
+REGISTER_TEST(tests_pass_valgrind);
 
 /* Note: we already test safe_mode in run_tests.c */
 static const char *can_run_vg(struct manifest *m)
 
 /* Note: we already test safe_mode in run_tests.c */
 static const char *can_run_vg(struct manifest *m)
@@ -115,8 +115,8 @@ static void do_run_tests_vg(struct manifest *m,
                                    " --leak-check=full"
                                    " --log-fd=3 %s %s"
                                    " 3> valgrind.log",
                                    " --leak-check=full"
                                    " --log-fd=3 %s %s"
                                    " 3> valgrind.log",
-                                   run_tests_vg.options ?
-                                   run_tests_vg.options : "",
+                                   tests_pass_valgrind.options ?
+                                   tests_pass_valgrind.options : "",
                                    i->compiled);
                        output = grab_file(i, "valgrind.log", NULL);
                        if (!output || output[0] == '\0') {
                                    i->compiled);
                        output = grab_file(i, "valgrind.log", NULL);
                        if (!output || output[0] == '\0') {
@@ -173,8 +173,8 @@ static void run_under_debugger_vg(struct manifest *m, struct score *score)
 
        first = list_top(&score->per_file_errors, struct file_error, list);
        command = talloc_asprintf(m, "valgrind --db-attach=yes%s %s",
 
        first = list_top(&score->per_file_errors, struct file_error, list);
        command = talloc_asprintf(m, "valgrind --db-attach=yes%s %s",
-                                 run_tests_vg.options ?
-                                 run_tests_vg.options : "",
+                                 tests_pass_valgrind.options ?
+                                 tests_pass_valgrind.options : "",
                                  first->file->compiled);
        if (system(command))
                doesnt_matter();
                                  first->file->compiled);
        if (system(command))
                doesnt_matter();
@@ -190,8 +190,6 @@ struct ccanlint tests_pass_valgrind = {
        .needs = "tests_pass"
 };
 
        .needs = "tests_pass"
 };
 
-REGISTER_TEST(tests_pass_valgrind);
-
 struct ccanlint tests_pass_valgrind_noleaks = {
        .key = "tests_pass_valgrind_noleaks",
        .name = "Module's run and api tests have no memory leaks",
 struct ccanlint tests_pass_valgrind_noleaks = {
        .key = "tests_pass_valgrind_noleaks",
        .name = "Module's run and api tests have no memory leaks",