From patchwork Thu Jan 28 20:30:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 60760 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp711229lbb; Thu, 28 Jan 2016 12:44:29 -0800 (PST) X-Received: by 10.31.154.21 with SMTP id c21mr3606368vke.38.1454013869006; Thu, 28 Jan 2016 12:44:29 -0800 (PST) Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com. [209.132.183.39]) by mx.google.com with ESMTPS id d4si7444628vkf.90.2016.01.28.12.44.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jan 2016 12:44:28 -0800 (PST) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.39 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 mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0SKg5IW030560; Thu, 28 Jan 2016 15:42:05 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u0SKUItG026794 for ; Thu, 28 Jan 2016 15:30:18 -0500 Received: from colepc.redhat.com (ovpn-113-198.phx2.redhat.com [10.3.113.198]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0SKUGKi010886; Thu, 28 Jan 2016 15:30:17 -0500 From: Cole Robinson To: libvirt-list@redhat.com Date: Thu, 28 Jan 2016 15:30:06 -0500 Message-Id: <093c363fc005f3b4571750a6468b692f88c2f4b4.1454011611.git.crobinso@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/9] tests: Run test-wrap-argv with REGENERATE_OUTPUT 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 To get properly wrapped output --- tests/testutils.c | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) -- 2.5.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/tests/testutils.c b/tests/testutils.c index b587f83..10c26648 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -433,6 +433,32 @@ virtTestCaptureProgramOutput(const char *const argv[] ATTRIBUTE_UNUSED, } #endif /* !WIN32 */ +static int +virTestRewrapFile(const char *filename) +{ + int ret = -1; + char *outbuf = NULL; + char *script = NULL; + virCommandPtr cmd = NULL; + + if (virAsprintf(&script, "%s/test-wrap-argv.pl", abs_srcdir) < 0) + goto cleanup; + + cmd = virCommandNewArgList(script, filename, NULL); + virCommandSetOutputBuffer(cmd, &outbuf); + if (virCommandRun(cmd, NULL) < 0) + goto cleanup; + + if (virFileWriteStr(filename, outbuf, 0666) < 0) + goto cleanup; + + ret = 0; + cleanup: + VIR_FREE(script); + virCommandFree(cmd); + VIR_FREE(outbuf); + return ret; +} /** * @param stream: output stream to write differences to @@ -470,17 +496,15 @@ virtTestDifferenceFullInternal(FILE *stream, actualEnd = actual + (strlen(actual)-1); if (expectName && regenerate && (virTestGetRegenerate() > 0)) { - char *regencontent; - - /* Try to properly indent qemu argv files */ - if (!(regencontent = virStringReplace(actual, " -", " \\\n-"))) + if (virFileWriteStr(expectName, actual, 0666) < 0) { + virDispatchError(NULL); return -1; + } - if (virFileWriteStr(expectName, regencontent, 0666) < 0) { - VIR_FREE(regencontent); + if (virTestRewrapFile(expectName) < 0) { + virDispatchError(NULL); return -1; } - VIR_FREE(regencontent); } if (!virTestGetDebug())