summaryrefslogtreecommitdiff
path: root/tests/virhostdevmock.c
diff options
context:
space:
mode:
authorAndrea Bolognani <abologna@redhat.com>2020-05-06 14:38:42 +0200
committerAndrea Bolognani <abologna@redhat.com>2020-05-06 16:24:31 +0200
commiteea5d63a221a8f36a3ed5b1189fe619d4fa1fde2 (patch)
tree201921edef1a8b2a89aba1fc2e7d0fdd177c5efc /tests/virhostdevmock.c
parent7c42aafb0990cfda0a786d03e1a58753fe9d3db2 (diff)
downloadlibvirt-eea5d63a221a8f36a3ed5b1189fe619d4fa1fde2.tar.gz
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>
Diffstat (limited to 'tests/virhostdevmock.c')
-rw-r--r--tests/virhostdevmock.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/virhostdevmock.c b/tests/virhostdevmock.c
new file mode 100644
index 0000000000..9b0e4dc2b0
--- /dev/null
+++ b/tests/virhostdevmock.c
@@ -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);
+}