[libvirt] [PATCH] tests: qemuxml2argv: Make tests based on DO_TEST_CAPS_INTERNAL stable

Peter Krempa posted 1 patch 5 years, 10 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/faf492851d268112bbb582b8bce5377fd7d8caa3.1528119183.git.pkrempa@redhat.com
Test syntax-check passed
src/qemu/qemu_capabilities.c                            | 17 +++++++++++++++++
src/qemu/qemu_capspriv.h                                |  3 +++
.../disk-virtio-scsi-reservations.x86_64-latest.args    |  2 +-
tests/qemuxml2argvdata/genid-auto.x86_64-latest.args    |  2 +-
tests/qemuxml2argvdata/genid.x86_64-latest.args         |  2 +-
tests/qemuxml2argvtest.c                                |  1 +
6 files changed, 24 insertions(+), 3 deletions(-)
[libvirt] [PATCH] tests: qemuxml2argv: Make tests based on DO_TEST_CAPS_INTERNAL stable
Posted by Peter Krempa 5 years, 10 months ago
To avoid problems with test cases specifying an alias machine type which
would change once capabilities for a newer version are added strip all
alias machine types for the DO_TEST_CAPS_INTERNAL based tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_capabilities.c                            | 17 +++++++++++++++++
 src/qemu/qemu_capspriv.h                                |  3 +++
 .../disk-virtio-scsi-reservations.x86_64-latest.args    |  2 +-
 tests/qemuxml2argvdata/genid-auto.x86_64-latest.args    |  2 +-
 tests/qemuxml2argvdata/genid.x86_64-latest.args         |  2 +-
 tests/qemuxml2argvtest.c                                |  1 +
 6 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index b8764eacd8..a4a89cedfd 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -5156,3 +5156,20 @@ virQEMUCapsSetMicrocodeVersion(virQEMUCapsPtr qemuCaps,
 {
     qemuCaps->microcodeVersion = microcodeVersion;
 }
+
+
+/**
+ * virQEMUCapsStripMachineAliases:
+ * @qemuCaps: capabilities object to process
+ *
+ * Remove all aliases so that the tests depending on the latest capabilities
+ * file can be stable when new files are added.
+ */
+void
+virQEMUCapsStripMachineAliases(virQEMUCapsPtr qemuCaps)
+{
+    size_t i;
+
+    for (i = 0; i < qemuCaps->nmachineTypes; i++)
+        VIR_FREE(qemuCaps->machineTypes[i].alias);
+}
diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h
index fea039ef3a..021260de2f 100644
--- a/src/qemu/qemu_capspriv.h
+++ b/src/qemu/qemu_capspriv.h
@@ -97,4 +97,7 @@ virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemuCaps,
 void
 virQEMUCapsSetMicrocodeVersion(virQEMUCapsPtr qemuCaps,
                                unsigned int microcodeVersion);
+
+void
+virQEMUCapsStripMachineAliases(virQEMUCapsPtr qemuCaps);
 #endif
diff --git a/tests/qemuxml2argvdata/disk-virtio-scsi-reservations.x86_64-latest.args b/tests/qemuxml2argvdata/disk-virtio-scsi-reservations.x86_64-latest.args
index 768bc22f9f..927173fa03 100644
--- a/tests/qemuxml2argvdata/disk-virtio-scsi-reservations.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/disk-virtio-scsi-reservations.x86_64-latest.args
@@ -13,7 +13,7 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
 path=/tmp/lib/domain--1-QEMUGuest1/pr-helper0.sock \
 -object pr-manager-helper,id=pr-helper-scsi0-0-0-1,\
 path=/path/to/qemu-pr-helper.sock \
--machine pc-i440fx-2.12,accel=tcg,usb=off,dump-guest-core=off \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
 -m 214 \
 -realtime mlock=off \
 -smp 8,sockets=8,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/genid-auto.x86_64-latest.args b/tests/qemuxml2argvdata/genid-auto.x86_64-latest.args
index ce163020b9..7412651479 100644
--- a/tests/qemuxml2argvdata/genid-auto.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/genid-auto.x86_64-latest.args
@@ -9,7 +9,7 @@ QEMU_AUDIO_DRV=none \
 -S \
 -object secret,id=masterKey0,format=raw,\
 file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
--machine pc-i440fx-2.12,accel=tcg,usb=off,dump-guest-core=off \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
 -m 214 \
 -realtime mlock=off \
 -smp 1,sockets=1,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/genid.x86_64-latest.args b/tests/qemuxml2argvdata/genid.x86_64-latest.args
index 54e00f4bdb..dbffa7e1d2 100644
--- a/tests/qemuxml2argvdata/genid.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/genid.x86_64-latest.args
@@ -9,7 +9,7 @@ QEMU_AUDIO_DRV=none \
 -S \
 -object secret,id=masterKey0,format=raw,\
 file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
--machine pc-i440fx-2.12,accel=tcg,usb=off,dump-guest-core=off \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
 -m 214 \
 -realtime mlock=off \
 -smp 1,sockets=1,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 61c7ae59aa..ab7a50817a 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -705,6 +705,7 @@ mymain(void)
         if (!(info.qemuCaps = qemuTestParseCapabilitiesArch(virArchFromString(arch), \
                                                             capsfile))) \
             return EXIT_FAILURE; \
+        virQEMUCapsStripMachineAliases(info.qemuCaps); \
         if (virTestRun("QEMU XML-2-ARGV " name "." suffix, \
                        testCompareXMLToArgv, &info) < 0) \
             ret = -1; \
-- 
2.16.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] tests: qemuxml2argv: Make tests based on DO_TEST_CAPS_INTERNAL stable
Posted by Peter Krempa 5 years, 10 months ago
On Mon, Jun 04, 2018 at 15:33:03 +0200, Peter Krempa wrote:
> To avoid problems with test cases specifying an alias machine type which
> would change once capabilities for a newer version are added strip all
> alias machine types for the DO_TEST_CAPS_INTERNAL based tests.
> 
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>  src/qemu/qemu_capabilities.c                            | 17 +++++++++++++++++
>  src/qemu/qemu_capspriv.h                                |  3 +++
>  .../disk-virtio-scsi-reservations.x86_64-latest.args    |  2 +-
>  tests/qemuxml2argvdata/genid-auto.x86_64-latest.args    |  2 +-
>  tests/qemuxml2argvdata/genid.x86_64-latest.args         |  2 +-
>  tests/qemuxml2argvtest.c                                |  1 +
>  6 files changed, 24 insertions(+), 3 deletions(-)

[...]

> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
> index 61c7ae59aa..ab7a50817a 100644
> --- a/tests/qemuxml2argvtest.c
> +++ b/tests/qemuxml2argvtest.c
> @@ -705,6 +705,7 @@ mymain(void)
>          if (!(info.qemuCaps = qemuTestParseCapabilitiesArch(virArchFromString(arch), \
>                                                              capsfile))) \
>              return EXIT_FAILURE; \
> +        virQEMUCapsStripMachineAliases(info.qemuCaps); \

Actually, this should be done only for the _LATEST tests and not all
based on a specific version.

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