+static const char *concat(struct score *score, char *bits[])
+{
+ unsigned int i;
+ char *ret = talloc_strdup(score, "");
+
+ for (i = 0; bits[i]; i++) {
+ if (i)
+ ret = talloc_append_string(ret, " ");
+ ret = talloc_append_string(ret, bits[i]);
+ }
+ return ret;
+}
+
+static void run_test(void *ctx,
+ struct manifest *m,
+ unsigned int *timeleft,
+ struct ccan_file *i)
+{
+ if (do_valgrind) {
+ const char *options;
+ options = concat(ctx,
+ per_file_options(&tests_pass_valgrind, i));
+
+ if (!streq(options, "FAIL")) {
+ /* FIXME: Valgrind's output sucks. XML is
+ * unreadable by humans *and* doesn't support
+ * children reporting. */
+ i->valgrind_log = talloc_asprintf(m,
+ "%s.valgrind-log",
+ i->compiled[COMPILE_NORMAL]);
+
+ run_command_async(i, *timeleft,
+ "valgrind -q"
+ " --leak-check=full"
+ " --log-fd=3 %s %s"
+ " 3> %s",
+ options,
+ i->compiled[COMPILE_NORMAL],
+ i->valgrind_log);
+ return;
+ }
+ }
+
+ run_command_async(i, *timeleft, "%s",
+ i->compiled[COMPILE_NORMAL]);
+}
+