[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 22/54] tests/unit: test-image-locking: Avoid using hardcoded /
From: |
Bin Meng |
Subject: |
[PATCH v3 22/54] tests/unit: test-image-locking: Avoid using hardcoded /tmp |
Date: |
Sun, 25 Sep 2022 19:30:00 +0800 |
From: Bin Meng <bin.meng@windriver.com>
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>
---
Changes in v3:
- Split to a separate patch
- Ensure g_autofree variable is initialized
tests/unit/test-image-locking.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tests/unit/test-image-locking.c b/tests/unit/test-image-locking.c
index ba057bd66c..a47299c247 100644
--- a/tests/unit/test-image-locking.c
+++ b/tests/unit/test-image-locking.c
@@ -76,10 +76,10 @@ static void check_locked_bytes(int fd, uint64_t perm_locks,
static void test_image_locking_basic(void)
{
BlockBackend *blk1, *blk2, *blk3;
- char img_path[] = "/tmp/qtest.XXXXXX";
+ g_autofree char *img_path = NULL;
uint64_t perm, shared_perm;
- int fd = mkstemp(img_path);
+ int fd = g_file_open_tmp("qtest.XXXXXX", &img_path, NULL);
assert(fd >= 0);
perm = BLK_PERM_WRITE | BLK_PERM_CONSISTENT_READ;
@@ -117,10 +117,10 @@ static void test_image_locking_basic(void)
static void test_set_perm_abort(void)
{
BlockBackend *blk1, *blk2;
- char img_path[] = "/tmp/qtest.XXXXXX";
+ g_autofree char *img_path = NULL;
uint64_t perm, shared_perm;
int r;
- int fd = mkstemp(img_path);
+ int fd = g_file_open_tmp("qtest.XXXXXX", &img_path, NULL);
assert(fd >= 0);
perm = BLK_PERM_WRITE | BLK_PERM_CONSISTENT_READ;
--
2.34.1
- Re: [PATCH v3 21/54] tests/qtest: libqtest: Avoid using hardcoded /tmp, (continued)
- [PATCH v3 25/54] block/vvfat: Unify the mkdir() call, Bin Meng, 2022/09/25
- [PATCH v3 31/54] accel/qtest: Implement a portable qtest accelerator, Bin Meng, 2022/09/25
- [PATCH v3 26/54] fsdev/virtfs-proxy-helper: Use g_mkdir(), Bin Meng, 2022/09/25
- [PATCH v3 11/54] tests/qtest: virtio_blk_fuzz: Avoid using hardcoded /tmp, Bin Meng, 2022/09/25
- [PATCH v3 28/54] tests/qtest: Skip running virtio-net-test cases that require socketpair() for win32, Bin Meng, 2022/09/25
- [PATCH v3 29/54] tests/qtest: Build test-filter-{mirror, redirector} cases for posix only, Bin Meng, 2022/09/25
- [PATCH v3 24/54] tests: vhost-user-bridge: Avoid using hardcoded /tmp, Bin Meng, 2022/09/25
- [PATCH v3 22/54] tests/unit: test-image-locking: Avoid using hardcoded /tmp,
Bin Meng <=
- [PATCH v3 18/54] tests/qtest: vhost-user-test: Avoid using hardcoded /tmp, Bin Meng, 2022/09/25
- [PATCH v3 30/54] tests/qtest: qmp-test: Skip running test_qmp_oob for win32, Bin Meng, 2022/09/25
- [PATCH v3 32/54] tests/qtest: libqtest: Adapt global_qtest declaration for win32, Bin Meng, 2022/09/25
- [PATCH v3 33/54] tests/qtest: Use send/recv for socket communication, Bin Meng, 2022/09/25
- [PATCH v3 34/54] tests/qtest: libqtest: Exclude the *_fds APIs for win32, Bin Meng, 2022/09/25
- [PATCH v3 36/54] tests/qtest: Support libqtest to build and run on Windows, Bin Meng, 2022/09/25
- [PATCH v3 42/54] chardev/char-file: Add FILE_SHARE_WRITE when opening the file for win32, Bin Meng, 2022/09/25