qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/2] Remove test-qga temporary file
@ 2016-06-15 11:05 marcandre.lureau
  2016-06-15 11:06 ` [Qemu-devel] [PATCH v2 1/2] build-sys: link tests/data marcandre.lureau
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: marcandre.lureau @ 2016-06-15 11:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, mdroth, Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau@redhat.com>

Hi,

Here are 2 small patches to remove the need for temporary file
creation in test-qga.

v1->v2:
- use a symlink to tests/data instead of hardcoding SRC_PATH

Marc-André Lureau (2):
  build-sys: link tests/data
  tests: use static qga config file

 configure                  |  5 +++++
 tests/data/test-qga-config |  8 ++++++++
 tests/test-qga.c           | 27 ++++-----------------------
 3 files changed, 17 insertions(+), 23 deletions(-)
 create mode 100644 tests/data/test-qga-config

-- 
2.7.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH v2 1/2] build-sys: link tests/data
  2016-06-15 11:05 [Qemu-devel] [PATCH v2 0/2] Remove test-qga temporary file marcandre.lureau
@ 2016-06-15 11:06 ` marcandre.lureau
  2016-06-15 11:06 ` [Qemu-devel] [PATCH v2 2/2] tests: use static qga config file marcandre.lureau
  2016-06-30 15:28 ` [Qemu-devel] [PATCH v2 0/2] Remove test-qga temporary file Michael Roth
  2 siblings, 0 replies; 4+ messages in thread
From: marcandre.lureau @ 2016-06-15 11:06 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, mdroth, Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau@redhat.com>

Link a common tests data directory to the build directory.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 configure | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/configure b/configure
index 8c2f90b..c79234c 100755
--- a/configure
+++ b/configure
@@ -6008,6 +6008,11 @@ for rom in seabios vgabios ; do
     echo "LD=$ld" >> $config_mak
 done
 
+# set up tests data directory
+if [ ! -e tests/data ]; then
+    symlink "$source_path/tests/data" tests/data
+fi
+
 # set up qemu-iotests in this build directory
 iotests_common_env="tests/qemu-iotests/common.env"
 iotests_check="tests/qemu-iotests/check"
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH v2 2/2] tests: use static qga config file
  2016-06-15 11:05 [Qemu-devel] [PATCH v2 0/2] Remove test-qga temporary file marcandre.lureau
  2016-06-15 11:06 ` [Qemu-devel] [PATCH v2 1/2] build-sys: link tests/data marcandre.lureau
@ 2016-06-15 11:06 ` marcandre.lureau
  2016-06-30 15:28 ` [Qemu-devel] [PATCH v2 0/2] Remove test-qga temporary file Michael Roth
  2 siblings, 0 replies; 4+ messages in thread
From: marcandre.lureau @ 2016-06-15 11:06 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, mdroth, Marc-André Lureau

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/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)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/2] Remove test-qga temporary file
  2016-06-15 11:05 [Qemu-devel] [PATCH v2 0/2] Remove test-qga temporary file marcandre.lureau
  2016-06-15 11:06 ` [Qemu-devel] [PATCH v2 1/2] build-sys: link tests/data marcandre.lureau
  2016-06-15 11:06 ` [Qemu-devel] [PATCH v2 2/2] tests: use static qga config file marcandre.lureau
@ 2016-06-30 15:28 ` Michael Roth
  2 siblings, 0 replies; 4+ messages in thread
From: Michael Roth @ 2016-06-30 15:28 UTC (permalink / raw)
  To: marcandre.lureau, qemu-devel; +Cc: peter.maydell

Quoting marcandre.lureau@redhat.com (2016-06-15 06:05:59)
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> Hi,
> 
> Here are 2 small patches to remove the need for temporary file
> creation in test-qga.
> 
> v1->v2:
> - use a symlink to tests/data instead of hardcoding SRC_PATH
> 
> Marc-André Lureau (2):
>   build-sys: link tests/data
>   tests: use static qga config file

Thanks, applied to qga tree:
  https://github.com/mdroth/qemu/commits/qga

> 
>  configure                  |  5 +++++
>  tests/data/test-qga-config |  8 ++++++++
>  tests/test-qga.c           | 27 ++++-----------------------
>  3 files changed, 17 insertions(+), 23 deletions(-)
>  create mode 100644 tests/data/test-qga-config
> 
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-06-30 19:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-15 11:05 [Qemu-devel] [PATCH v2 0/2] Remove test-qga temporary file marcandre.lureau
2016-06-15 11:06 ` [Qemu-devel] [PATCH v2 1/2] build-sys: link tests/data marcandre.lureau
2016-06-15 11:06 ` [Qemu-devel] [PATCH v2 2/2] tests: use static qga config file marcandre.lureau
2016-06-30 15:28 ` [Qemu-devel] [PATCH v2 0/2] Remove test-qga temporary file Michael Roth

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).