mirror of
https://github.com/libvirt/libvirt.git
synced 2026-10-02 12:20:06 -05:00
tests: Move fakerootdir handling to common logic
Instead of having each test manually initialize and cleanup its own fakerootdir, do that as part of the common test initialization logic in virTestMain(). In most cases we can simply drop the relevant code from the test program, but scsihosttest uses the value of fakerootdir as a starting point to build another path, so we need to do things slightly differently. In order to keep things working, we retrieve the value from the LIBVIRT_FAKE_ROOT_DIR environment variable, same as all the mock libraries are already doing. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
1 parent
457a0183d6
commit
87b30e6965
9 files changed
+8
-47
No files matched your search
@@ -808,6 +808,7 @@ int virTestMain(int argc,
|
||||
g_autofree const char **preloads = NULL;
|
||||
size_t npreloads = 0;
|
||||
g_autofree char *mock = NULL;
|
||||
g_autofree char *fakerootdir = NULL;
|
||||
|
||||
if (getenv("VIR_TEST_FILE_ACCESS")) {
|
||||
preloads = g_renew(const char *, preloads, npreloads + 2);
|
||||
@@ -888,6 +889,9 @@ int virTestMain(int argc,
|
||||
|
||||
failedTests = virBitmapNew(1);
|
||||
|
||||
if (!(fakerootdir = virTestFakeRootDirInit()))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
ret = (func)();
|
||||
|
||||
virResetLastError();
|
||||
@@ -897,6 +901,8 @@ int virTestMain(int argc,
|
||||
fprintf(stderr, " %-3zu %s\n", testCounter, ret == 0 ? "OK" : "FAIL");
|
||||
}
|
||||
|
||||
virTestFakeRootDirCleanup(fakerootdir);
|
||||
|
||||
switch (ret) {
|
||||
case EXIT_FAILURE:
|
||||
case EXIT_SUCCESS:
|
||||
|
||||
Reference in new issue
Block a user