aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBin Meng <bin.meng@windriver.com>2022-09-25 19:30:00 +0800
committerThomas Huth <thuth@redhat.com>2022-09-27 20:51:20 +0200
commite0e5b3dc0024f76a27b4643c4158cc5463713d9c (patch)
tree0ce5934398d26356d5da34b3fff4bb26ca713378 /tests
parentb6dabc82b070850711881feaa0d8028ee7c396dc (diff)
downloadqemu-e0e5b3dc0024f76a27b4643c4158cc5463713d9c.zip
qemu-e0e5b3dc0024f76a27b4643c4158cc5463713d9c.tar.gz
qemu-e0e5b3dc0024f76a27b4643c4158cc5463713d9c.tar.bz2
tests/unit: test-image-locking: 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-23-bmeng.cn@gmail.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test-image-locking.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/unit/test-image-locking.c b/tests/unit/test-image-locking.c
index ba057bd..a47299c 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;