[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 18/54] tests/qtest: vhost-user-test: Avoid using hardcoded /tm
From: |
Bin Meng |
Subject: |
[PATCH v3 18/54] tests/qtest: vhost-user-test: Avoid using hardcoded /tmp |
Date: |
Sun, 25 Sep 2022 19:29:56 +0800 |
From: Bin Meng <bin.meng@windriver.com>
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>
---
Changes in v3:
- Split to a separate patch
- Ensure g_autofree variable is initialized
tests/qtest/vhost-user-test.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c
index d7d6cfc9bd..448fda3e7f 100644
--- a/tests/qtest/vhost-user-test.c
+++ b/tests/qtest/vhost-user-test.c
@@ -482,8 +482,7 @@ static TestServer *test_server_new(const gchar *name,
struct vhost_user_ops *ops)
{
TestServer *server = g_new0(TestServer, 1);
- char template[] = "/tmp/vhost-test-XXXXXX";
- const char *tmpfs;
+ g_autofree const char *tmpfs = NULL;
server->context = g_main_context_new();
server->loop = g_main_loop_new(server->context, FALSE);
@@ -491,9 +490,10 @@ static TestServer *test_server_new(const gchar *name,
/* run the main loop thread so the chardev may operate */
server->thread = g_thread_new(NULL, thread_function, server->loop);
- tmpfs = g_mkdtemp(template);
+ tmpfs = g_dir_make_tmp("vhost-test-XXXXXX", NULL);
if (!tmpfs) {
- g_test_message("g_mkdtemp on path (%s): %s", template,
strerror(errno));
+ g_test_message("g_dir_make_tmp on path (%s): %s", tmpfs,
+ strerror(errno));
}
g_assert(tmpfs);
--
2.34.1
- [PATCH v3 31/54] accel/qtest: Implement a portable qtest accelerator, (continued)
- [PATCH v3 31/54] accel/qtest: Implement a portable qtest accelerator, Bin Meng, 2022/09/25
- [PATCH v3 26/54] fsdev/virtfs-proxy-helper: Use g_mkdir(), Bin Meng, 2022/09/25
- [PATCH v3 11/54] tests/qtest: virtio_blk_fuzz: Avoid using hardcoded /tmp, Bin Meng, 2022/09/25
- [PATCH v3 28/54] tests/qtest: Skip running virtio-net-test cases that require socketpair() for win32, Bin Meng, 2022/09/25
- [PATCH v3 29/54] tests/qtest: Build test-filter-{mirror, redirector} cases for posix only, Bin Meng, 2022/09/25
- [PATCH v3 24/54] tests: vhost-user-bridge: Avoid using hardcoded /tmp, Bin Meng, 2022/09/25
- [PATCH v3 22/54] tests/unit: test-image-locking: Avoid using hardcoded /tmp, Bin Meng, 2022/09/25
- [PATCH v3 18/54] tests/qtest: vhost-user-test: Avoid using hardcoded /tmp,
Bin Meng <=
- [PATCH v3 30/54] tests/qtest: qmp-test: Skip running test_qmp_oob for win32, Bin Meng, 2022/09/25
- [PATCH v3 32/54] tests/qtest: libqtest: Adapt global_qtest declaration for win32, Bin Meng, 2022/09/25
- [PATCH v3 33/54] tests/qtest: Use send/recv for socket communication, Bin Meng, 2022/09/25
- [PATCH v3 34/54] tests/qtest: libqtest: Exclude the *_fds APIs for win32, Bin Meng, 2022/09/25
- [PATCH v3 36/54] tests/qtest: Support libqtest to build and run on Windows, Bin Meng, 2022/09/25
- [PATCH v3 42/54] chardev/char-file: Add FILE_SHARE_WRITE when opening the file for win32, Bin Meng, 2022/09/25