]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: Mock access to /dev/kvm
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 15 Nov 2019 10:56:46 +0000 (11:56 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 15 Nov 2019 10:56:46 +0000 (11:56 +0100)
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 <mprivozn@redhat.com>
tests/qemuhotplugtest.c
tests/qemumemlocktest.c
tests/qemusecuritytest.c
tests/qemuxml2argvtest.c
tests/qemuxml2xmltest.c
tests/securityselinuxlabeltest.c

index a914a8a8b5f28a361a65d2c6974c3ae6500aeadc..7d70113b6ebf9e3a5d14dc7771ba6bc17d9ff53b 100644 (file)
@@ -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"));
index 52cd9f9f26db2518e648f0f201971dd0c1143e40..ef3bfa0345750e639098ed6e887ff8c3dd3157ad 100644 (file)
@@ -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
 
index 685ac4dca247ff1816246b82282efdfc1f531d7e..8c0a48bb65bf60fe07172bb5e564457185198a7e 100644 (file)
@@ -217,4 +217,5 @@ mymain(void)
     return ret;
 }
 
-VIR_TEST_MAIN(mymain)
+VIR_TEST_MAIN_PRELOAD(mymain,
+                      VIR_TEST_MOCK("domaincaps"))
index 9bb186ed95edee61c532aa7d7d24793ff4ffc50a..3d42cabdb877eef96339768d9fa72aff146d409f 100644 (file)
@@ -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"))
index 757e0a33e151ac053a031cd716f589b0a9613491..1dfa834f6bdb9ea89e6805d50951667930fa8795 100644 (file)
@@ -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
index 741c39d4d1c048b8425caedd6613dbfeb6d60c83..cbc7018e27dbd99aadf5217e8070dc04ce962e1c 100644 (file)
@@ -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")