X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Frun_tests_valgrind.c;h=4b425ea23ba59d7baa3d689ddbbd58355596af8f;hp=47d93c578efd4c69e5d6f3a667271af6c39df813;hb=aba65f26a9cbc9b9cb3eb493731f83bca487d67f;hpb=39323f37b0209c24f5be4b4c7f119d6019912541 diff --git a/tools/ccanlint/tests/run_tests_valgrind.c b/tools/ccanlint/tests/run_tests_valgrind.c index 47d93c57..4b425ea2 100644 --- a/tools/ccanlint/tests/run_tests_valgrind.c +++ b/tools/ccanlint/tests/run_tests_valgrind.c @@ -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 --error-exitcode=0 true"); if (output) return talloc_asprintf(m, "No valgrind support: %s", output); @@ -30,28 +31,22 @@ 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; struct ccan_file *i; char *cmdout; - char *olddir; - - /* We run tests in the module directory, so any paths - * referenced can all be module-local. */ - olddir = talloc_getcwd(m); - if (!olddir) - err(1, "Could not save cwd"); - if (chdir(m->dir) != 0) - err(1, "Could not chdir to %s", m->dir); list_head_init(list); list_for_each(&m->run_tests, i, list) { run_tests_vg.total_score++; - /* FIXME: timeout here */ - cmdout = run_command(m, "valgrind -q %s", i->compiled); + cmdout = run_command(m, timeleft, + "valgrind -q --error-exitcode=100 %s", + i->compiled); if (cmdout) { res = talloc(list, struct run_tests_result); res->file = i; @@ -62,8 +57,9 @@ static void *do_run_tests_vg(struct manifest *m) list_for_each(&m->api_tests, i, list) { run_tests_vg.total_score++; - /* FIXME: timeout here */ - cmdout = run_command(m, "valgrind -q %s", i->compiled); + cmdout = run_command(m, timeleft, + "valgrind -q --error-exitcode=100 %s", + i->compiled); if (cmdout) { res = talloc(list, struct run_tests_result); res->file = i; @@ -77,9 +73,6 @@ static void *do_run_tests_vg(struct manifest *m) list = NULL; } - if (chdir(olddir) != 0) - err(1, "Could not chdir to %s", olddir); - return list; } @@ -107,6 +100,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 +115,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,