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 <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2019-03-14 06:19:28 -04:00
parent f32d4e3e71
commit 320a1480d0

View File

@ -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, \