From patchwork Fri Jan 22 19:09:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 60181 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp40008lbb; Fri, 22 Jan 2016 11:12:33 -0800 (PST) X-Received: by 10.28.1.210 with SMTP id 201mr5401860wmb.90.1453489953029; Fri, 22 Jan 2016 11:12:33 -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 r186si5969206wmb.16.2016.01.22.11.12.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Jan 2016 11:12:33 -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 u0MJA58E005023; Fri, 22 Jan 2016 14:10:06 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u0MJ9U5e014292 for ; Fri, 22 Jan 2016 14:09:30 -0500 Received: from colepc.redhat.com (ovpn-113-198.phx2.redhat.com [10.3.113.198]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0MJ9Tfo004059; Fri, 22 Jan 2016 14:09:30 -0500 From: Cole Robinson To: libvirt-list@redhat.com Date: Fri, 22 Jan 2016 14:09:17 -0500 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 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())