From patchwork Sun Jan 13 23:12: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: 155385 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3040690jaa; Sun, 13 Jan 2019 15:13:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN4nW+NnYwKq/Nai4nn9Ng2TbLVhrPtubamMmKO+yQA9KctobFZ6rDLhGsA476JNF9UHtqu/ X-Received: by 2002:a37:6801:: with SMTP id d1mr19902901qkc.283.1547421223622; Sun, 13 Jan 2019 15:13:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547421223; cv=none; d=google.com; s=arc-20160816; b=Xes6/a/6KUj12wZf01/RjGXaibYS7PR5tfVQRMuisr8+iGGv00IMItYVrP6m7wDovI BnDZLnb3qHYL7EqPB2ydtl/T2NtaFAr6dBIbEjfILPYZvWskhuhGOeGkG2oFDazNhvuu SzBxRRrVsvm/E3tsHnwc5E2zMtIlmb+1BusZHt216oEUOgL8k+iqJzG7VTJgC/vzlUiL e4IIsHItg/SFl+n9JFaEr1FPwAQJcC5THp1AH5EbtZbptHgDr6O+lOALHWDW98lrOEkO dlQ2t9P+VLa86JQwSF8mZvO4tdYwFB0o1bIN0VyOmuD4Di6j6eGItT+5a+/qWGR6y0WS CY9g== 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=v4eIx+oDFMQQWW0oo41Zn9CdfITn7djH7sH2aBTmSP0=; b=SNpi1fLzAo/oSsusyq+lggJOqVZBb4gtYRdIaklmA05HJysuTrfdlx9yqC38yUscTr ofh4F29L7i3DMsBkBGA4cT9saw5NkCZRZJov7PGg723wMAuQO1B1mQMF06CAOzA7Oc1N xGYMn3SQqpD7EJQCIa3eY/xyAly3OIZKoxoRiCsoDDq6jwxJA/6NADAmAYW/4QfUKB8K xsbLlSFChbKZ3NbvYAsoobM7fll2urnASdtx/czU81AV9IBkMutD0SBcm/EPOP+jLMU7 TWmEqycrWnymszLEEOEF+xUXRvRFUZ5C2yJcNsqXC6ca1zBJVDGCXC+HeStn3+FTTdK0 JoMQ== 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 k15si10903427qvc.27.2019.01.13.15.13.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 13 Jan 2019 15:13:43 -0800 (PST) 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 4020F356D5; Sun, 13 Jan 2019 23:13:42 +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 08C328378B; Sun, 13 Jan 2019 23:13:42 +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 AF4E418436BF; Sun, 13 Jan 2019 23:13:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0DND9U5028614 for ; Sun, 13 Jan 2019 18:13:09 -0500 Received: by smtp.corp.redhat.com (Postfix) id E4AB617A9F; Sun, 13 Jan 2019 23:13:09 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.redhat.com (ovpn-120-202.rdu2.redhat.com [10.10.120.202]) by smtp.corp.redhat.com (Postfix) with ESMTP id 49904608DC; Sun, 13 Jan 2019 23:13:09 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Sun, 13 Jan 2019 18:12:04 -0500 Message-Id: <0cfd161706183af03ce62bd43b8c4ed062661031.1547420060.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/6] tests: qemuxml2xml: Add basic DO_TEST_CAPS impl 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.30]); Sun, 13 Jan 2019 23:13:42 +0000 (UTC) Signed-off-by: Cole Robinson --- tests/qemuxml2xmltest.c | 57 ++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 15 deletions(-) -- 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 82e2c0ee0f..b686a585e8 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -117,10 +117,10 @@ testInfoClear(struct testInfo *info) static int testInfoSetCommon(struct testInfo *info, - int gic) + int gic, + virQEMUCapsPtr qemuCaps) { - if (!(info->qemuCaps = virQEMUCapsNew())) - goto error; + info->qemuCaps = qemuCaps; if (testQemuCapsSetGIC(info->qemuCaps, gic) < 0) goto error; @@ -140,9 +140,10 @@ static int testInfoSet(struct testInfo *info, const char *name, int when, - int gic) + int gic, + virQEMUCapsPtr qemuCaps) { - if (testInfoSetCommon(info, gic) < 0) + if (testInfoSetCommon(info, gic, qemuCaps) < 0) return -1; if (virAsprintf(&info->inName, "%s/qemuxml2argvdata/%s.xml", @@ -194,9 +195,10 @@ static const char *statusPath = abs_srcdir "/qemustatusxml2xmldata/"; static int testInfoSetStatus(struct testInfo *info, const char *name, - int gic) + int gic, + virQEMUCapsPtr qemuCaps) { - if (testInfoSetCommon(info, gic) < 0) + if (testInfoSetCommon(info, gic, qemuCaps) < 0) return -1; if (virAsprintf(&info->inName, "%s%s-in.xml", statusPath, name) < 0 || @@ -220,6 +222,7 @@ mymain(void) char *fakerootdir; struct testInfo info; virQEMUDriverConfigPtr cfg = NULL; + virQEMUCapsPtr qemuCaps = NULL; if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) { fprintf(stderr, "Out of memory\n"); @@ -240,14 +243,8 @@ mymain(void) cfg = virQEMUDriverGetConfig(&driver); -# define DO_TEST_FULL(name, when, gic, ...) \ +# define DO_TEST_RUN(name, info) \ do { \ - if (testInfoSet(&info, name, when, gic) < 0) { \ - VIR_TEST_DEBUG("Failed to generate test data for '%s'", name); \ - return -1; \ - } \ - virQEMUCapsSetList(info.qemuCaps, __VA_ARGS__, QEMU_CAPS_LAST); \ - \ if (info.outInactiveName) { \ if (virTestRun("QEMU XML-2-XML-inactive " name, \ testXML2XMLInactive, &info) < 0) \ @@ -262,6 +259,34 @@ mymain(void) testInfoClear(&info); \ } while (0) +# define DO_TEST_FULL(name, when, gic, ...) \ + do { \ + if (!(qemuCaps = virQEMUCapsNew())) \ + return -1; \ + if (testInfoSet(&info, name, when, gic, qemuCaps) < 0) { \ + VIR_TEST_DEBUG("Failed to generate test data for '%s'", name); \ + return -1; \ + } \ + virQEMUCapsSetList(info.qemuCaps, __VA_ARGS__, QEMU_CAPS_LAST); \ + DO_TEST_RUN(name, info); \ + } while (0) + +# define TEST_CAPS_PATH abs_srcdir "/qemucapabilitiesdata/caps_" + +# define DO_TEST_CAPS(name, arch, ver) \ + do { \ + if (!(qemuCaps = qemuTestParseCapabilitiesArch(virArchFromString(arch), \ + TEST_CAPS_PATH ver "." arch ".xml"))) { \ + printf("bad\n"); \ + return -1; \ + } \ + if (testInfoSet(&info, name, WHEN_BOTH, GIC_NONE, qemuCaps) < 0) { \ + VIR_TEST_DEBUG("Failed to generate test data for '%s'", name); \ + return -1; \ + } \ + DO_TEST_RUN(name, info); \ + } while (0) + # define NONE QEMU_CAPS_LAST # define DO_TEST(name, ...) \ @@ -1233,7 +1258,9 @@ mymain(void) # define DO_TEST_STATUS(name) \ do { \ - if (testInfoSetStatus(&info, name, GIC_NONE) < 0) { \ + if (!(qemuCaps = virQEMUCapsNew())) \ + return -1; \ + if (testInfoSetStatus(&info, name, GIC_NONE, qemuCaps) < 0) { \ VIR_TEST_DEBUG("Failed to generate status test data for '%s'", name); \ return -1; \ } \