summary refs log tree commit diff stats
path: root/tests/qtest/fuzz/virtio_blk_fuzz.c
diff options
context:
space:
mode:
authorBin Meng <bin.meng@windriver.com>2022-09-25 19:29:49 +0800
committerThomas Huth <thuth@redhat.com>2022-09-27 20:51:20 +0200
commit3ff220a0acc1d46d528600af937badf246cb05f3 (patch)
tree8181846d78c0a829f31a082356da82c3ae49fedc /tests/qtest/fuzz/virtio_blk_fuzz.c
parent9e5d84037fcff3c5936b1e7776cc2363920ad1f1 (diff)
downloadfocaccia-qemu-3ff220a0acc1d46d528600af937badf246cb05f3.tar.gz
focaccia-qemu-3ff220a0acc1d46d528600af937badf246cb05f3.zip
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>
Diffstat (limited to 'tests/qtest/fuzz/virtio_blk_fuzz.c')
-rw-r--r--tests/qtest/fuzz/virtio_blk_fuzz.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/qtest/fuzz/virtio_blk_fuzz.c b/tests/qtest/fuzz/virtio_blk_fuzz.c
index 236d078cc8..a9fb9ecf6c 100644
--- a/tests/qtest/fuzz/virtio_blk_fuzz.c
+++ b/tests/qtest/fuzz/virtio_blk_fuzz.c
@@ -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);