From f28fbb05d312fa923711afc8e036835b19bf943c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Mon, 4 May 2020 13:09:45 +0100 Subject: [PATCH] tests: poison $HOME and $XDG_RUNTIME_DIR env variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To attempt to catch unit tests which accidentally create files in $HOME, or $XDG_RUNTIME_DIR, poison these env vars by pointing them to directories which don't exist. This should give easier to debug test failures. For example: $ VIR_TEST_DEBUG=1 ./qemuhotplugtest Could not initialize HostdevManager - operation failed: Failed to create state dir '/bad-test-used-env-xdg-runtime-dir/libvirt/hostdevmgr' Reviewed-by: Michal Privoznik Reviewed-by: Andrea Bolognani Signed-off-by: Daniel P. Berrangé --- tests/testutils.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/testutils.c b/tests/testutils.c index 5fd81b70a2..7f1776b244 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -767,6 +767,9 @@ int virTestMain(int argc, preloads[npreloads] = NULL; } + g_setenv("HOME", "/bad-test-used-env-home", TRUE); + g_setenv("XDG_RUNTIME_DIR", "/bad-test-used-env-xdg-runtime-dir", TRUE); + va_start(ap, func); while ((lib = va_arg(ap, const char *))) { if (!virFileIsExecutable(lib)) { -- GitLab