From a7c1eb140f33c7be85797cc9d0df66d6112eb916 Mon Sep 17 00:00:00 2001 From: Roman Bogorodskiy Date: Tue, 21 Apr 2015 12:14:45 +0400 Subject: [PATCH] vircapstest: fix build without LXC, QEMU or XEN When building without lxc support enabled, build fails with: CLD vircapstest vircapstest.o: In function `test_virCapsDomainDataLookupLXC': vircapstest.c:(.text+0x9ef): undefined reference to `testLXCCapsInit' Fix that by hiding LXC tests under appropriate #ifdef. Same applies for QEMU and XEN. Signed-off-by: Michal Privoznik --- tests/Makefile.am | 15 ++++++++++----- tests/vircapstest.c | 18 +++++++++++++++--- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index c6d60cd9e6..09dc2cbfb4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -877,11 +877,16 @@ virkmodtest_SOURCES = \ virkmodtest_LDADD = $(LDADDS) vircapstest_SOURCES = \ - vircapstest.c testutils.h testutils.c \ - testutilsqemu.c testutilsqemu.h \ - testutilslxc.c testutilslxc.h \ - testutilsxen.c testutilsxen.h \ - $(NULL) + vircapstest.c testutils.h testutils.c +if WITH_LXC +vircapstest_SOURCES += testutilslxc.c testutilslxc.h +endif WITH_LXC +if WITH_QEMU +vircapstest_SOURCES += testutilsqemu.c testutilsqemu.h +endif WITH_QEMU +if WITH_XEN +vircapstest_SOURCES += testutilsxen.c testutilsxen.h +endif WITH_XEN vircapstest_LDADD = $(qemu_LDADDS) $(LDADDS) vircaps2xmltest_SOURCES = \ diff --git a/tests/vircapstest.c b/tests/vircapstest.c index 3e5038bd62..5a43d63457 100644 --- a/tests/vircapstest.c +++ b/tests/vircapstest.c @@ -38,7 +38,7 @@ /* * Build NUMA Toplogy with cell id starting from (0 + seq) * for testing -*/ + */ static virCapsPtr buildNUMATopology(int seq) { @@ -121,7 +121,7 @@ test_virCapabilitiesGetCpusForNodemask(const void *data ATTRIBUTE_UNUSED) } -static bool +static bool ATTRIBUTE_UNUSED doCapsExpectFailure(virCapsPtr caps, int ostype, virArch arch, @@ -140,7 +140,7 @@ doCapsExpectFailure(virCapsPtr caps, return true; } -static bool +static bool ATTRIBUTE_UNUSED doCapsCompare(virCapsPtr caps, int ostype, virArch arch, @@ -210,6 +210,7 @@ doCapsCompare(virCapsPtr caps, if (!doCapsExpectFailure(caps, o, a, d, e, m)) \ ret = 1; +#ifdef WITH_QEMU static int test_virCapsDomainDataLookupQEMU(const void *data ATTRIBUTE_UNUSED) { @@ -262,7 +263,9 @@ test_virCapsDomainDataLookupQEMU(const void *data ATTRIBUTE_UNUSED) virObjectUnref(caps); return ret; } +#endif /* WITH_QEMU */ +#ifdef WITH_XEN static int test_virCapsDomainDataLookupXen(const void *data ATTRIBUTE_UNUSED) { @@ -288,7 +291,9 @@ test_virCapsDomainDataLookupXen(const void *data ATTRIBUTE_UNUSED) virObjectUnref(caps); return ret; } +#endif /* WITH_XEN */ +#ifdef WITH_LXC static int test_virCapsDomainDataLookupLXC(const void *data ATTRIBUTE_UNUSED) { @@ -311,6 +316,7 @@ test_virCapsDomainDataLookupLXC(const void *data ATTRIBUTE_UNUSED) virObjectUnref(caps); return ret; } +#endif /* WITH_LXC */ static int mymain(void) @@ -320,15 +326,21 @@ mymain(void) if (virtTestRun("virCapabilitiesGetCpusForNodemask", test_virCapabilitiesGetCpusForNodemask, NULL) < 0) ret = -1; +#ifdef WITH_QEMU if (virtTestRun("virCapsDomainDataLookupQEMU", test_virCapsDomainDataLookupQEMU, NULL) < 0) ret = -1; +#endif +#ifdef WITH_XEN if (virtTestRun("virCapsDomainDataLookupXen", test_virCapsDomainDataLookupXen, NULL) < 0) ret = -1; +#endif +#ifdef WITH_LXC if (virtTestRun("virCapsDomainDataLookupLXC", test_virCapsDomainDataLookupLXC, NULL) < 0) ret = -1; +#endif /* WITH_LXC */ return ret; } -- GitLab