As of 47503cc859 we are statically linking libtest_utils.a into
qemuhotplugmock.so (see the original commit for reasoning).
However, this breaks ASAN on older clang because now
qemuhotplugtest has two instances of virTestHostArch global
variable. One that comes from the binary itself (which also links
with libtest_utils.a) and the other from the mock. Resolve this
by making the variable static and introducing getter and setter.
Well, the former already exists (as virArchFromHost()) so only
the latter is needed.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tests/testutils.c | 7 ++++++-
tests/testutils.h | 2 +-
tests/testutilsqemu.c | 2 +-
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/tests/testutils.c b/tests/testutils.c
index 2b37c1965d..9d454c23bc 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -55,7 +55,7 @@ static size_t testCounter;
static virBitmap *testBitmap;
static virBitmap *failedTests;
-virArch virTestHostArch = VIR_ARCH_X86_64;
+static virArch virTestHostArch = VIR_ARCH_X86_64;
virArch
virArchFromHost(void)
@@ -63,6 +63,11 @@ virArchFromHost(void)
return virTestHostArch;
}
+void
+virTestSetHostArch(virArch arch)
+{
+ virTestHostArch = arch;
+}
static int virTestUseTerminalColors(void)
{
diff --git a/tests/testutils.h b/tests/testutils.h
index 13a154a5af..ff5661bb3f 100644
--- a/tests/testutils.h
+++ b/tests/testutils.h
@@ -35,7 +35,7 @@
# error Fix build system
#endif
-extern virArch virTestHostArch;
+void virTestSetHostArch(virArch arch);
int virTestRun(const char *title,
int (*body)(const void *data),
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 105b41cbeb..53fb5f656d 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -307,7 +307,7 @@ qemuTestSetHostArch(virQEMUDriver *driver,
if (arch == VIR_ARCH_NONE)
arch = VIR_ARCH_X86_64;
- virTestHostArch = arch;
+ virTestSetHostArch(arch);
driver->hostarch = virArchFromHost();
driver->caps->host.arch = virArchFromHost();
qemuTestSetHostCPU(driver, arch, NULL);
--
2.35.1