From patchwork Wed Apr 20 17:33:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 66228 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp2581857qge; Wed, 20 Apr 2016 10:35:53 -0700 (PDT) X-Received: by 10.140.20.204 with SMTP id 70mr12751731qgj.38.1461173750870; Wed, 20 Apr 2016 10:35:50 -0700 (PDT) Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com. [209.132.183.25]) by mx.google.com with ESMTPS id z17si4806786qka.125.2016.04.20.10.35.49 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 20 Apr 2016 10:35:50 -0700 (PDT) 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 u3KHX5I2010696; Wed, 20 Apr 2016 13:33:06 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u3KHX4Ft020802 for ; Wed, 20 Apr 2016 13:33:04 -0400 Received: from colepc.redhat.com (ovpn-113-99.phx2.redhat.com [10.3.113.99]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3KHX3gp020609; Wed, 20 Apr 2016 13:33:03 -0400 From: Cole Robinson To: libvirt-list@redhat.com Date: Wed, 20 Apr 2016 13:33:00 -0400 Message-Id: <6f895b748c76b799dd4f2b0f4b96fd20562a5310.1461173530.git.crobinso@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] tests: Use system() for test-wrap-argv.pl 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 virCommand doesn't buy us anything here, and this simplifies the code. There's another usage of system() in testutils.c already FWIW, though it predates virCommand --- Had this sitting in a branch from an earlier discussion... I figure system() is safe in the test suite but I'm not going to argue if someone feels strongly the other way tests/testutils.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) -- 2.7.3 -- 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 79d0763..7664b06 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -432,28 +432,14 @@ virtTestCaptureProgramOutput(const char *const argv[] ATTRIBUTE_UNUSED, 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; + char *cmd; - if (virFileWriteStr(filename, outbuf, 0666) < 0) - goto cleanup; + /* The 'echo' syntax lets us read and write the file in one shot */ + if (virAsprintf(&cmd, "echo \"$(%s/test-wrap-argv.pl %s)\" > %s", + abs_srcdir, filename, filename) < 0) + return -1; - ret = 0; - cleanup: - VIR_FREE(script); - virCommandFree(cmd); - VIR_FREE(outbuf); - return ret; + return system(cmd); } /**