From patchwork Thu Mar 14 14:44:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 160354 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp15595592jad; Thu, 14 Mar 2019 07:45:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOLEpifWF90Doa3ojgKvNaTFP2vMbZ59HRRG3/t1J94H9DuPXqv+A0dUgiMOISaHRb6FOS X-Received: by 2002:a0c:b89e:: with SMTP id y30mr39470805qvf.52.1552574713054; Thu, 14 Mar 2019 07:45:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552574713; cv=none; d=google.com; s=arc-20160816; b=Sc5YjQob8pii/9tD7fkAs+7g+Qajb4m5aGgXRVGQYhDZjVrUzDIjWlb/jv60aYpLz6 NiFw4qrhb++lPmbEXy9dwNYn+F8FSWnU8XSNBvpw5y/3eI5UeILShEiL4e55hsX1GS9Z 7leCdUp+/eoMxSc5tVpgyD0mReFdraRXbyrCtlOzqveDVaV2FSTTJM/jgHdiQy6i7aak K5Z5V6Z1+SeLrPUKYkFi4Qa1Ncaa/+VbJyeMuc9cfgmssQXpOg69t00MKBE9TEhzM88W PuxqWqUviMLidhuPGmCpr5TLTary2Uvz1KYjPGX9BTVjN3DacfeFtKsm1qCq/XHYVYnq HgJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=B8mgTd6LjVhQD+XPcMP1ivLHg9SzJxWb6QIkiiY8Nvk=; b=QFt2guNfObyxL5VJD5K3Pzq0StxPSySORWW/DFEn2wosnKWzvUEzyu/bXySkjaB4LX 87FP8hprZSbXgwIPBNOvYazOov8HFp9NrRrYa0huWYFSvPdX3hvkwsBbe9COW9+fVqMC 13GI36a2CgdThsq03YRyuFtx/Pw8zK+ANP+1a4sYWgDQFmEIj38JNjS8SLhVkfxM5TSB sMCjxTd0XXGVjLMlXK44djyskdhW45P9/X1ZZP2lqeeESImIfBH+nH8AfXXsGcO6n4Dq cu1lSUYArt78hFj1bvslVJfGORPGSp1DlouLwi0ptmj3BP+EMz0U9dVhseeFGPqIY0iK xobQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id z42si4519144qve.19.2019.03.14.07.45.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Mar 2019 07:45:13 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7A5CE30A187A; Thu, 14 Mar 2019 14:45:11 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 37A015D9C8; Thu, 14 Mar 2019 14:45:11 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C21A5181A274; Thu, 14 Mar 2019 14:45:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x2EEj9Zd024868 for ; Thu, 14 Mar 2019 10:45:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 55793610CA; Thu, 14 Mar 2019 14:45:09 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.redhat.com (ovpn-124-177.rdu2.redhat.com [10.10.124.177]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D68F61084; Thu, 14 Mar 2019 14:44:50 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Thu, 14 Mar 2019 10:44:12 -0400 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 19/21] tests: qemuxml2argv: move DO_TEST qemuCaps init X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Thu, 14 Mar 2019 14:45:12 +0000 (UTC) Move DO_TEST* qemuCaps init into testInfoSetArgs. This is a step towards unifying the different test macro implementations Signed-off-by: Cole Robinson --- tests/qemuxml2argvtest.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) -- 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Andrea Bolognani diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 813871d6b8..ff74892944 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -621,19 +621,21 @@ testInfoSetArgs(struct testInfo *info, ...) { va_list argptr; testInfoArgNames argname; + virQEMUCapsPtr qemuCaps = NULL; + int gic = GIC_NONE; int ret = -1; va_start(argptr, info); while ((argname = va_arg(argptr, int)) < ARG_END) { switch (argname) { case ARG_QEMU_CAPS: - virQEMUCapsSetVList(info->qemuCaps, argptr); + if (qemuCaps || !(qemuCaps = virQEMUCapsNew())) + goto cleanup; + virQEMUCapsSetVList(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: @@ -659,8 +661,20 @@ 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 && testQemuCapsSetGIC(info->qemuCaps, gic) < 0) + goto cleanup; + ret = 0; cleanup: + virObjectUnref(qemuCaps); va_end(argptr); return ret; } @@ -851,8 +865,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, \