From patchwork Thu Mar 21 19:55:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 160816 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp1192476jan; Thu, 21 Mar 2019 12:55:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqxw815eeCln+HljAi4Ybaz1yWPMuN8TXZ18esHtVSNqQySpHPcMQxyXNDCG2JwST/vpdna2 X-Received: by 2002:a0c:a3c1:: with SMTP id v59mr4661121qvv.159.1553198123111; Thu, 21 Mar 2019 12:55:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553198123; cv=none; d=google.com; s=arc-20160816; b=mEh7R/CoiIOtc3fX/aAozTPE1WSKAuVvSR8O2P/h86yOBTSOBS9vou4JSy8cFDvERm 3uEvCynpeRDNPKxErtjqN7hs1Skb9xBiyAPfm4RLDmW6x1iiLzm2QWOLcVj4tTSHSBUj hIDJ9nlR9Bh91+Qm9CNu+0ga/orRC7YWejfefav7loOQ/qSnnm5/chPlEtZR01570DUh amHDFPXuVHfzuEVDq1vHBfnXRU+gydfnzqdMA4U+wmhwX1Q9D8QnP/Rx6ObyaZhcypFH oKdNCClPvw3zSsNS1fW5MASXeWL9XUvO3t6OeXn33+pBy+0PJHHBfFjwnMtvTa4Z/t9p db7A== 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=ydIKhMCWv92vdK09ODe0hHNpOK1wE8Dc5lH4dBH7FOw=; b=aDjyscOGVw+Mecz4qmEwgvFGNg4Ijc1lT31oXdEW0znsw9YBAbK9iO+gB7ksHfbBo8 35kCfAMfq/ssfPp/yEFF/nNmYz5AL9cKvYVjeIjS2ScATZ7rILGFDbe+bDvLoq5+8tx7 216C/jqJSQUzCyoEQ2KP9aW7x03hsL7LeI9OX2x55WOSoxJ+ITEDXbTCoHdqunYjCekf IwyG16JE5xgHBrLMnloCg9w7e3AVK/evJHFlsBKqk7ssD5/U4+rdxFVlivcvGw5PyZUA 2j6LlRTut8KQeXXbvM6UjhRrivy6Hlc0uBVHCWFCdkWL3yeF4Ik7xyqVUFdkoM0UD3/b 8E6A== 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 s24si3493123qkj.139.2019.03.21.12.55.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Mar 2019 12:55:23 -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 88C713D94D; Thu, 21 Mar 2019 19:55:21 +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 5C3AE5D9C5; Thu, 21 Mar 2019 19:55:21 +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 0F9271803387; Thu, 21 Mar 2019 19:55:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x2LJtHmE020710 for ; Thu, 21 Mar 2019 15:55:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 049234108; Thu, 21 Mar 2019 19:55:17 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.redhat.com (ovpn-121-55.rdu2.redhat.com [10.10.121.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D00E19C71; Thu, 21 Mar 2019 19:55:16 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Thu, 21 Mar 2019 15:55:04 -0400 Message-Id: <3591f921f167335d5d3cfe3fd9d97c246af9d515.1553197802.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 2/4] tests: qemuxml2argv: move DO_CAPS_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.30]); Thu, 21 Mar 2019 19:55:22 +0000 (UTC) Move DO_CAPS_TEST* qemuCaps init and all the associated setup into testInfoSetArgs, adding ARG_CAPS_ARCH and ARG_CAPS_VER options and using those to build the capsfile path locally Signed-off-by: Cole Robinson --- tests/qemuxml2argvtest.c | 69 +++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 22 deletions(-) -- 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index d982a497a9..191a43726d 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -605,6 +605,8 @@ testCompareXMLToArgv(const void *data) return ret; } +# define TEST_CAPS_PATH abs_srcdir "/qemucapabilitiesdata" + typedef enum { ARG_QEMU_CAPS, ARG_GIC, @@ -612,6 +614,8 @@ typedef enum { ARG_MIGRATE_FD, ARG_FLAGS, ARG_PARSEFLAGS, + ARG_CAPS_ARCH, + ARG_CAPS_VER, /* ARG_END is our va_args sentinel. The value QEMU_CAPS_LATEST is * necessary to handle the DO_TEST(..., NONE) case, which through macro @@ -628,15 +632,19 @@ typedef enum { } testInfoArgName; static int -testInfoSetArgs(struct testInfo *info, ...) +testInfoSetArgs(struct testInfo *info, + virHashTablePtr capslatest, ...) { va_list argptr; testInfoArgName argname; virQEMUCapsPtr qemuCaps = NULL; int gic = GIC_NONE; + char *capsarch = NULL; + char *capsver = NULL; + VIR_AUTOFREE(char *) capsfile = NULL; int ret = -1; - va_start(argptr, info); + va_start(argptr, capslatest); while ((argname = va_arg(argptr, testInfoArgName)) < ARG_END) { switch (argname) { case ARG_QEMU_CAPS: @@ -665,6 +673,14 @@ testInfoSetArgs(struct testInfo *info, ...) info->parseFlags = va_arg(argptr, int); break; + case ARG_CAPS_ARCH: + capsarch = va_arg(argptr, char *); + break; + + case ARG_CAPS_VER: + capsver = va_arg(argptr, char *); + break; + case ARG_END: default: fprintf(stderr, "Unexpected test info argument"); @@ -672,13 +688,32 @@ testInfoSetArgs(struct testInfo *info, ...) } } - if (!info->qemuCaps) { - if (!qemuCaps) { - fprintf(stderr, "No qemuCaps generated\n"); + if (!qemuCaps && capsarch && capsver) { + bool stripmachinealiases = false; + + if (STREQ(capsver, "latest")) { + if (VIR_STRDUP(capsfile, virHashLookup(capslatest, capsarch)) < 0) + goto cleanup; + stripmachinealiases = true; + } else if (virAsprintf(&capsfile, "%s/caps_%s.%s.xml", + TEST_CAPS_PATH, capsver, capsarch) < 0) { goto cleanup; } - VIR_STEAL_PTR(info->qemuCaps, qemuCaps); + + if (!(qemuCaps = qemuTestParseCapabilitiesArch(virArchFromString(capsarch), + capsfile))) + goto cleanup; + + if (stripmachinealiases) + virQEMUCapsStripMachineAliases(qemuCaps); + info->flags |= FLAG_REAL_CAPS; + } + + 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; @@ -819,28 +854,17 @@ mymain(void) * the test cases should be forked using DO_TEST_CAPS_VER with the appropriate * version. */ -# define TEST_CAPS_PATH abs_srcdir "/qemucapabilitiesdata" - # define DO_TEST_CAPS_INTERNAL(_name, arch, ver, ...) \ do { \ static struct testInfo info = { \ .name = _name, \ .suffix = "." arch "-" ver, \ }; \ - static const char *capsfile = TEST_CAPS_PATH "/caps_" ver "." arch ".xml"; \ - static bool stripmachinealiases; \ - if (STREQ(ver, "latest")) { \ - capsfile = virHashLookup(capslatest, arch); \ - stripmachinealiases = true; \ - } \ - if (!(info.qemuCaps = qemuTestParseCapabilitiesArch(virArchFromString(arch), \ - capsfile))) \ - return EXIT_FAILURE; \ - if (stripmachinealiases) \ - virQEMUCapsStripMachineAliases(info.qemuCaps); \ - if (testInfoSetArgs(&info, __VA_ARGS__, ARG_END) < 0) \ + if (testInfoSetArgs(&info, capslatest, \ + ARG_CAPS_ARCH, arch, \ + ARG_CAPS_VER, ver, \ + __VA_ARGS__, ARG_END) < 0) \ return EXIT_FAILURE; \ - info.flags |= FLAG_REAL_CAPS; \ if (virTestRun("QEMU XML-2-ARGV " _name "." arch "-" ver, \ testCompareXMLToArgv, &info) < 0) \ ret = -1; \ @@ -876,7 +900,8 @@ mymain(void) static struct testInfo info = { \ .name = _name, \ }; \ - if (testInfoSetArgs(&info, __VA_ARGS__, QEMU_CAPS_LAST, ARG_END) < 0) \ + if (testInfoSetArgs(&info, capslatest, \ + __VA_ARGS__, QEMU_CAPS_LAST, ARG_END) < 0) \ return EXIT_FAILURE; \ if (virTestRun("QEMU XML-2-ARGV " _name, \ testCompareXMLToArgv, &info) < 0) \