aboutsummaryrefslogtreecommitdiff
path: root/tests/test-qga.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2016-06-15 13:06:01 +0200
committerMichael Roth <mdroth@linux.vnet.ibm.com>2016-07-25 13:23:18 -0500
commit1741b945f245dd51018fb31748d302eda1ddaafd (patch)
treeca6019a3ed521b88c6d3b4b4f7a69cfdfa46607a /tests/test-qga.c
parentfe31017f79e591463599de30b11b24835f10f18b (diff)
tests: use static qga config file
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> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Diffstat (limited to 'tests/test-qga.c')
-rw-r--r--tests/test-qga.c27
1 files changed, 4 insertions, 23 deletions
diff --git a/tests/test-qga.c b/tests/test-qga.c
index 251b20190c..dac8fb8c0a 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)