From patchwork Wed Jun 15 11:06:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 9178161 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BC30960573 for ; Wed, 15 Jun 2016 11:06:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A94C227DF9 for ; Wed, 15 Jun 2016 11:06:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9DF5D2824A; Wed, 15 Jun 2016 11:06:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 199D127DF9 for ; Wed, 15 Jun 2016 11:06:37 +0000 (UTC) Received: from localhost ([::1]:41359 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bD8eZ-0007Js-Jz for patchwork-qemu-devel@patchwork.kernel.org; Wed, 15 Jun 2016 07:06:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48827) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bD8e8-0007Iy-Uo for qemu-devel@nongnu.org; Wed, 15 Jun 2016 07:06:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bD8e7-0003GO-Hf for qemu-devel@nongnu.org; Wed, 15 Jun 2016 07:06:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57591) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bD8e7-0003GK-9G for qemu-devel@nongnu.org; Wed, 15 Jun 2016 07:06:07 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E24FB6437F; Wed, 15 Jun 2016 11:06:06 +0000 (UTC) Received: from localhost (ovpn-116-80.phx2.redhat.com [10.3.116.80]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5FB65eb001415; Wed, 15 Jun 2016 07:06:06 -0400 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Date: Wed, 15 Jun 2016 13:06:01 +0200 Message-Id: <1465988761-23054-3-git-send-email-marcandre.lureau@redhat.com> In-Reply-To: <1465988761-23054-1-git-send-email-marcandre.lureau@redhat.com> References: <1465988761-23054-1-git-send-email-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 15 Jun 2016 11:06:06 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 2/2] tests: use static qga config file X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, mdroth@linux.vnet.ibm.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Marc-André Lureau Do not create a leaking temporary file, but use a static file instead. Signed-off-by: Marc-André Lureau Reported-by: Peter Maydell --- tests/data/test-qga-config | 8 ++++++++ tests/test-qga.c | 27 ++++----------------------- 2 files changed, 12 insertions(+), 23 deletions(-) create mode 100644 tests/data/test-qga-config diff --git a/tests/data/test-qga-config b/tests/data/test-qga-config new file mode 100644 index 0000000..4bb721a --- /dev/null +++ b/tests/data/test-qga-config @@ -0,0 +1,8 @@ +[general] +daemon=false +method=virtio-serial +path=/path/to/org.qemu.guest_agent.0 +pidfile=/var/foo/qemu-ga.pid +statedir=/var/state +verbose=true +blacklist=guest-ping;guest-get-time diff --git a/tests/test-qga.c b/tests/test-qga.c index 251b201..dac8fb8 100644 --- a/tests/test-qga.c +++ b/tests/test-qga.c @@ -691,28 +691,11 @@ static void test_qga_blacklist(gconstpointer data) static void test_qga_config(gconstpointer data) { GError *error = NULL; - char *cwd, *cmd, *out, *err, *str, **strv, *conf, **argv = NULL; + char *cwd, *cmd, *out, *err, *str, **strv, **argv = NULL; char *env[2]; - int status, tmp; + int status; gsize n; GKeyFile *kf; - const char *qga_config = - "[general]\n" - "daemon=false\n" - "method=virtio-serial\n" - "path=/path/to/org.qemu.guest_agent.0\n" - "pidfile=/var/foo/qemu-ga.pid\n" - "statedir=/var/state\n" - "verbose=true\n" - "blacklist=guest-ping;guest-get-time\n"; - - tmp = g_file_open_tmp(NULL, &conf, &error); - g_assert_no_error(error); - g_assert_cmpint(tmp, >=, 0); - g_assert_cmpstr(conf, !=, ""); - - g_file_set_contents(conf, qga_config, -1, &error); - g_assert_no_error(error); cwd = g_get_current_dir(); cmd = g_strdup_printf("%s%cqemu-ga -D", @@ -720,7 +703,8 @@ static void test_qga_config(gconstpointer data) g_shell_parse_argv(cmd, NULL, &argv, &error); g_assert_no_error(error); - env[0] = g_strdup_printf("QGA_CONF=%s", conf); + env[0] = g_strdup_printf("QGA_CONF=tests%cdata%ctest-qga-config", + G_DIR_SEPARATOR, G_DIR_SEPARATOR); env[1] = NULL; g_spawn_sync(NULL, argv, env, 0, NULL, NULL, &out, &err, &status, &error); @@ -775,11 +759,8 @@ static void test_qga_config(gconstpointer data) g_free(out); g_free(err); - g_free(conf); g_free(env[0]); g_key_file_free(kf); - - close(tmp); } static void test_qga_fsfreeze_status(gconstpointer fix)