diff mbox series

[v3,23/54] tests/unit: test-qga: Avoid using hardcoded /tmp

Message ID 20220925113032.1949844-24-bmeng.cn@gmail.com (mailing list archive)
State New, archived
Headers show
Series tests/qtest: Enable running qtest on Windows | expand

Commit Message

Bin Meng Sept. 25, 2022, 11:30 a.m. UTC
From: Bin Meng <bin.meng@windriver.com>

This case was written to use hardcoded /tmp directory for temporary
files. Update to use g_get_tmp_dir() for a portable implementation.

Signed-off-by: Bin Meng <bin.meng@windriver.com>
---

Changes in v3:
- Split to a separate patch

 tests/unit/test-qga.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Marc-André Lureau Sept. 26, 2022, 1:23 p.m. UTC | #1
On Sun, Sep 25, 2022 at 3:57 PM Bin Meng <bmeng.cn@gmail.com> wrote:

> From: Bin Meng <bin.meng@windriver.com>
>
> This case was written to use hardcoded /tmp directory for temporary
> files. Update to use g_get_tmp_dir() for a portable implementation.
>
> Signed-off-by: Bin Meng <bin.meng@windriver.com>
>

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


> ---
>
> Changes in v3:
> - Split to a separate patch
>
>  tests/unit/test-qga.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tests/unit/test-qga.c b/tests/unit/test-qga.c
> index b6ea7c7304..b4e0a14573 100644
> --- a/tests/unit/test-qga.c
> +++ b/tests/unit/test-qga.c
> @@ -60,7 +60,7 @@ fixture_setup(TestFixture *fixture, gconstpointer data,
> gchar **envp)
>
>      fixture->loop = g_main_loop_new(NULL, FALSE);
>
> -    fixture->test_dir = g_strdup("/tmp/qgatest.XXXXXX");
> +    fixture->test_dir = g_strdup_printf("%s/qgatest.XXXXXX",
> g_get_tmp_dir());
>      g_assert_nonnull(g_mkdtemp(fixture->test_dir));
>
>      path = g_build_filename(fixture->test_dir, "sock", NULL);
> --
> 2.34.1
>
>
>
diff mbox series

Patch

diff --git a/tests/unit/test-qga.c b/tests/unit/test-qga.c
index b6ea7c7304..b4e0a14573 100644
--- a/tests/unit/test-qga.c
+++ b/tests/unit/test-qga.c
@@ -60,7 +60,7 @@  fixture_setup(TestFixture *fixture, gconstpointer data, gchar **envp)
 
     fixture->loop = g_main_loop_new(NULL, FALSE);
 
-    fixture->test_dir = g_strdup("/tmp/qgatest.XXXXXX");
+    fixture->test_dir = g_strdup_printf("%s/qgatest.XXXXXX", g_get_tmp_dir());
     g_assert_nonnull(g_mkdtemp(fixture->test_dir));
 
     path = g_build_filename(fixture->test_dir, "sock", NULL);