mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06: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:
@@ -231,10 +231,10 @@ static int
|
||||
mymain(void)
|
||||
{
|
||||
int ret = -1;
|
||||
g_autofree char *fakerootdir = NULL;
|
||||
const char *fakerootdir = NULL;
|
||||
g_autofree char *fakesysfsdir = NULL;
|
||||
|
||||
if (!(fakerootdir = virTestFakeRootDirInit()))
|
||||
if (!(fakerootdir = g_getenv("LIBVIRT_FAKE_ROOT_DIR")))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
fakesysfsdir = g_strdup_printf("%s/sys", fakerootdir);
|
||||
@@ -262,7 +262,6 @@ mymain(void)
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
virTestFakeRootDirCleanup(fakerootdir);
|
||||
VIR_FREE(scsihost_class_path);
|
||||
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user