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_LATEST based tests.
Signed-off-by: Peter Krempa <pkrempa(a)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 | 8 +++++---
6 files changed, 28 insertions(+), 6 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..693d623c17 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -695,7 +695,7 @@ mymain(void)
* version.
*/
# define DO_TEST_CAPS_INTERNAL(name, suffix, migrateFrom, flags, parseFlags, \
- arch, capsfile) \
+ arch, capsfile, stripmachinealiases) \
do { \
static struct testInfo info = { \
name, "." suffix, NULL, migrateFrom, migrateFrom ? 7 : -1,\
@@ -705,6 +705,8 @@ mymain(void)
if (!(info.qemuCaps = qemuTestParseCapabilitiesArch(virArchFromString(arch), \
capsfile))) \
return EXIT_FAILURE; \
+ if (stripmachinealiases) \
+ virQEMUCapsStripMachineAliases(info.qemuCaps); \
if (virTestRun("QEMU XML-2-ARGV " name "." suffix, \
testCompareXMLToArgv, &info) < 0) \
ret = -1; \
@@ -716,7 +718,7 @@ mymain(void)
# define DO_TEST_CAPS_ARCH_VER_FULL(name, flags, parseFlags, arch, ver) \
DO_TEST_CAPS_INTERNAL(name, arch "-" ver, NULL, flags, parseFlags, \
- arch, TEST_CAPS_PATH ver "." arch ".xml")
+ arch, TEST_CAPS_PATH ver "." arch ".xml",
false)
# define DO_TEST_CAPS_ARCH_VER(name, arch, ver) \
DO_TEST_CAPS_ARCH_VER_FULL(name, 0, 0, arch, ver)
@@ -726,7 +728,7 @@ mymain(void)
# define DO_TEST_CAPS_LATEST(name) \
DO_TEST_CAPS_INTERNAL(name, "x86_64-latest", NULL, 0, 0,
"x86_64", \
- capslatest_x86_64)
+ capslatest_x86_64, true)
/**
* The following test macros should be used only in cases when the tests require
--
2.16.2