X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Fcompulsory_tests%2Frun_tests.c;h=2fd87a8c5c4978204926440aa4f6ef02c27cbdbf;hp=b3c1188de592f4eece24b81cfa45561dc0a83be3;hb=f952b88b36e3803370825fb43385f1a42aa24b64;hpb=5f44c8ca0eb66503db51e0df1b65ff173eb42f57 diff --git a/tools/ccanlint/compulsory_tests/run_tests.c b/tools/ccanlint/compulsory_tests/run_tests.c index b3c1188d..2fd87a8c 100644 --- a/tools/ccanlint/compulsory_tests/run_tests.c +++ b/tools/ccanlint/compulsory_tests/run_tests.c @@ -33,6 +33,15 @@ static void *do_run_tests(struct manifest *m) 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); @@ -65,6 +74,9 @@ static void *do_run_tests(struct manifest *m) list = NULL; } + if (chdir(olddir) != 0) + err(1, "Could not chdir to %s", olddir); + return list; } @@ -92,6 +104,9 @@ static const char *describe_run_tests(struct manifest *m, return descrip; } +/* Gcc's warn_unused_result is fascist bullshit. */ +#define doesnt_matter() + static void run_under_debugger(struct manifest *m, void *check_result) { char *command; @@ -104,10 +119,12 @@ static void run_under_debugger(struct manifest *m, void *check_result) first = list_top(list, struct run_tests_result, list); command = talloc_asprintf(m, "gdb -ex 'break tap.c:136' -ex 'run' %s", first->file->compiled); - system(command); + if (system(command)) + doesnt_matter(); } struct ccanlint run_tests = { + .key = "run", .name = "run and api tests run successfully", .score = score_run_tests, .check = do_run_tests,