mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
tests: Introduce virhostdevmock
We need this for all tests that use virHostdevManager, because during creation of this object for unprivileged connections like those used in the test suite we would end up writing inside the user's home directory. That's bad manners in general, but when running the test suite inside a purposefully constrained environment such as the one exposed by pbuilder, it turns into an outright test failure: Could not initialize HostdevManager - operation failed: Failed to create state dir '/nonexistent/.cache/libvirt/hostdevmgr' Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
7c42aafb09
commit
eea5d63a22
@ -99,7 +99,7 @@ char *virGetUserDirectory(void);
|
||||
char *virGetUserDirectoryByUID(uid_t uid);
|
||||
char *virGetUserConfigDirectory(void);
|
||||
char *virGetUserCacheDirectory(void);
|
||||
char *virGetUserRuntimeDirectory(void);
|
||||
char *virGetUserRuntimeDirectory(void) G_GNUC_NO_INLINE;
|
||||
char *virGetUserShell(uid_t uid);
|
||||
char *virGetUserName(uid_t uid) G_GNUC_NO_INLINE;
|
||||
char *virGetGroupName(gid_t gid) G_GNUC_NO_INLINE;
|
||||
|
@ -212,6 +212,7 @@ test_libraries = libshunload.la \
|
||||
libvirnetdaemonmock.la \
|
||||
libvirnetserverclientmock.la \
|
||||
libvircgroupmock.la \
|
||||
libvirhostdevmock.la \
|
||||
libvirpcimock.la \
|
||||
libvirnetdevmock.la \
|
||||
libvirrandommock.la \
|
||||
@ -1226,6 +1227,12 @@ libvirfilecachemock_la_SOURCES = \
|
||||
libvirfilecachemock_la_LDFLAGS = $(MOCKLIBS_LDFLAGS)
|
||||
libvirfilecachemock_la_LIBADD = $(MOCKLIBS_LIBS)
|
||||
|
||||
libvirhostdevmock_la_SOURCES = \
|
||||
virhostdevmock.c \
|
||||
$(NULL)
|
||||
libvirhostdevmock_la_LDFLAGS = $(MOCKLIBS_LDFLAGS)
|
||||
libvirhostdevmock_la_LIBADD = $(MOCKLIBS_LIBS)
|
||||
|
||||
if WITH_LINUX
|
||||
vircaps2xmltest_SOURCES = \
|
||||
vircaps2xmltest.c testutils.h testutils.c virfilewrapper.h virfilewrapper.c
|
||||
|
@ -900,6 +900,7 @@ mymain(void)
|
||||
}
|
||||
|
||||
VIR_TEST_MAIN_PRELOAD(mymain,
|
||||
VIR_TEST_MOCK("virhostdev"),
|
||||
VIR_TEST_MOCK("virpci"),
|
||||
VIR_TEST_MOCK("domaincaps"),
|
||||
VIR_TEST_MOCK("virprocess"),
|
||||
|
15
tests/virhostdevmock.c
Normal file
15
tests/virhostdevmock.c
Normal file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Red Hat, Inc.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "virutil.h"
|
||||
|
||||
char *
|
||||
virGetUserRuntimeDirectory(void)
|
||||
{
|
||||
return g_build_filename(g_getenv("LIBVIRT_FAKE_ROOT_DIR"),
|
||||
"user-runtime-directory", NULL);
|
||||
}
|
@ -628,7 +628,9 @@ mymain(void)
|
||||
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
||||
VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("virpci"))
|
||||
VIR_TEST_MAIN_PRELOAD(mymain,
|
||||
VIR_TEST_MOCK("virhostdev"),
|
||||
VIR_TEST_MOCK("virpci"))
|
||||
#else
|
||||
int
|
||||
main(void)
|
||||
|
Loading…
Reference in New Issue
Block a user