tests/qtest: vhost-user-blk-test: Avoid using hardcoded /tmp

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>
Message-Id: <20220925113032.1949844-18-bmeng.cn@gmail.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
Bin Meng 2022-09-25 19:29:55 +08:00 committed by Thomas Huth
parent 354aeeabec
commit c20413558a

View File

@ -841,7 +841,8 @@ static char *create_listen_socket(int *fd)
char *path;
/* No race because our pid makes the path unique */
path = g_strdup_printf("/tmp/qtest-%d-sock.XXXXXX", getpid());
path = g_strdup_printf("%s/qtest-%d-sock.XXXXXX",
g_get_tmp_dir(), getpid());
tmp_fd = mkstemp(path);
g_assert_cmpint(tmp_fd, >=, 0);
close(tmp_fd);