From patchwork Wed Jan 13 23:03:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 59688 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp3654826lbb; Wed, 13 Jan 2016 15:07:11 -0800 (PST) X-Received: by 10.31.21.210 with SMTP id 201mr545768vkv.132.1452726431872; Wed, 13 Jan 2016 15:07:11 -0800 (PST) Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com. [209.132.183.25]) by mx.google.com with ESMTPS id h198si3322691vka.134.2016.01.13.15.07.10 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 13 Jan 2016 15:07:11 -0800 (PST) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.25 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 mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u0DN4bJp000655; Wed, 13 Jan 2016 18:04:37 -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 u0DN42fn029324 for ; Wed, 13 Jan 2016 18:04:02 -0500 Received: from colepc.redhat.com (ovpn-113-150.phx2.redhat.com [10.3.113.150]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0DN3xq6014131; Wed, 13 Jan 2016 18:04:01 -0500 From: Cole Robinson To: libvirt-list@redhat.com Date: Wed, 13 Jan 2016 18:03:45 -0500 Message-Id: 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 1/8] 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())