[libvirt] [PATCH 12/12] tests/domaincaps: Use testQemuCapsIterate()

Andrea Bolognani abologna at redhat.com
Wed Oct 23 10:43:02 UTC 2019


Now that the only data we need for fully testing a QEMU binary is
the (version, arch) combo, we can stop providing that information
ourselves and instead rely on testQemuCapsIterate() automatically
picking up new input files as they are added to the repository,
the same way the qemucapabilities and qemucaps2xml tests already
behave.

Unsurprisingly, this change results in a bunch of extra output
files being created, significantly expanding our test coverage.

Signed-off-by: Andrea Bolognani <abologna at redhat.com>
---
 .../domaincapsdata/qemu_1.5.3-q35.x86_64.xml  | 134 ++++++++++++
 .../domaincapsdata/qemu_1.5.3-tcg.x86_64.xml  | 134 ++++++++++++
 tests/domaincapsdata/qemu_1.5.3.x86_64.xml    | 134 ++++++++++++
 .../domaincapsdata/qemu_1.6.0-q35.x86_64.xml  | 134 ++++++++++++
 .../domaincapsdata/qemu_1.6.0-tcg.x86_64.xml  | 134 ++++++++++++
 tests/domaincapsdata/qemu_1.6.0.x86_64.xml    | 134 ++++++++++++
 .../domaincapsdata/qemu_2.1.1-q35.x86_64.xml  | 135 ++++++++++++
 .../domaincapsdata/qemu_2.1.1-tcg.x86_64.xml  | 135 ++++++++++++
 tests/domaincapsdata/qemu_2.1.1.x86_64.xml    | 135 ++++++++++++
 .../domaincapsdata/qemu_2.10.0-q35.x86_64.xml | 158 ++++++++++++++
 .../domaincapsdata/qemu_2.10.0-tcg.x86_64.xml | 177 ++++++++++++++++
 .../qemu_2.10.0-virt.aarch64.xml              | 142 +++++++++++++
 tests/domaincapsdata/qemu_2.10.0.aarch64.xml  | 136 ++++++++++++
 tests/domaincapsdata/qemu_2.10.0.ppc64.xml    | 108 ++++++++++
 tests/domaincapsdata/qemu_2.10.0.s390x.xml    | 198 ++++++++++++++++++
 tests/domaincapsdata/qemu_2.10.0.x86_64.xml   | 158 ++++++++++++++
 .../domaincapsdata/qemu_2.11.0-q35.x86_64.xml | 156 ++++++++++++++
 .../domaincapsdata/qemu_2.11.0-tcg.x86_64.xml | 172 +++++++++++++++
 tests/domaincapsdata/qemu_2.11.0.s390x.xml    | 197 +++++++++++++++++
 tests/domaincapsdata/qemu_2.11.0.x86_64.xml   | 156 ++++++++++++++
 .../domaincapsdata/qemu_2.4.0-q35.x86_64.xml  | 143 +++++++++++++
 .../domaincapsdata/qemu_2.4.0-tcg.x86_64.xml  | 143 +++++++++++++
 tests/domaincapsdata/qemu_2.4.0.x86_64.xml    | 143 +++++++++++++
 .../domaincapsdata/qemu_2.5.0-q35.x86_64.xml  | 143 +++++++++++++
 .../domaincapsdata/qemu_2.5.0-tcg.x86_64.xml  | 143 +++++++++++++
 tests/domaincapsdata/qemu_2.5.0.x86_64.xml    | 143 +++++++++++++
 .../domaincapsdata/qemu_2.7.0-q35.x86_64.xml  | 144 +++++++++++++
 .../domaincapsdata/qemu_2.7.0-tcg.x86_64.xml  | 144 +++++++++++++
 tests/domaincapsdata/qemu_2.7.0.x86_64.xml    | 144 +++++++++++++
 tests/domaincapsdata/qemu_2.9.0.ppc64.xml     | 108 ++++++++++
 tests/domaincapsdata/qemu_2.9.0.s390x.xml     | 183 ++++++++++++++++
 .../domaincapsdata/qemu_3.0.0-q35.x86_64.xml  | 169 +++++++++++++++
 .../domaincapsdata/qemu_3.0.0-tcg.x86_64.xml  | 184 ++++++++++++++++
 tests/domaincapsdata/qemu_3.0.0.ppc64.xml     | 109 ++++++++++
 tests/domaincapsdata/qemu_3.0.0.x86_64.xml    | 169 +++++++++++++++
 tests/domaincapsdata/qemu_3.1.0.ppc64.xml     | 110 ++++++++++
 .../qemu_4.0.0-virt.aarch64.xml               | 150 +++++++++++++
 tests/domaincapsdata/qemu_4.0.0.aarch64.xml   | 144 +++++++++++++
 tests/domaincapsdata/qemu_4.0.0.ppc64.xml     | 111 ++++++++++
 tests/domaincapstest.c                        |  57 ++---
 40 files changed, 5715 insertions(+), 36 deletions(-)
 create mode 100644 tests/domaincapsdata/qemu_1.5.3-q35.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_1.5.3-tcg.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_1.5.3.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_1.6.0-q35.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_1.6.0-tcg.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_1.6.0.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_2.1.1-q35.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_2.1.1-tcg.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_2.1.1.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_2.10.0-q35.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_2.10.0-tcg.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_2.10.0-virt.aarch64.xml
 create mode 100644 tests/domaincapsdata/qemu_2.10.0.aarch64.xml
 create mode 100644 tests/domaincapsdata/qemu_2.10.0.ppc64.xml
 create mode 100644 tests/domaincapsdata/qemu_2.10.0.s390x.xml
 create mode 100644 tests/domaincapsdata/qemu_2.10.0.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_2.11.0-q35.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_2.11.0-tcg.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_2.11.0.s390x.xml
 create mode 100644 tests/domaincapsdata/qemu_2.11.0.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_2.4.0-q35.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_2.4.0-tcg.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_2.4.0.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_2.5.0-q35.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_2.5.0-tcg.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_2.5.0.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_2.7.0-q35.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_2.7.0-tcg.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_2.7.0.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_2.9.0.ppc64.xml
 create mode 100644 tests/domaincapsdata/qemu_2.9.0.s390x.xml
 create mode 100644 tests/domaincapsdata/qemu_3.0.0-q35.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_3.0.0-tcg.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_3.0.0.ppc64.xml
 create mode 100644 tests/domaincapsdata/qemu_3.0.0.x86_64.xml
 create mode 100644 tests/domaincapsdata/qemu_3.1.0.ppc64.xml
 create mode 100644 tests/domaincapsdata/qemu_4.0.0-virt.aarch64.xml
 create mode 100644 tests/domaincapsdata/qemu_4.0.0.aarch64.xml
 create mode 100644 tests/domaincapsdata/qemu_4.0.0.ppc64.xml

diff --git a/tests/domaincapsdata/qemu_1.5.3-q35.x86_64.xml b/tests/domaincapsdata/qemu_1.5.3-q35.x86_64.xml
new file mode 100644
index 0000000000..c6b090ed06
--- /dev/null
+++ b/tests/domaincapsdata/qemu_1.5.3-q35.x86_64.xml
@@ -0,0 +1,134 @@
+<domainCapabilities>
+  <path>/usr/bin/qemu-system-x86_64</path>
+  <domain>kvm</domain>
+  <machine>pc-q35-1.5</machine>
+  <arch>x86_64</arch>
+  <vcpu max='255'/>
+  <iothreads supported='no'/>
+  <os supported='yes'>
+    <enum name='firmware'>
+      <value>bios</value>
+      <value>efi</value>
+    </enum>
+    <loader supported='yes'>
+      <value>/usr/share/AAVMF/AAVMF_CODE.fd</value>
+      <value>/usr/share/AAVMF/AAVMF32_CODE.fd</value>
+      <value>/usr/share/OVMF/OVMF_CODE.fd</value>
+      <enum name='type'>
+        <value>rom</value>
+        <value>pflash</value>
+      </enum>
+      <enum name='readonly'>
+        <value>yes</value>
+        <value>no</value>
+      </enum>
+      <enum name='secure'>
+        <value>yes</value>
+        <value>no</value>
+      </enum>
+    </loader>
+  </os>
+  <cpu>
+    <mode name='host-passthrough' supported='yes'/>
+    <mode name='host-model' supported='yes'>
+      <model fallback='allow'>Broadwell</model>
+    </mode>
+    <mode name='custom' supported='yes'>
+      <model usable='unknown'>Opteron_G5</model>
+      <model usable='unknown'>Opteron_G4</model>
+      <model usable='unknown'>Opteron_G3</model>
+      <model usable='unknown'>Opteron_G2</model>
+      <model usable='unknown'>Opteron_G1</model>
+      <model usable='unknown'>Haswell</model>
+      <model usable='unknown'>SandyBridge</model>
+      <model usable='unknown'>Westmere</model>
+      <model usable='unknown'>Nehalem</model>
+      <model usable='unknown'>Penryn</model>
+      <model usable='unknown'>Conroe</model>
+      <model usable='unknown'>n270</model>
+      <model usable='unknown'>athlon</model>
+      <model usable='unknown'>pentium3</model>
+      <model usable='unknown'>pentium2</model>
+      <model usable='unknown'>pentium</model>
+      <model usable='unknown'>486</model>
+      <model usable='unknown'>coreduo</model>
+      <model usable='unknown'>kvm32</model>
+      <model usable='unknown'>qemu32</model>
+      <model usable='unknown'>kvm64</model>
+      <model usable='unknown'>core2duo</model>
+      <model usable='unknown'>phenom</model>
+      <model usable='unknown'>qemu64</model>
+    </mode>
+  </cpu>
+  <devices>
+    <disk supported='yes'>
+      <enum name='diskDevice'>
+        <value>disk</value>
+        <value>cdrom</value>
+        <value>floppy</value>
+        <value>lun</value>
+      </enum>
+      <enum name='bus'>
+        <value>fdc</value>
+        <value>scsi</value>
+        <value>virtio</value>
+        <value>usb</value>
+        <value>sata</value>
+      </enum>
+      <enum name='model'>
+        <value>virtio</value>
+      </enum>
+    </disk>
+    <graphics supported='yes'>
+      <enum name='type'>
+        <value>sdl</value>
+        <value>vnc</value>
+        <value>spice</value>
+      </enum>
+    </graphics>
+    <video supported='yes'>
+      <enum name='modelType'>
+        <value>vga</value>
+        <value>cirrus</value>
+        <value>vmvga</value>
+        <value>qxl</value>
+      </enum>
+    </video>
+    <hostdev supported='yes'>
+      <enum name='mode'>
+        <value>subsystem</value>
+      </enum>
+      <enum name='startupPolicy'>
+        <value>default</value>
+        <value>mandatory</value>
+        <value>requisite</value>
+        <value>optional</value>
+      </enum>
+      <enum name='subsysType'>
+        <value>usb</value>
+        <value>pci</value>
+        <value>scsi</value>
+      </enum>
+      <enum name='capsType'/>
+      <enum name='pciBackend'>
+        <value>default</value>
+        <value>vfio</value>
+      </enum>
+    </hostdev>
+    <rng supported='yes'>
+      <enum name='model'>
+        <value>virtio</value>
+      </enum>
+      <enum name='backendModel'>
+        <value>random</value>
+        <value>egd</value>
+      </enum>
+    </rng>
+  </devices>
+  <features>
+    <gic supported='no'/>
+    <vmcoreinfo supported='no'/>
+    <genid supported='no'/>
+    <sev supported='no'/>
+  </features>
+</domainCapabilities>

[... many more files like this one get generated ...]

diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c
index 4476423228..0197c61c8a 100644
--- a/tests/domaincapstest.c
+++ b/tests/domaincapstest.c
@@ -303,8 +303,11 @@ doTestQemuInternal(const char *version,
 }
 
 static int
-doTestQemu(const char *version,
+doTestQemu(const char *inputDir G_GNUC_UNUSED,
+           const char *prefix G_GNUC_UNUSED,
+           const char *version,
            const char *arch,
+           const char *suffix G_GNUC_UNUSED,
            void *opaque)
 {
     if (STREQ(arch, "x86_64")) {
@@ -376,12 +379,6 @@ mymain(void)
             ret = -1; \
     } while (0)
 
-#define DO_TEST_QEMU(Version, Arch) \
-    do { \
-        if (doTestQemu(Version, Arch, cfg) < 0) \
-            ret = -1; \
-    } while (0)
-
 #define DO_TEST_LIBXL(Name, Emulator, Machine, Arch, Type) \
     do { \
         struct testData data = { \
@@ -428,36 +425,24 @@ mymain(void)
     virFileWrapperAddPrefix("/home/user/.config/qemu/firmware",
                             abs_srcdir "/qemufirmwaredata/home/user/.config/qemu/firmware");
 
-    DO_TEST_QEMU("1.7.0", "x86_64");
-
-    DO_TEST_QEMU("2.6.0", "x86_64");
-    DO_TEST_QEMU("2.6.0", "aarch64");
-    DO_TEST_QEMU("2.6.0", "ppc64");
-
-    DO_TEST_QEMU("2.7.0", "s390x");
-
-    DO_TEST_QEMU("2.8.0", "x86_64");
-    DO_TEST_QEMU("2.8.0", "s390x");
-
-    DO_TEST_QEMU("2.9.0", "x86_64");
-
-    DO_TEST_QEMU("2.12.0", "x86_64");
-    DO_TEST_QEMU("2.12.0", "aarch64");
-    DO_TEST_QEMU("2.12.0", "ppc64");
-    DO_TEST_QEMU("2.12.0", "s390x");
-
-    DO_TEST_QEMU("3.0.0", "s390x");
-
-    DO_TEST_QEMU("3.1.0", "x86_64");
-
-    DO_TEST_QEMU("4.0.0", "x86_64");
-    DO_TEST_QEMU("4.0.0", "s390x");
-
-    DO_TEST_QEMU("4.1.0", "x86_64");
+    if (testQemuCapsIterate(".xml", doTestQemu, cfg) < 0)
+        return EXIT_FAILURE;
 
-    DO_TEST_QEMU("4.2.0", "x86_64");
-    DO_TEST_QEMU("4.2.0", "ppc64");
-    DO_TEST_QEMU("4.2.0", "aarch64");
+    /*
+     * Run "tests/qemucapsprobe /path/to/qemu/binary >foo.replies"
+     * to generate updated or new *.replies data files.
+     *
+     * If you manually edit replies files you can run
+     * "tests/qemucapsfixreplies foo.replies" to fix the replies ids.
+     *
+     * Once a replies file has been generated and tweaked if necessary,
+     * you can drop it into tests/qemucapabilitiesdata/ (with a sensible
+     * name - look at what's already there for inspiration) and test
+     * programs will automatically pick it up.
+     *
+     * To generate the corresponding output files after a new replies
+     * file has been added, run "VIR_TEST_REGENERATE_OUTPUT=1 make check".
+     */
 
     virObjectUnref(cfg);
 
-- 
2.21.0




More information about the libvir-list mailing list