[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 14/37] tests/unit: test-image-locking: Avoid using hardcoded /tmp
From: |
Thomas Huth |
Subject: |
[PULL 14/37] tests/unit: test-image-locking: Avoid using hardcoded /tmp |
Date: |
Wed, 28 Sep 2022 09:18:20 +0200 |
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>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20220925113032.1949844-23-bmeng.cn@gmail.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
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.31.1
- [PULL 35/37] tests/qtest: vhost-user-test: Avoid using hardcoded /tmp, (continued)
- [PULL 35/37] tests/qtest: vhost-user-test: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 36/37] tests/qtest: boot-serial-test: Close the serial file before starting QEMU, Thomas Huth, 2022/09/28
- [PULL 09/37] tests/qtest: ide-test: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 12/37] tests/qtest: virtio-scsi-test: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 16/37] tests: vhost-user-bridge: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 17/37] tests/qtest: Skip running virtio-net-test cases that require socketpair() for win32, Thomas Huth, 2022/09/28
- [PULL 23/37] tests/qtest: bios-tables-test: Adapt the case for win32, Thomas Huth, 2022/09/28
- [PULL 25/37] tests/qtest: ide-test: Open file in binary mode, Thomas Huth, 2022/09/28
- [PULL 29/37] tests/qtest: migration-test: Skip running some TLS cases for win32, Thomas Huth, 2022/09/28
- [PULL 08/37] tests/qtest: virtio_blk_fuzz: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 14/37] tests/unit: test-image-locking: Avoid using hardcoded /tmp,
Thomas Huth <=
- [PULL 37/37] docs/devel: testing: Document writing portable test cases, Thomas Huth, 2022/09/28
- [PULL 18/37] tests/qtest: Build test-filter-{mirror, redirector} cases for posix only, Thomas Huth, 2022/09/28
- [PULL 19/37] tests/qtest: qmp-test: Skip running test_qmp_oob for win32, Thomas Huth, 2022/09/28
- [PULL 26/37] tests/qtest: virtio-net-failover: Disable migration tests for win32, Thomas Huth, 2022/09/28
- [PULL 31/37] tests/x86: Move common code to function in device-plug-test, Thomas Huth, 2022/09/28
- Re: [PULL 00/37] qtests fixes, Stefan Hajnoczi, 2022/09/29