* Stop using system() inside the library and use fork + exec instead
* testsuite:
- - allow to set PATH, so install commands can contain tools in them
- when fake init_module() succeeds, create an entry in /sys/module
- when fake delete_module() succeeds, remove its entry from /sys/module
- add test for dependency loop _with install commands_ relying on module
return err;
}
+static int prepend_path(const char *extra)
+{
+ char *oldpath, *newpath;
+ int r;
+
+ if (extra == NULL)
+ return 0;
+
+ oldpath = getenv("PATH");
+ if (oldpath == NULL)
+ return setenv("PATH", extra, 1);
+
+ if (asprintf(&newpath, "%s:%s", extra, oldpath) < 0) {
+ ERR("failed to allocate memory to new PATH");
+ return -1;
+ }
+
+ r = setenv("PATH", newpath, 1);
+ free(newpath);
+
+ return r;
+}
+
int test_run(const struct test *t)
{
pid_t pid;
}
}
+ if (prepend_path(t->path) < 0) {
+ ERR("failed to prepend '%s' to PATH\n", t->path);
+ return EXIT_FAILURE;
+ }
+
LOG("running %s, in forked context\n", t->name);
pid = fork();