X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Ftests_pass.c;h=cb093264c74ba7d2a3500c49fe6b2151f6518395;hb=49a1a4366fdcea418582a97cb0bf700373b89868;hp=f90b5858f236bf41bd0ef6d0298e05d13e5f8707;hpb=728d98e8e44abcacbe9bfcd89762de2beda72698;p=ccan diff --git a/tools/ccanlint/tests/tests_pass.c b/tools/ccanlint/tests/tests_pass.c index f90b5858..cb093264 100644 --- a/tools/ccanlint/tests/tests_pass.c +++ b/tools/ccanlint/tests/tests_pass.c @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include #include @@ -36,19 +36,19 @@ static const char *can_run(struct manifest *m) 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; } -static bool run_test(void *ctx, +static void run_test(void *ctx, struct manifest *m, - unsigned int *timeleft, char **cmdout, + unsigned int *timeleft, struct ccan_file *i) { if (do_valgrind) { @@ -60,49 +60,54 @@ static bool 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]); - talloc_set_destructor(i->valgrind_log, - unlink_file_destructor); - - return run_command(ctx, timeleft, cmdout, - "valgrind -q" - " --leak-check=full" - " --log-fd=3 %s %s" - " 3> %s", - options, - i->compiled[COMPILE_NORMAL], - i->valgrind_log); + + 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; } } - return run_command(m, timeleft, cmdout, "%s", - i->compiled[COMPILE_NORMAL]); + run_command_async(i, *timeleft, "%s", + i->compiled[COMPILE_NORMAL]); } static void do_run_tests(struct manifest *m, - bool keep, unsigned int *timeleft, struct score *score) { struct list_head *list; struct ccan_file *i; char *cmdout; + bool ok; score->total = 0; foreach_ptr(list, &m->run_tests, &m->api_tests) { list_for_each(list, i, list) { score->total++; if (verbose >= 2) - printf(" %s\n", i->name); - if (run_test(score, m, timeleft, &cmdout, i)) - score->score++; - else - score_file_error(score, i, 0, "%s", cmdout); + printf(" %s...\n", i->name); + run_test(score, m, timeleft, i); } } + while ((i = collect_command(&ok, &cmdout)) != NULL) { + if (!ok) + score_file_error(score, i, 0, "%s", cmdout); + else + score->score++; + if (verbose >= 2) + printf(" ...%s\n", i->name); + } + if (score->score == score->total) score->pass = true; } @@ -121,8 +126,8 @@ 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]); + command = tal_fmt(m, "gdb -ex 'break tap.c:139' -ex 'run' %s", + first->file->compiled[COMPILE_NORMAL]); if (system(command)) doesnt_matter(); }