From patchwork Thu Mar 14 14:43:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 160339 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp15594957jad; Thu, 14 Mar 2019 07:44:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwi3uUrFkCoxL9IugPjjzN6R+zPAnz+Sbt2A848lFpypUcXozxvEIxHHuzdIZafcJLThRIw X-Received: by 2002:aed:22d6:: with SMTP id q22mr39280782qtc.171.1552574676357; Thu, 14 Mar 2019 07:44:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552574676; cv=none; d=google.com; s=arc-20160816; b=QKwXHkWK/U2GjK/VKHnQB4PbVgf2g4FGy9VDoctwSuFcxWFmCffwQFTxKnPrcQ0Wso Pz5t7ywFFouFBYMvJUK1DwtWF3X+Hf2wTI+T2VrKS5Mkhg7L7uEFpZ+CXwPcfJ1GdHgR cmVUEN4/abYUwcU2E/BLsj0UK06X/8kSlFm1iXsrhp/7v3VsZsXA0j7HI/veQ6LXlHZs A+7rr8qKBFUPw2otMC5rrIpbfJYLb/EWRqB022YvoSSbQhPga3V96nmZcboupXD96CD1 xzy6bBKXml2yH8zDXe+2CbUNMbq5eKfZSBLRne9FQKwyJtoZu6ju2doKG3w/bcJbQdIQ 4imw== 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=DLBTGL/AMNBIE7WeYPuo4lZISk/byx2ludVobCj4mQk=; b=gbE1fwVwD7UoNKMmMJjmFptGKfn4u0frizGsv5bgZ+2KaKfReI1CxT6BQzK3/Mb1DB xw157GYDb331ejhZEy2A29LahRPYGnZa3z4nUMmp6AktuPDkOpI1DRDVbdujSGtfYPUY /b17I7tuCa8+fuDnJWAaNjfAbnUAvV4KgxAETWfGvNPM1S+RCszkbzYu5thokNIrX0at TEalI+nSXpL/3M0uLF3BDZRQxkXfYjByL2jKiEYcTxWX3RQeC3ama8P8pMbkFIFSs1j1 08b9odm0onfSVZQi/o6BHCAT1uEJ4dPS0SfGcZbSc/S9jvmb3GGnGd/I5AmMlTmcZbB2 WjkA== 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 z2si1642422qti.353.2019.03.14.07.44.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Mar 2019 07:44:36 -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-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 01BE330018C2; Thu, 14 Mar 2019 14:44:35 +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 C9C1D4C4; Thu, 14 Mar 2019 14:44:34 +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 8A832181A263; Thu, 14 Mar 2019 14:44:34 +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 x2EEiNUM024495 for ; Thu, 14 Mar 2019 10:44:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3C8CE60FAB; Thu, 14 Mar 2019 14:44:23 +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 CC97160BE6; Thu, 14 Mar 2019 14:44:22 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Thu, 14 Mar 2019 10:43:56 -0400 Message-Id: <185092267f0b872f526bd5b9f17372ce252b53da.1552574299.git.crobinso@redhat.com> 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 03/21] tests: qemuxml2argv: add va_arg enum handling 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 14 Mar 2019 14:44:35 +0000 (UTC) This establishes a pattern that will allow us to make test macros more general purpose, by taking optional arguments. The general format will be: DO_TEST_FULL(... ARG_FOO, , ARG_BAR, ) ARG_X are just enum values that we look for in the va_args and know how to interpret. Implement this for the existing implicit qemuCaps va_args Signed-off-by: Cole Robinson --- tests/qemuxml2argvtest.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 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 3b90cd1873..0dba908c70 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -624,14 +624,35 @@ testCompareXMLToArgv(const void *data) return ret; } +typedef enum { + ARG_QEMU_CAPS = 1, + + ARG_END = QEMU_CAPS_LAST, +} testInfoArgNames; + static int testInfoSetArgs(struct testInfo *info, ...) { va_list argptr; - int ret = 0; + testInfoArgNames argname; + int ret = -1; va_start(argptr, info); - virQEMUCapsSetVList(info->qemuCaps, argptr); + while ((argname = va_arg(argptr, int)) < ARG_END) { + switch (argname) { + case ARG_QEMU_CAPS: + virQEMUCapsSetVList(info->qemuCaps, argptr); + break; + + case ARG_END: + default: + fprintf(stderr, "Unexpected test info argument"); + goto cleanup; + } + } + + ret = 0; + cleanup: va_end(argptr); return ret; } @@ -821,7 +842,8 @@ mymain(void) }; \ if (testInitQEMUCaps(&info, gic) < 0) \ return EXIT_FAILURE; \ - if (testInfoSetArgs(&info, __VA_ARGS__, QEMU_CAPS_LAST) < 0) \ + if (testInfoSetArgs(&info, ARG_QEMU_CAPS, \ + __VA_ARGS__, QEMU_CAPS_LAST, ARG_END) < 0) \ return EXIT_FAILURE; \ if (virTestRun("QEMU XML-2-ARGV " name, \ testCompareXMLToArgv, &info) < 0) \