From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36155) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bRlBc-0002NE-Rk for qemu-devel@nongnu.org; Mon, 25 Jul 2016 15:05:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bRlBY-0000LR-KA for qemu-devel@nongnu.org; Mon, 25 Jul 2016 15:05:07 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:31665 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bRlBY-0000LN-EQ for qemu-devel@nongnu.org; Mon, 25 Jul 2016 15:05:04 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u6PJ4qJu039800 for ; Mon, 25 Jul 2016 15:05:04 -0400 Received: from e37.co.us.ibm.com (e37.co.us.ibm.com [32.97.110.158]) by mx0b-001b2d01.pphosted.com with ESMTP id 24dnc57dwt-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 25 Jul 2016 15:05:03 -0400 Received: from localhost by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 25 Jul 2016 13:05:03 -0600 From: Michael Roth Date: Mon, 25 Jul 2016 14:04:26 -0500 In-Reply-To: <1469473467-16316-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1469473467-16316-1-git-send-email-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Message-Id: <1469473467-16316-3-git-send-email-mdroth@linux.vnet.ibm.com> Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL for-2.7 2/3] tests: use static qga config file List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= From: Marc-Andr=C3=A9 Lureau Do not create a leaking temporary file, but use a static file instead. Signed-off-by: Marc-Andr=C3=A9 Lureau Reported-by: Peter Maydell Signed-off-by: Michael Roth --- 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=3Dfalse +method=3Dvirtio-serial +path=3D/path/to/org.qemu.guest_agent.0 +pidfile=3D/var/foo/qemu-ga.pid +statedir=3D/var/state +verbose=3Dtrue +blacklist=3Dguest-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 =3D NULL; - char *cwd, *cmd, *out, *err, *str, **strv, *conf, **argv =3D NULL; + char *cwd, *cmd, *out, *err, *str, **strv, **argv =3D NULL; char *env[2]; - int status, tmp; + int status; gsize n; GKeyFile *kf; - const char *qga_config =3D - "[general]\n" - "daemon=3Dfalse\n" - "method=3Dvirtio-serial\n" - "path=3D/path/to/org.qemu.guest_agent.0\n" - "pidfile=3D/var/foo/qemu-ga.pid\n" - "statedir=3D/var/state\n" - "verbose=3Dtrue\n" - "blacklist=3Dguest-ping;guest-get-time\n"; - - tmp =3D g_file_open_tmp(NULL, &conf, &error); - g_assert_no_error(error); - g_assert_cmpint(tmp, >=3D, 0); - g_assert_cmpstr(conf, !=3D, ""); - - g_file_set_contents(conf, qga_config, -1, &error); - g_assert_no_error(error); =20 cwd =3D g_get_current_dir(); cmd =3D 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); =20 - env[0] =3D g_strdup_printf("QGA_CONF=3D%s", conf); + env[0] =3D g_strdup_printf("QGA_CONF=3Dtests%cdata%ctest-qga-config"= , + G_DIR_SEPARATOR, G_DIR_SEPARATOR); env[1] =3D 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) =20 g_free(out); g_free(err); - g_free(conf); g_free(env[0]); g_key_file_free(kf); - - close(tmp); } =20 static void test_qga_fsfreeze_status(gconstpointer fix) --=20 1.9.1