]> git.ozlabs.org Git - ccan/blobdiff - tools/ccanlint/tests/tests_pass_valgrind.c
ccanlint: fix _info option handling
[ccan] / tools / ccanlint / tests / tests_pass_valgrind.c
index 4365f2a60227bc1a259ad4671d23efa72f87f0e9..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)
@@ -52,11 +52,11 @@ static bool blank_line(const char *line)
 static char *get_leaks(const char *output, char **errs)
 {
        char *leaks = talloc_strdup(output, "");
 static char *get_leaks(const char *output, char **errs)
 {
        char *leaks = talloc_strdup(output, "");
-       unsigned int i, num;
-       char **lines = strsplit(output, output, "\n", &num);
+       unsigned int i;
+       char **lines = strsplit(output, output, "\n");
 
        *errs = talloc_strdup(output, "");
 
        *errs = talloc_strdup(output, "");
-       for (i = 0; i < num; i++) {
+       for (i = 0; i < talloc_array_length(lines) - 1; i++) {
                if (strstr(lines[i], " lost ")) {
                        /* A leak... */
                        if (strstr(lines[i], " definitely lost ")) {
                if (strstr(lines[i], " lost ")) {
                        /* A leak... */
                        if (strstr(lines[i], " definitely lost ")) {
@@ -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",