提交 eea5d63a 编写于 作者: A Andrea Bolognani

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: NAndrea Bolognani <abologna@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 7c42aafb
......@@ -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"),
......
/*
* 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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册