mirror of https://gitee.com/openkylin/libvirt.git
tests: Use testQemuCapsIterate()
With only a couple minor tweaks, we can make the existing doCapsTest() functions with testQemuCapsIterate() and finally remove the need to manually adjust the test programs every time a new input file is introduced; moreover, this means that the two lists can't possibly get out of sync anymore. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Acked-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
30439c1b81
commit
60943f0eec
|
@ -179,8 +179,9 @@ testQemuCapsCopy(const void *opaque)
|
|||
static int
|
||||
doCapsTest(const char *base,
|
||||
const char *archName,
|
||||
testQemuDataPtr data)
|
||||
void *opaque)
|
||||
{
|
||||
testQemuDataPtr data = (testQemuDataPtr) opaque;
|
||||
VIR_AUTOFREE(char *) title = NULL;
|
||||
VIR_AUTOFREE(char *) copyTitle = NULL;
|
||||
|
||||
|
@ -220,49 +221,8 @@ mymain(void)
|
|||
if (testQemuDataInit(&data) < 0)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
#define DO_TEST(arch, name) \
|
||||
do { \
|
||||
if (doCapsTest(name, arch, &data) < 0) \
|
||||
return EXIT_FAILURE; \
|
||||
} while (0)
|
||||
|
||||
/* Keep this in sync with qemucaps2xmltest */
|
||||
DO_TEST("x86_64", "caps_1.5.3");
|
||||
DO_TEST("x86_64", "caps_1.6.0");
|
||||
DO_TEST("x86_64", "caps_1.7.0");
|
||||
DO_TEST("x86_64", "caps_2.1.1");
|
||||
DO_TEST("x86_64", "caps_2.4.0");
|
||||
DO_TEST("x86_64", "caps_2.5.0");
|
||||
DO_TEST("x86_64", "caps_2.6.0");
|
||||
DO_TEST("x86_64", "caps_2.7.0");
|
||||
DO_TEST("x86_64", "caps_2.8.0");
|
||||
DO_TEST("x86_64", "caps_2.9.0");
|
||||
DO_TEST("x86_64", "caps_2.10.0");
|
||||
DO_TEST("x86_64", "caps_2.11.0");
|
||||
DO_TEST("x86_64", "caps_2.12.0");
|
||||
DO_TEST("x86_64", "caps_3.0.0");
|
||||
DO_TEST("x86_64", "caps_3.1.0");
|
||||
DO_TEST("x86_64", "caps_4.0.0");
|
||||
DO_TEST("aarch64", "caps_2.6.0");
|
||||
DO_TEST("aarch64", "caps_2.10.0");
|
||||
DO_TEST("aarch64", "caps_2.12.0");
|
||||
DO_TEST("ppc64", "caps_2.6.0");
|
||||
DO_TEST("ppc64", "caps_2.9.0");
|
||||
DO_TEST("ppc64", "caps_2.10.0");
|
||||
DO_TEST("ppc64", "caps_2.12.0");
|
||||
DO_TEST("ppc64", "caps_3.0.0");
|
||||
DO_TEST("ppc64", "caps_3.1.0");
|
||||
DO_TEST("s390x", "caps_2.7.0");
|
||||
DO_TEST("s390x", "caps_2.8.0");
|
||||
DO_TEST("s390x", "caps_2.9.0");
|
||||
DO_TEST("s390x", "caps_2.10.0");
|
||||
DO_TEST("s390x", "caps_2.11.0");
|
||||
DO_TEST("s390x", "caps_2.12.0");
|
||||
DO_TEST("s390x", "caps_3.0.0");
|
||||
DO_TEST("riscv32", "caps_3.0.0");
|
||||
DO_TEST("riscv32", "caps_4.0.0");
|
||||
DO_TEST("riscv64", "caps_3.0.0");
|
||||
DO_TEST("riscv64", "caps_4.0.0");
|
||||
if (testQemuCapsIterate(data.dataDir, ".replies", doCapsTest, &data) < 0)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
/*
|
||||
* Run "tests/qemucapsprobe /path/to/qemu/binary >foo.replies"
|
||||
|
|
|
@ -177,8 +177,9 @@ testQemuCapsXML(const void *opaque)
|
|||
static int
|
||||
doCapsTest(const char *base,
|
||||
const char *archName,
|
||||
testQemuDataPtr data)
|
||||
void *opaque)
|
||||
{
|
||||
testQemuDataPtr data = (testQemuDataPtr) opaque;
|
||||
VIR_AUTOFREE(char *) title = NULL;
|
||||
|
||||
if (virAsprintf(&title, "%s (%s)", base, archName) < 0)
|
||||
|
@ -211,49 +212,8 @@ mymain(void)
|
|||
if (testQemuDataInit(&data) < 0)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
#define DO_TEST(arch, name) \
|
||||
do { \
|
||||
if (doCapsTest(name, arch, &data) < 0) \
|
||||
return EXIT_FAILURE; \
|
||||
} while (0)
|
||||
|
||||
/* Keep this in sync with qemucapabilitiestest */
|
||||
DO_TEST("x86_64", "caps_1.5.3");
|
||||
DO_TEST("x86_64", "caps_1.6.0");
|
||||
DO_TEST("x86_64", "caps_1.7.0");
|
||||
DO_TEST("x86_64", "caps_2.1.1");
|
||||
DO_TEST("x86_64", "caps_2.4.0");
|
||||
DO_TEST("x86_64", "caps_2.5.0");
|
||||
DO_TEST("x86_64", "caps_2.6.0");
|
||||
DO_TEST("x86_64", "caps_2.7.0");
|
||||
DO_TEST("x86_64", "caps_2.8.0");
|
||||
DO_TEST("x86_64", "caps_2.9.0");
|
||||
DO_TEST("x86_64", "caps_2.10.0");
|
||||
DO_TEST("x86_64", "caps_2.11.0");
|
||||
DO_TEST("x86_64", "caps_2.12.0");
|
||||
DO_TEST("x86_64", "caps_3.0.0");
|
||||
DO_TEST("x86_64", "caps_3.1.0");
|
||||
DO_TEST("x86_64", "caps_4.0.0");
|
||||
DO_TEST("aarch64", "caps_2.6.0");
|
||||
DO_TEST("aarch64", "caps_2.10.0");
|
||||
DO_TEST("aarch64", "caps_2.12.0");
|
||||
DO_TEST("ppc64", "caps_2.6.0");
|
||||
DO_TEST("ppc64", "caps_2.9.0");
|
||||
DO_TEST("ppc64", "caps_2.10.0");
|
||||
DO_TEST("ppc64", "caps_2.12.0");
|
||||
DO_TEST("ppc64", "caps_3.0.0");
|
||||
DO_TEST("ppc64", "caps_3.1.0");
|
||||
DO_TEST("s390x", "caps_2.7.0");
|
||||
DO_TEST("s390x", "caps_2.8.0");
|
||||
DO_TEST("s390x", "caps_2.9.0");
|
||||
DO_TEST("s390x", "caps_2.10.0");
|
||||
DO_TEST("s390x", "caps_2.11.0");
|
||||
DO_TEST("s390x", "caps_2.12.0");
|
||||
DO_TEST("s390x", "caps_3.0.0");
|
||||
DO_TEST("riscv32", "caps_3.0.0");
|
||||
DO_TEST("riscv32", "caps_4.0.0");
|
||||
DO_TEST("riscv64", "caps_3.0.0");
|
||||
DO_TEST("riscv64", "caps_4.0.0");
|
||||
if (testQemuCapsIterate(data.inputDir, ".xml", doCapsTest, &data) < 0)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
return (data.ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue