]> git.ozlabs.org Git - ccan/blobdiff - tools/ccanlint/tests/run_tests_valgrind.c
ccanlint: fix directory issues properly.
[ccan] / tools / ccanlint / tests / run_tests_valgrind.c
index b89541f331475c510dd5a464b8826d418ce74003..4f32ed6c630953373ca461f193a55ddf1484896e 100644 (file)
@@ -36,6 +36,15 @@ static void *do_run_tests_vg(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);
 
@@ -68,6 +77,9 @@ 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;
 }
 
@@ -99,12 +111,15 @@ static void run_under_debugger_vg(struct manifest *m, void *check_result)
 {
        struct list_head *list = check_result;
        struct run_tests_result *first;
+       char *command;
 
        if (!ask("Should I run the first failing test under the debugger?"))
                return;
 
        first = list_top(list, struct run_tests_result, list);
-       run_command(m, "valgrind --db-attach=yes %s", first->file->compiled);
+       command = talloc_asprintf(m, "valgrind --db-attach=yes %s",
+                                 first->file->compiled);
+       system(command);
 }
 
 struct ccanlint run_tests_vg = {