Some of our tests try to validate domain XMLs they are working
with (not intentionally, simply because they call top level
domain XML parse function). Anyway, this implies that we build
domain capabilities also - see
virQEMUDriverGetDomainCapabilities(). And since some domain XMLs
are type of 'kvm' the control gets through
virQEMUCapsFillDomainCaps() and virHostCPUGetKVMMaxVCPUs() to
opening /dev/kvm which may be missing on the machine we're
running 'make check'.

Previously, we did not see this issue, because it was masked. If
building domain capabilities failed for whatever reason, we
ignored the failure. Only v5.9.0-207-gc69e6edea3 uncovered the
problem (it changed reval from 0 to -1 if
virQEMUDriverGetDomainCapabilities() fails). Since the referenced
commit is correct, we need to mock access to /dev/kvm in our
tests.

Signed-off-by: Michal Privoznik <mpriv...@redhat.com>
---

Pushed under broken build rule.

 tests/qemuhotplugtest.c          | 1 +
 tests/qemumemlocktest.c          | 4 +++-
 tests/qemusecuritytest.c         | 3 ++-
 tests/qemuxml2argvtest.c         | 1 +
 tests/qemuxml2xmltest.c          | 1 +
 tests/securityselinuxlabeltest.c | 4 +++-
 6 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
index a914a8a8b5..7d70113b6e 100644
--- a/tests/qemuhotplugtest.c
+++ b/tests/qemuhotplugtest.c
@@ -878,5 +878,6 @@ mymain(void)
 
 VIR_TEST_MAIN_PRELOAD(mymain,
                       VIR_TEST_MOCK("virpci"),
+                      VIR_TEST_MOCK("domaincaps"),
                       VIR_TEST_MOCK("virprocess"),
                       VIR_TEST_MOCK("qemuhotplug"));
diff --git a/tests/qemumemlocktest.c b/tests/qemumemlocktest.c
index 52cd9f9f26..ef3bfa0345 100644
--- a/tests/qemumemlocktest.c
+++ b/tests/qemumemlocktest.c
@@ -151,7 +151,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("virpci"),
+                      VIR_TEST_MOCK("domaincaps"))
 
 #else
 
diff --git a/tests/qemusecuritytest.c b/tests/qemusecuritytest.c
index 685ac4dca2..8c0a48bb65 100644
--- a/tests/qemusecuritytest.c
+++ b/tests/qemusecuritytest.c
@@ -217,4 +217,5 @@ mymain(void)
     return ret;
 }
 
-VIR_TEST_MAIN(mymain)
+VIR_TEST_MAIN_PRELOAD(mymain,
+                      VIR_TEST_MOCK("domaincaps"))
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 9bb186ed95..3d42cabdb8 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -3033,6 +3033,7 @@ mymain(void)
 
 VIR_TEST_MAIN_PRELOAD(mymain,
                       VIR_TEST_MOCK("qemuxml2argv"),
+                      VIR_TEST_MOCK("domaincaps"),
                       VIR_TEST_MOCK("virrandom"),
                       VIR_TEST_MOCK("qemucpu"),
                       VIR_TEST_MOCK("virpci"))
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 757e0a33e1..1dfa834f6b 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1355,6 +1355,7 @@ mymain(void)
 VIR_TEST_MAIN_PRELOAD(mymain,
                       VIR_TEST_MOCK("virpci"),
                       VIR_TEST_MOCK("virrandom"),
+                      VIR_TEST_MOCK("domaincaps"),
                       VIR_TEST_MOCK("virdeterministichash"))
 
 #else
diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabeltest.c
index 741c39d4d1..cbc7018e27 100644
--- a/tests/securityselinuxlabeltest.c
+++ b/tests/securityselinuxlabeltest.c
@@ -371,4 +371,6 @@ mymain(void)
     return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
-VIR_TEST_MAIN_PRELOAD(mymain, abs_builddir 
"/.libs/libsecurityselinuxhelper.so")
+VIR_TEST_MAIN_PRELOAD(mymain,
+                      VIR_TEST_MOCK("domaincaps"),
+                      abs_builddir "/.libs/libsecurityselinuxhelper.so")
-- 
2.23.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to