From patchwork Mon Jan 4 19:31:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 59163 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp5549754lbb; Mon, 4 Jan 2016 11:34:51 -0800 (PST) X-Received: by 10.31.138.20 with SMTP id m20mr62456607vkd.70.1451936091751; Mon, 04 Jan 2016 11:34:51 -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 l76si73891965vke.108.2016.01.04.11.34.50 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Jan 2016 11:34:51 -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 u04JW6bZ022627; Mon, 4 Jan 2016 14:32:08 -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 u04JW57P003878 for ; Mon, 4 Jan 2016 14:32:05 -0500 Received: from colepc.redhat.com (ovpn-113-33.phx2.redhat.com [10.3.113.33]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u04JW4He012997; Mon, 4 Jan 2016 14:32:04 -0500 From: Cole Robinson To: libvirt-list@redhat.com Date: Mon, 4 Jan 2016 14:31:58 -0500 Message-Id: <4aba1552490509234ac6be10eb7c4534fa892287.1451935906.git.crobinso@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] tests: Add newlines with VIR_TEST_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 Since test files are formatted predictably nowadays, we can make VIR_TEST_REGENERATE_OUTPUT handle most cases for us with a simple replacement. test-wrap-argv.pl is still canon, but this bit makes it easier to confirm test output changes during active development. --- tests/testutils.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- 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 857e819..6487a62 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -598,6 +598,7 @@ virtTestCompareToFile(const char *strcontent, int ret = -1; char *filecontent = NULL; char *fixedcontent = NULL; + char *regencontent = NULL; bool regenerate = !!virTestGetFlag("VIR_TEST_REGENERATE_OUTPUT"); if (virtTestLoadFile(filename, &filecontent) < 0 && !regenerate) @@ -613,7 +614,10 @@ virtTestCompareToFile(const char *strcontent, if (STRNEQ_NULLABLE(fixedcontent ? fixedcontent : strcontent, filecontent)) { if (regenerate) { - if (virFileWriteStr(filename, strcontent, 0666) < 0) + if (!(regencontent = virStringReplace(strcontent, " -", " \\\n-"))) + goto failure; + + if (virFileWriteStr(filename, regencontent, 0666) < 0) goto failure; goto out; } @@ -626,6 +630,7 @@ virtTestCompareToFile(const char *strcontent, failure: VIR_FREE(fixedcontent); VIR_FREE(filecontent); + VIR_FREE(regencontent); return ret; }