From patchwork Sat Jan 9 00:13:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 59422 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp861009lbb; Fri, 8 Jan 2016 16:16:46 -0800 (PST) X-Received: by 10.28.98.133 with SMTP id w127mr1478484wmb.4.1452298606012; Fri, 08 Jan 2016 16:16:46 -0800 (PST) Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com. [209.132.183.37]) by mx.google.com with ESMTPS id et14si33595901wjc.67.2016.01.08.16.16.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Jan 2016 16:16:45 -0800 (PST) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u090ELLj058152; Fri, 8 Jan 2016 19:14:21 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.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 u090DVGj002880 for ; Fri, 8 Jan 2016 19:13:31 -0500 Received: from colepc.redhat.com (ovpn-113-33.phx2.redhat.com [10.3.113.33]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u090DSuD014481; Fri, 8 Jan 2016 19:13:31 -0500 From: Cole Robinson To: libvirt-list@redhat.com Date: Fri, 8 Jan 2016 19:13:23 -0500 Message-Id: <121f54b2531bcf0645a9d6023276ef0b208c0959.1452298382.git.crobinso@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/6] tests: qemuxml2xml: drop early file loading 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: , MIME-Version: 1.0 Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com For the standard active/inactive XML testing, if we leave the file loading up to the generic XML2XML infrastructure, we get the benefit of VIR_TEST_REGENERATE_OUTPUT, at the price of a few more disk reads. Seems worth it. --- tests/qemuxml2xmltest.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) -- 2.5.0 -- 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 312bb53..9482f6c 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -30,13 +30,8 @@ enum { struct testInfo { char *inName; - char *inFile; - char *outActiveName; - char *outActiveFile; - char *outInactiveName; - char *outInactiveFile; }; static int @@ -95,13 +90,19 @@ testCompareStatusXMLToXMLFiles(const void *opaque) char *expect = NULL; char *actual = NULL; char *source = NULL; + char *inFile = NULL, *outActiveFile = NULL; int ret = -1; int keepBlanksDefault = xmlKeepBlanksDefault(0); + if (virtTestLoadFile(data->inName, &inFile) < 0) + goto cleanup; + if (virtTestLoadFile(data->outActiveName, &outActiveFile) < 0) + goto cleanup; + /* construct faked source status XML */ virBufferAdd(&buf, testStatusXMLPrefix, -1); virBufferAdjustIndent(&buf, 2); - virBufferAddStr(&buf, data->inFile); + virBufferAddStr(&buf, inFile); virBufferAdjustIndent(&buf, -2); virBufferAdd(&buf, testStatusXMLSuffix, -1); @@ -113,7 +114,7 @@ testCompareStatusXMLToXMLFiles(const void *opaque) /* construct the expect string */ virBufferAdd(&buf, testStatusXMLPrefix, -1); virBufferAdjustIndent(&buf, 2); - virBufferAddStr(&buf, data->outActiveFile); + virBufferAddStr(&buf, outActiveFile); virBufferAdjustIndent(&buf, -2); virBufferAdd(&buf, testStatusXMLSuffix, -1); @@ -158,6 +159,8 @@ testCompareStatusXMLToXMLFiles(const void *opaque) VIR_FREE(expect); VIR_FREE(actual); VIR_FREE(source); + VIR_FREE(inFile); + VIR_FREE(outActiveFile); return ret; } @@ -166,13 +169,8 @@ static void testInfoFree(struct testInfo *info) { VIR_FREE(info->inName); - VIR_FREE(info->inFile); - VIR_FREE(info->outActiveName); - VIR_FREE(info->outActiveFile); - VIR_FREE(info->outInactiveName); - VIR_FREE(info->outInactiveFile); } @@ -186,9 +184,6 @@ testInfoSet(struct testInfo *info, abs_srcdir, name) < 0) goto error; - if (virtTestLoadFile(info->inName, &info->inFile) < 0) - goto error; - if (when & WHEN_INACTIVE) { if (different) { if (virAsprintf(&info->outInactiveName, @@ -208,9 +203,6 @@ testInfoSet(struct testInfo *info, if (VIR_STRDUP(info->outInactiveName, info->inName) < 0) goto error; } - - if (virtTestLoadFile(info->outInactiveName, &info->outInactiveFile) < 0) - goto error; } if (when & WHEN_ACTIVE) { @@ -233,8 +225,6 @@ testInfoSet(struct testInfo *info, goto error; } - if (virtTestLoadFile(info->outActiveName, &info->outActiveFile) < 0) - goto error; } return 0;