ccanlint: Add -k option to keep results.
[ccan] / tools / ccanlint / tests / run_tests_valgrind.c
index 4f32ed6c630953373ca461f193a55ddf1484896e..233a719dfb3eddfec896eeda3daa8ec48ed6320e 100644 (file)
@@ -17,7 +17,8 @@
 /* Note: we already test safe_mode in run_tests.c */
 static const char *can_run_vg(struct manifest *m)
 {
-       char *output = run_command(m, "valgrind -q true");
+       unsigned int timeleft = default_timeout_ms;
+       char *output = run_command(m, &timeleft, "valgrind -q true");
 
        if (output)
                return talloc_asprintf(m, "No valgrind support: %s", output);
@@ -30,7 +31,9 @@ struct run_tests_result {
        const char *output;
 };
 
-static void *do_run_tests_vg(struct manifest *m)
+static void *do_run_tests_vg(struct manifest *m,
+                            bool keep,
+                            unsigned int *timeleft)
 {
        struct list_head *list = talloc(m, struct list_head);
        struct run_tests_result *res;
@@ -49,9 +52,9 @@ static void *do_run_tests_vg(struct manifest *m)
        list_head_init(list);
 
        list_for_each(&m->run_tests, i, list) {
-               run_tests.total_score++;
-               /* FIXME: timeout here */
-               cmdout = run_command(m, "valgrind -q %s", i->compiled);
+               run_tests_vg.total_score++;
+               cmdout = run_command(m, timeleft,
+                                    "valgrind -q %s", i->compiled);
                if (cmdout) {
                        res = talloc(list, struct run_tests_result);
                        res->file = i;
@@ -61,9 +64,9 @@ static void *do_run_tests_vg(struct manifest *m)
        }
 
        list_for_each(&m->api_tests, i, list) {
-               run_tests.total_score++;
-               /* FIXME: timeout here */
-               cmdout = run_command(m, "valgrind -q %s", i->compiled);
+               run_tests_vg.total_score++;
+               cmdout = run_command(m, timeleft,
+                                    "valgrind -q %s", i->compiled);
                if (cmdout) {
                        res = talloc(list, struct run_tests_result);
                        res->file = i;
@@ -87,7 +90,7 @@ static unsigned int score_run_tests_vg(struct manifest *m, void *check_result)
 {
        struct list_head *list = check_result;
        struct run_tests_result *i;
-       unsigned int score = run_tests.total_score;
+       unsigned int score = run_tests_vg.total_score;
 
        list_for_each(list, i, list)
                score--;
@@ -107,6 +110,9 @@ static const char *describe_run_tests_vg(struct manifest *m,
        return descrip;
 }
 
+/* Gcc's warn_unused_result is fascist bullshit. */
+#define doesnt_matter()
+
 static void run_under_debugger_vg(struct manifest *m, void *check_result)
 {
        struct list_head *list = check_result;
@@ -119,11 +125,13 @@ static void run_under_debugger_vg(struct manifest *m, void *check_result)
        first = list_top(list, struct run_tests_result, list);
        command = talloc_asprintf(m, "valgrind --db-attach=yes %s",
                                  first->file->compiled);
-       system(command);
+       if (system(command))
+               doesnt_matter();
 }
 
 struct ccanlint run_tests_vg = {
-       .name = "run and api tests under valgrind",
+       .key = "valgrind-tests",
+       .name = "Module's run and api tests succeed under valgrind",
        .score = score_run_tests_vg,
        .check = do_run_tests_vg,
        .describe = describe_run_tests_vg,