summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorBin Meng <bin.meng@windriver.com>2022-09-25 19:29:57 +0800
committerThomas Huth <thuth@redhat.com>2022-09-27 20:51:20 +0200
commitbc989a2b870629276fcbb9f5ee380d5c53e145cc (patch)
tree5e20620e6998ca253aa161f85d892e8b15abb3b6 /tests
parentc20413558a49326599b15c3854c0df68a0b45895 (diff)
downloadfocaccia-qemu-bc989a2b870629276fcbb9f5ee380d5c53e145cc.tar.gz
focaccia-qemu-bc989a2b870629276fcbb9f5ee380d5c53e145cc.zip
tests/qtest: virtio-blk-test: 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-20-bmeng.cn@gmail.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/qtest/virtio-blk-test.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/qtest/virtio-blk-test.c b/tests/qtest/virtio-blk-test.c
index dc5eed31c8..19c01f808b 100644
--- a/tests/qtest/virtio-blk-test.c
+++ b/tests/qtest/virtio-blk-test.c
@@ -49,10 +49,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);