From 320a1480d0dbe77ae9da08b6ce6c3ad5e2706b63 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Thu, 14 Mar 2019 06:19:28 -0400 Subject: [PATCH] tests: qemuxml2argv: move DO_TEST qemuCaps init Move DO_TEST* qemuCaps init into testInfoSetArgs. This is a step towards unifying the different test macro implementations Reviewed-by: Andrea Bolognani Signed-off-by: Cole Robinson --- tests/qemuxml2argvtest.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 004d3b4c4f..14d3df02a9 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -632,19 +632,21 @@ testInfoSetArgs(struct testInfo *info, ...) { va_list argptr; testInfoArgName argname; + virQEMUCapsPtr qemuCaps = NULL; + int gic = GIC_NONE; int ret = -1; va_start(argptr, info); while ((argname = va_arg(argptr, testInfoArgName)) < ARG_END) { switch (argname) { case ARG_QEMU_CAPS: - virQEMUCapsSetVAList(info->qemuCaps, argptr); + if (qemuCaps || !(qemuCaps = virQEMUCapsNew())) + goto cleanup; + virQEMUCapsSetVAList(qemuCaps, argptr); break; case ARG_GIC: - if (testQemuCapsSetGIC(info->qemuCaps, - va_arg(argptr, int)) < 0) - goto cleanup; + gic = va_arg(argptr, int); break; case ARG_MIGRATE_FROM: @@ -670,9 +672,21 @@ testInfoSetArgs(struct testInfo *info, ...) } } + if (!info->qemuCaps) { + if (!qemuCaps) { + fprintf(stderr, "No qemuCaps generated\n"); + goto cleanup; + } + VIR_STEAL_PTR(info->qemuCaps, qemuCaps); + } + + if (gic != GIC_NONE && testQemuCapsSetGIC(info->qemuCaps, gic) < 0) + goto cleanup; + ret = 0; cleanup: + virObjectUnref(qemuCaps); va_end(argptr); return ret; @@ -862,8 +876,6 @@ mymain(void) static struct testInfo info = { \ .name = _name, \ }; \ - if (!(info.qemuCaps = virQEMUCapsNew())) \ - return EXIT_FAILURE; \ if (testInfoSetArgs(&info, __VA_ARGS__, QEMU_CAPS_LAST, ARG_END) < 0) \ return EXIT_FAILURE; \ if (virTestRun("QEMU XML-2-ARGV " _name, \