]> git.ozlabs.org Git - ccan/blobdiff - tools/ccanlint/tests/run_tests_valgrind.c
ccanlint: show example we actually compiled when we report warnings.
[ccan] / tools / ccanlint / tests / run_tests_valgrind.c
index e0c2ab9197db29d8fbe60c2194d1cbbd9e68e4d1..310e89710829893aa15044870691ff4256408d19 100644 (file)
 static const char *can_run_vg(struct manifest *m)
 {
        unsigned int timeleft = default_timeout_ms;
-       char *output = run_command(m, &timeleft,
-                                  "valgrind -q --error-exitcode=0 true");
+       char *output;
 
-       if (output)
+       if (!run_command(m, &timeleft, &output,
+                        "valgrind -q --error-exitcode=0 true"))
                return talloc_asprintf(m, "No valgrind support: %s", output);
        return NULL;
 }
@@ -41,14 +41,15 @@ static void do_run_tests_vg(struct manifest *m,
        foreach_ptr(list, &m->run_tests, &m->api_tests) {
                list_for_each(list, i, list) {
                        score->total++;
-                       cmdout = run_command(m, timeleft,
-                                    "valgrind -q --error-exitcode=100 %s",
-                                    i->compiled);
-                       if (cmdout) {
-                               score->error = "Running under valgrind";
-                               score_file_error(score, i, 0, cmdout);
-                       } else
+                       if (run_command(score, timeleft, &cmdout,
+                                       "valgrind -q --error-exitcode=100%s %s",
+                                       run_tests_vg.options ?
+                                       run_tests_vg.options : "",
+                                       i->compiled)) {
                                score->score++;
+                       } else {
+                               score_file_error(score, i, 0, cmdout);
+                       }
                }
        }
 
@@ -79,7 +80,8 @@ struct ccanlint run_tests_vg = {
        .name = "Module's run and api tests succeed under valgrind",
        .can_run = can_run_vg,
        .check = do_run_tests_vg,
-       .handle = run_under_debugger_vg
+       .handle = run_under_debugger_vg,
+       .takes_options = true
 };
 
 REGISTER_TEST(run_tests_vg, &run_tests, NULL);