diff options
author | Bin Meng <bin.meng@windriver.com> | 2022-09-25 19:29:46 +0800 |
---|---|---|
committer | Thomas Huth <thuth@redhat.com> | 2022-09-27 20:51:20 +0200 |
commit | 39180d4e944caa0a9818f73acc4fadc2fbd2f422 (patch) | |
tree | 7d39da2c85308a08b0d314b999820bc7f2d22567 | |
parent | 4bcea44b9af7981e2074c74298e89ea3f97a3174 (diff) | |
download | qemu-39180d4e944caa0a9818f73acc4fadc2fbd2f422.zip qemu-39180d4e944caa0a9818f73acc4fadc2fbd2f422.tar.gz qemu-39180d4e944caa0a9818f73acc4fadc2fbd2f422.tar.bz2 |
tests/qtest: cxl-test: Avoid using hardcoded /tmp
This case was written to use hardcoded /tmp directory for temporary
files. Update to use g_dir_make_tmp() for a portable implementation.
Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20220925113032.1949844-9-bmeng.cn@gmail.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
-rw-r--r-- | tests/qtest/cxl-test.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/tests/qtest/cxl-test.c b/tests/qtest/cxl-test.c index 2e14da7..cbe0fb5 100644 --- a/tests/qtest/cxl-test.c +++ b/tests/qtest/cxl-test.c @@ -93,10 +93,9 @@ static void cxl_2root_port(void) static void cxl_t3d(void) { g_autoptr(GString) cmdline = g_string_new(NULL); - char template[] = "/tmp/cxl-test-XXXXXX"; - const char *tmpfs; + g_autofree const char *tmpfs = NULL; - tmpfs = g_mkdtemp(template); + tmpfs = g_dir_make_tmp("cxl-test-XXXXXX", NULL); g_string_printf(cmdline, QEMU_PXB_CMD QEMU_RP QEMU_T3D, tmpfs, tmpfs); @@ -107,10 +106,9 @@ static void cxl_t3d(void) static void cxl_1pxb_2rp_2t3d(void) { g_autoptr(GString) cmdline = g_string_new(NULL); - char template[] = "/tmp/cxl-test-XXXXXX"; - const char *tmpfs; + g_autofree const char *tmpfs = NULL; - tmpfs = g_mkdtemp(template); + tmpfs = g_dir_make_tmp("cxl-test-XXXXXX", NULL); g_string_printf(cmdline, QEMU_PXB_CMD QEMU_2RP QEMU_2T3D, tmpfs, tmpfs, tmpfs, tmpfs); @@ -122,10 +120,9 @@ static void cxl_1pxb_2rp_2t3d(void) static void cxl_2pxb_4rp_4t3d(void) { g_autoptr(GString) cmdline = g_string_new(NULL); - char template[] = "/tmp/cxl-test-XXXXXX"; - const char *tmpfs; + g_autofree const char *tmpfs = NULL; - tmpfs = g_mkdtemp(template); + tmpfs = g_dir_make_tmp("cxl-test-XXXXXX", NULL); g_string_printf(cmdline, QEMU_2PXB_CMD QEMU_4RP QEMU_4T3D, tmpfs, tmpfs, tmpfs, tmpfs, tmpfs, tmpfs, |