X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Ftests_pass.c;h=ba6103de2d50bf118b1952df3e7c28f66f16e7a2;hp=e1dfba6aee63534430895430cccaa183f63dcf90;hb=dfafd0a1f522277c9be5fc589885db38f706d108;hpb=af5b1a18948345c5f9f9abf4eda3ab9fe0aa9a9f diff --git a/tools/ccanlint/tests/tests_pass.c b/tools/ccanlint/tests/tests_pass.c index e1dfba6a..ba6103de 100644 --- a/tools/ccanlint/tests/tests_pass.c +++ b/tools/ccanlint/tests/tests_pass.c @@ -1,8 +1,9 @@ #include #include -#include +#include #include #include +#include #include #include #include @@ -17,6 +18,7 @@ #include "tests_pass.h" bool do_valgrind = false; +const char *valgrind_suppress = ""; static const char *can_run(struct manifest *m) { @@ -27,21 +29,30 @@ static const char *can_run(struct manifest *m) if (!is_excluded("tests_pass_valgrind") && run_command(m, &timeleft, &output, - "valgrind -q true")) + "valgrind -q true")) { + const char *sfile; + do_valgrind = true; + /* Check for suppressions file for all of CCAN. */ + sfile = path_join(m, ccan_dir, ".valgrind_suppressions"); + if (path_is_file(sfile)) + valgrind_suppress = tal_fmt(m, "--suppressions=%s", + sfile); + } + return NULL; } static const char *concat(struct score *score, char *bits[]) { unsigned int i; - char *ret = talloc_strdup(score, ""); + char *ret = tal_strdup(score, ""); for (i = 0; bits[i]; i++) { if (i) - ret = talloc_append_string(ret, " "); - ret = talloc_append_string(ret, bits[i]); + ret = tal_strcat(score, take(ret), " "); + ret = tal_strcat(score, take(ret), bits[i]); } return ret; } @@ -60,16 +71,16 @@ static void run_test(void *ctx, /* FIXME: Valgrind's output sucks. XML is * unreadable by humans *and* doesn't support * children reporting. */ - i->valgrind_log = talloc_asprintf(m, + i->valgrind_log = tal_fmt(m, "%s.valgrind-log", i->compiled[COMPILE_NORMAL]); run_command_async(i, *timeleft, "valgrind -q" " --leak-check=full" - " --log-fd=3 %s %s" + " --log-fd=3 %s %s %s" " 3> %s", - options, + valgrind_suppress, options, i->compiled[COMPILE_NORMAL], i->valgrind_log); return; @@ -126,10 +137,11 @@ static void run_under_debugger(struct manifest *m, struct score *score) if (!ask("Should I run the first failing test under the debugger?")) return; - command = talloc_asprintf(m, "gdb -ex 'break tap.c:139' -ex 'run' %s", - first->file->compiled[COMPILE_NORMAL]); - if (system(command)) + command = tal_fmt(m, "gdb -ex 'break tap.c:139' -ex 'run' %s", + first->file->compiled[COMPILE_NORMAL]); + if (system(command)) { doesnt_matter(); + } } struct ccanlint tests_pass = {