From: "Marc-André Lureau" <mlureau@redhat.com>
To: marcandre lureau <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org, peter maydell <peter.maydell@linaro.org>,
mdroth@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH] tests: use static qga config file
Date: Mon, 13 Jun 2016 08:30:59 -0400 (EDT) [thread overview]
Message-ID: <198901162.5803520.1465821059076.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <1465820746-25664-1-git-send-email-marcandre.lureau@redhat.com>
Hi
----- Original Message -----
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Do not create a leaking temporary file, but use a static file instead.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> tests/test-qga-config | 8 ++++++++
> tests/test-qga.c | 27 ++++-----------------------
> 2 files changed, 12 insertions(+), 23 deletions(-)
> create mode 100644 tests/test-qga-config
>
> diff --git a/tests/test-qga-config b/tests/test-qga-config
> new file mode 100644
> index 0000000..4bb721a
> --- /dev/null
> +++ b/tests/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..7d206ec 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=%s%ctests%ctest-qga-config",
> + cwd, G_DIR_SEPARATOR, G_DIR_SEPARATOR);
Actually instead of cwd here, it would be nice to have srcdir or testdir. There is g_test_build_filename() in glib 2.38, not sure what we should do without it. Ideas?
> 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)
> --
> 2.7.4
>
>
next prev parent reply other threads:[~2016-06-13 12:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-13 12:25 [Qemu-devel] [PATCH] tests: use static qga config file marcandre.lureau
2016-06-13 12:30 ` Marc-André Lureau [this message]
2016-06-13 16:08 ` Michael Roth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=198901162.5803520.1465821059076.JavaMail.zimbra@redhat.com \
--to=mlureau@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).