tests/qtest: virtio_blk_fuzz: Avoid using hardcoded /tmp

This case was written to use hardcoded /tmp directory for temporary
files. Update to use g_file_open_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-12-bmeng.cn@gmail.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
master
Bin Meng 2022-09-25 19:29:49 +08:00 committed by Thomas Huth
parent 9e5d84037f
commit 3ff220a0ac
1 changed files with 2 additions and 2 deletions

View File

@ -181,10 +181,10 @@ static void drive_destroy(void *path)
static char *drive_create(void)
{
int fd, ret;
char *t_path = g_strdup("/tmp/qtest.XXXXXX");
char *t_path;
/* Create a temporary raw image */
fd = mkstemp(t_path);
fd = g_file_open_tmp("qtest.XXXXXX", &t_path, NULL);
g_assert_cmpint(fd, >=, 0);
ret = ftruncate(fd, TEST_IMAGE_SIZE);
g_assert_cmpint(ret, ==, 0);