[libvirt] [PATCH v2 0/4] tests: Add and use more DO_TEST_CAPS_*() macros

Changes from [v1]: * split 1/2 into three separate patches for easier review. [v1] https://www.redhat.com/archives/libvir-list/2019-July/msg00069.html Andrea Bolognani (4): tests: Reorder DO_TEST_CAPS_*() macros tests: Add DO_TEST_CAPS_ARCH_VER_FULL() tests: Add more DO_TEST_CAPS_*() macros tests: Use the new DO_TEST_CAPS_*() macros tests/qemuxml2argvtest.c | 76 ++++++++++++++++++++-------------------- tests/qemuxml2xmltest.c | 32 +++++++++-------- 2 files changed, 55 insertions(+), 53 deletions(-) -- 2.21.0

Make sure the order is consistent between xml2argv and xml2xml, and make room for more macros that are going to be introduced shortly. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- tests/qemuxml2argvtest.c | 13 ++++++------- tests/qemuxml2xmltest.c | 29 ++++++++++++++--------------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 91ca35d469..f4603d36c2 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -712,21 +712,21 @@ mymain(void) ARG_CAPS_VER, ver, \ __VA_ARGS__) -# define DO_TEST_CAPS_ARCH_VER(name, arch, ver) \ - DO_TEST_CAPS_INTERNAL(name, arch, ver, ARG_END) - -# define DO_TEST_CAPS_VER(name, ver) \ - DO_TEST_CAPS_ARCH_VER(name, "x86_64", ver) - # define DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, ...) \ DO_TEST_CAPS_INTERNAL(name, arch, "latest", __VA_ARGS__) # define DO_TEST_CAPS_ARCH_LATEST(name, arch) \ DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, ARG_END) +# define DO_TEST_CAPS_ARCH_VER(name, arch, ver) \ + DO_TEST_CAPS_INTERNAL(name, arch, ver, ARG_END) + # define DO_TEST_CAPS_LATEST(name) \ DO_TEST_CAPS_ARCH_LATEST(name, "x86_64") +# define DO_TEST_CAPS_VER(name, ver) \ + DO_TEST_CAPS_ARCH_VER(name, "x86_64", ver) + # define DO_TEST_CAPS_LATEST_FAILURE(name) \ DO_TEST_CAPS_ARCH_LATEST_FULL(name, "x86_64", \ ARG_FLAGS, FLAG_EXPECT_FAILURE) @@ -735,7 +735,6 @@ mymain(void) DO_TEST_CAPS_ARCH_LATEST_FULL(name, "x86_64", \ ARG_FLAGS, FLAG_EXPECT_PARSE_ERROR) - # define DO_TEST_FULL(name, ...) \ DO_TEST_INTERNAL(name, "", \ __VA_ARGS__, QEMU_CAPS_LAST) diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index a64b17ac28..b60a013ac0 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -207,36 +207,35 @@ mymain(void) testQemuInfoClear(&info); \ } while (0) -# define NONE QEMU_CAPS_LAST - -# define DO_TEST_FULL(name, when, ...) \ - DO_TEST_INTERNAL(name, "", when, __VA_ARGS__) - -# define DO_TEST(name, ...) \ - DO_TEST_FULL(name, WHEN_BOTH, \ - ARG_QEMU_CAPS, __VA_ARGS__, QEMU_CAPS_LAST) - # define DO_TEST_CAPS_INTERNAL(name, arch, ver, ...) \ DO_TEST_INTERNAL(name, "." arch "-" ver, WHEN_BOTH, \ ARG_CAPS_ARCH, arch, \ ARG_CAPS_VER, ver, \ __VA_ARGS__) -# define DO_TEST_CAPS_ARCH_VER(name, arch, ver) \ - DO_TEST_CAPS_INTERNAL(name, arch, ver, ARG_END) - -# define DO_TEST_CAPS_VER(name, ver) \ - DO_TEST_CAPS_ARCH_VER(name, "x86_64", ver) - # define DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, ...) \ DO_TEST_CAPS_INTERNAL(name, arch, "latest", __VA_ARGS__) # define DO_TEST_CAPS_ARCH_LATEST(name, arch) \ DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, ARG_END) +# define DO_TEST_CAPS_ARCH_VER(name, arch, ver) \ + DO_TEST_CAPS_INTERNAL(name, arch, ver, ARG_END) + # define DO_TEST_CAPS_LATEST(name) \ DO_TEST_CAPS_ARCH_LATEST(name, "x86_64") +# define DO_TEST_CAPS_VER(name, ver) \ + DO_TEST_CAPS_ARCH_VER(name, "x86_64", ver) + +# define DO_TEST_FULL(name, when, ...) \ + DO_TEST_INTERNAL(name, "", when, __VA_ARGS__) + +# define DO_TEST(name, ...) \ + DO_TEST_FULL(name, WHEN_BOTH, \ + ARG_QEMU_CAPS, __VA_ARGS__, QEMU_CAPS_LAST) + +# define NONE QEMU_CAPS_LAST /* Unset or set all envvars here that are copied in qemudBuildCommandLine * using ADD_ENV_COPY, otherwise these tests may fail due to unexpected -- 2.21.0

On Tue, Jul 02, 2019 at 05:50:39PM +0200, Andrea Bolognani wrote:
Make sure the order is consistent between xml2argv and xml2xml, and make room for more macros that are going to be introduced shortly.
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- tests/qemuxml2argvtest.c | 13 ++++++------- tests/qemuxml2xmltest.c | 29 ++++++++++++++--------------- 2 files changed, 20 insertions(+), 22 deletions(-)
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 91ca35d469..f4603d36c2 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -712,21 +712,21 @@ mymain(void) ARG_CAPS_VER, ver, \ __VA_ARGS__)
-# define DO_TEST_CAPS_ARCH_VER(name, arch, ver) \ - DO_TEST_CAPS_INTERNAL(name, arch, ver, ARG_END) - -# define DO_TEST_CAPS_VER(name, ver) \ - DO_TEST_CAPS_ARCH_VER(name, "x86_64", ver) - # define DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, ...) \ DO_TEST_CAPS_INTERNAL(name, arch, "latest", __VA_ARGS__)
# define DO_TEST_CAPS_ARCH_LATEST(name, arch) \ DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, ARG_END)
+# define DO_TEST_CAPS_ARCH_VER(name, arch, ver) \ + DO_TEST_CAPS_INTERNAL(name, arch, ver, ARG_END) + # define DO_TEST_CAPS_LATEST(name) \ DO_TEST_CAPS_ARCH_LATEST(name, "x86_64")
+# define DO_TEST_CAPS_VER(name, ver) \ + DO_TEST_CAPS_ARCH_VER(name, "x86_64", ver) + # define DO_TEST_CAPS_LATEST_FAILURE(name) \ DO_TEST_CAPS_ARCH_LATEST_FULL(name, "x86_64", \ ARG_FLAGS, FLAG_EXPECT_FAILURE) @@ -735,7 +735,6 @@ mymain(void) DO_TEST_CAPS_ARCH_LATEST_FULL(name, "x86_64", \ ARG_FLAGS, FLAG_EXPECT_PARSE_ERROR)
- # define DO_TEST_FULL(name, ...) \ DO_TEST_INTERNAL(name, "", \ __VA_ARGS__, QEMU_CAPS_LAST)
Unrelated whitespace change. Jano

On Wed, 2019-07-03 at 08:22 +0200, Ján Tomko wrote:
On Tue, Jul 02, 2019 at 05:50:39PM +0200, Andrea Bolognani wrote:
@@ -735,7 +735,6 @@ mymain(void) DO_TEST_CAPS_ARCH_LATEST_FULL(name, "x86_64", \ ARG_FLAGS, FLAG_EXPECT_PARSE_ERROR)
- # define DO_TEST_FULL(name, ...) \ DO_TEST_INTERNAL(name, "", \ __VA_ARGS__, QEMU_CAPS_LAST)
Unrelated whitespace change.
It's not unrelated: xml2xml didn't have that empty line because it's pointless for it to be there, and as part of the unification process it's been removed from xml2argv as well. What was wrong is me re-introducing it in commit 3/4 O:-) So I got rid of that before pushing. Thank you for the review! -- Andrea Bolognani / Red Hat / Virtualization

It mirrors the existing DO_TEST_CAPS_ARCH_LATEST_FULL(), and is now used to implement DO_TEST_CAPS_ARCH_VER(). Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- tests/qemuxml2argvtest.c | 5 ++++- tests/qemuxml2xmltest.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index f4603d36c2..748d43f488 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -715,11 +715,14 @@ mymain(void) # define DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, ...) \ DO_TEST_CAPS_INTERNAL(name, arch, "latest", __VA_ARGS__) +# define DO_TEST_CAPS_ARCH_VER_FULL(name, arch, ver, ...) \ + DO_TEST_CAPS_INTERNAL(name, arch, ver, __VA_ARGS__) + # define DO_TEST_CAPS_ARCH_LATEST(name, arch) \ DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, ARG_END) # define DO_TEST_CAPS_ARCH_VER(name, arch, ver) \ - DO_TEST_CAPS_INTERNAL(name, arch, ver, ARG_END) + DO_TEST_CAPS_ARCH_VER_FULL(name, arch, ver, ARG_END) # define DO_TEST_CAPS_LATEST(name) \ DO_TEST_CAPS_ARCH_LATEST(name, "x86_64") diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index b60a013ac0..6d808e172f 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -216,11 +216,14 @@ mymain(void) # define DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, ...) \ DO_TEST_CAPS_INTERNAL(name, arch, "latest", __VA_ARGS__) +# define DO_TEST_CAPS_ARCH_VER_FULL(name, arch, ver, ...) \ + DO_TEST_CAPS_INTERNAL(name, arch, ver, __VA_ARGS__) + # define DO_TEST_CAPS_ARCH_LATEST(name, arch) \ DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, ARG_END) # define DO_TEST_CAPS_ARCH_VER(name, arch, ver) \ - DO_TEST_CAPS_INTERNAL(name, arch, ver, ARG_END) + DO_TEST_CAPS_ARCH_VER_FULL(name, arch, ver, ARG_END) # define DO_TEST_CAPS_LATEST(name) \ DO_TEST_CAPS_ARCH_LATEST(name, "x86_64") -- 2.21.0

Right now we have macros such as DO_TEST_CAPS_LATEST_PARSE_ERROR() and DO_TEST_CAPS_ARCH_VER(), but there is no concise way to say "using this version of QEMU on this architecture will result in a failure". This commit adds DO_TEST_CAPS_ARCH_LATEST_FAILURE() DO_TEST_CAPS_ARCH_VER_FAILURE() DO_TEST_CAPS_ARCH_LATEST_PARSE_ERROR() DO_TEST_CAPS_ARCH_VER_PARSE_ERROR() and reworks DO_TEST_CAPS_LATEST_FAILURE() DO_TEST_CAPS_LATEST_PARSE_ERROR() to use the corresponding DO_CAPS_TEST_ARCH_*() macros instead of using DO_TEST_CAPS_ARCH_LATEST_FULL() directly. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- tests/qemuxml2argvtest.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 748d43f488..8d725040d3 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -730,14 +730,35 @@ mymain(void) # define DO_TEST_CAPS_VER(name, ver) \ DO_TEST_CAPS_ARCH_VER(name, "x86_64", ver) -# define DO_TEST_CAPS_LATEST_FAILURE(name) \ - DO_TEST_CAPS_ARCH_LATEST_FULL(name, "x86_64", \ +# define DO_TEST_CAPS_ARCH_LATEST_FAILURE(name, arch) \ + DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, \ ARG_FLAGS, FLAG_EXPECT_FAILURE) -# define DO_TEST_CAPS_LATEST_PARSE_ERROR(name) \ - DO_TEST_CAPS_ARCH_LATEST_FULL(name, "x86_64", \ +# define DO_TEST_CAPS_ARCH_VER_FAILURE(name, arch, ver) \ + DO_TEST_CAPS_ARCH_VER_FULL(name, arch, ver, \ + ARG_FLAGS, FLAG_EXPECT_FAILURE) + +# define DO_TEST_CAPS_LATEST_FAILURE(name) \ + DO_TEST_CAPS_ARCH_LATEST_FAILURE(name, "x86_64") + +# define DO_TEST_CAPS_VER_FAILURE(name, ver) \ + DO_TEST_CAPS_ARCH_VER_FAILURE(name, "x86_64", ver) + +# define DO_TEST_CAPS_ARCH_LATEST_PARSE_ERROR(name, arch) \ + DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, \ ARG_FLAGS, FLAG_EXPECT_PARSE_ERROR) +# define DO_TEST_CAPS_ARCH_VER_PARSE_ERROR(name, arch, ver) \ + DO_TEST_CAPS_ARCH_VER_FULL(name, arch, ver, \ + ARG_FLAGS, FLAG_EXPECT_PARSE_ERROR) + +# define DO_TEST_CAPS_LATEST_PARSE_ERROR(name) \ + DO_TEST_CAPS_ARCH_LATEST_PARSE_ERROR(name, "x86_64") + +# define DO_TEST_CAPS_VER_PARSE_ERROR(name, ver) \ + DO_TEST_CAPS_ARCH_VER_PARSE_ERROR(name, "x86_64", ver) + + # define DO_TEST_FULL(name, ...) \ DO_TEST_INTERNAL(name, "", \ __VA_ARGS__, QEMU_CAPS_LAST) -- 2.21.0

There are probably more situations where they could be taken advantage of, but these are very obvious scenarios because we either manage to get rid of a bunch of explicit capabilities, or we make a bunch of related test cases all use the macros by switching the only odd one out. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- tests/qemuxml2argvtest.c | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 8d725040d3..08697e91d6 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2849,7 +2849,7 @@ mymain(void) DO_TEST_CAPS_LATEST("intel-iommu-caching-mode"); DO_TEST_CAPS_LATEST("intel-iommu-eim"); DO_TEST_CAPS_LATEST("intel-iommu-device-iotlb"); - DO_TEST_PARSE_ERROR("intel-iommu-wrong-machine", NONE); + DO_TEST_CAPS_LATEST_PARSE_ERROR("intel-iommu-wrong-machine"); DO_TEST_CAPS_ARCH_LATEST("iommu-smmuv3", "aarch64"); DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS); @@ -2915,29 +2915,9 @@ mymain(void) DO_TEST_CAPS_LATEST("disk-virtio-scsi-reservations"); DO_TEST_CAPS_LATEST("tseg-explicit-size"); - DO_TEST_PARSE_ERROR("tseg-i440fx", - QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, - QEMU_CAPS_DEVICE_PCI_BRIDGE, - QEMU_CAPS_DEVICE_IOH3420, - QEMU_CAPS_ICH9_AHCI, - QEMU_CAPS_MACHINE_SMM_OPT, - QEMU_CAPS_VIRTIO_SCSI, - QEMU_CAPS_MCH_EXTENDED_TSEG_MBYTES); - DO_TEST_PARSE_ERROR("tseg-explicit-size", - QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, - QEMU_CAPS_DEVICE_PCI_BRIDGE, - QEMU_CAPS_DEVICE_IOH3420, - QEMU_CAPS_ICH9_AHCI, - QEMU_CAPS_MACHINE_SMM_OPT, - QEMU_CAPS_VIRTIO_SCSI); - DO_TEST_PARSE_ERROR("tseg-invalid-size", - QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, - QEMU_CAPS_DEVICE_PCI_BRIDGE, - QEMU_CAPS_DEVICE_IOH3420, - QEMU_CAPS_ICH9_AHCI, - QEMU_CAPS_MACHINE_SMM_OPT, - QEMU_CAPS_VIRTIO_SCSI, - QEMU_CAPS_MCH_EXTENDED_TSEG_MBYTES); + DO_TEST_CAPS_LATEST_PARSE_ERROR("tseg-i440fx"); + DO_TEST_CAPS_VER_PARSE_ERROR("tseg-explicit-size", "2.10.0"); + DO_TEST_CAPS_LATEST_PARSE_ERROR("tseg-invalid-size"); DO_TEST("video-virtio-gpu-ccw", QEMU_CAPS_CCW, QEMU_CAPS_DEVICE_VIRTIO_GPU, @@ -2971,10 +2951,7 @@ mymain(void) DO_TEST_CAPS_VER("virtio-non-transitional", "3.1.0"); DO_TEST_CAPS_LATEST("virtio-transitional"); DO_TEST_CAPS_LATEST("virtio-non-transitional"); - DO_TEST_PARSE_ERROR("virtio-transitional-not-supported", - QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, - QEMU_CAPS_DEVICE_PCI_BRIDGE, - QEMU_CAPS_DEVICE_IOH3420); + DO_TEST_CAPS_LATEST_PARSE_ERROR("virtio-transitional-not-supported"); /* Simple headless guests for various architectures */ DO_TEST_CAPS_ARCH_LATEST("aarch64-virt-headless", "aarch64"); -- 2.21.0

On Tue, Jul 02, 2019 at 05:50:38PM +0200, Andrea Bolognani wrote:
Changes from [v1]:
* split 1/2 into three separate patches for easier review.
[v1] https://www.redhat.com/archives/libvir-list/2019-July/msg00069.html
Andrea Bolognani (4): tests: Reorder DO_TEST_CAPS_*() macros tests: Add DO_TEST_CAPS_ARCH_VER_FULL() tests: Add more DO_TEST_CAPS_*() macros tests: Use the new DO_TEST_CAPS_*() macros
tests/qemuxml2argvtest.c | 76 ++++++++++++++++++++-------------------- tests/qemuxml2xmltest.c | 32 +++++++++-------- 2 files changed, 55 insertions(+), 53 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (2)
-
Andrea Bolognani
-
Ján Tomko