mirror of https://github.com/xemu-project/xemu.git
tests/qtest: vhost-user-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> Message-Id: <20220927110632.1973965-19-bmeng.cn@gmail.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
parent
c12fea71a0
commit
e6efe236c1
|
@ -482,8 +482,8 @@ static TestServer *test_server_new(const gchar *name,
|
||||||
struct vhost_user_ops *ops)
|
struct vhost_user_ops *ops)
|
||||||
{
|
{
|
||||||
TestServer *server = g_new0(TestServer, 1);
|
TestServer *server = g_new0(TestServer, 1);
|
||||||
char template[] = "/tmp/vhost-test-XXXXXX";
|
g_autofree const char *tmpfs = NULL;
|
||||||
const char *tmpfs;
|
GError *err = NULL;
|
||||||
|
|
||||||
server->context = g_main_context_new();
|
server->context = g_main_context_new();
|
||||||
server->loop = g_main_loop_new(server->context, FALSE);
|
server->loop = g_main_loop_new(server->context, FALSE);
|
||||||
|
@ -491,9 +491,11 @@ static TestServer *test_server_new(const gchar *name,
|
||||||
/* run the main loop thread so the chardev may operate */
|
/* run the main loop thread so the chardev may operate */
|
||||||
server->thread = g_thread_new(NULL, thread_function, server->loop);
|
server->thread = g_thread_new(NULL, thread_function, server->loop);
|
||||||
|
|
||||||
tmpfs = g_mkdtemp(template);
|
tmpfs = g_dir_make_tmp("vhost-test-XXXXXX", &err);
|
||||||
if (!tmpfs) {
|
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,
|
||||||
|
err->message);
|
||||||
|
g_error_free(err);
|
||||||
}
|
}
|
||||||
g_assert(tmpfs);
|
g_assert(tmpfs);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue