[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 14/54] tests/qtest: migration-test: Avoid using hardcoded /tmp
From: |
Bin Meng |
Subject: |
[PATCH v4 14/54] tests/qtest: migration-test: Avoid using hardcoded /tmp |
Date: |
Tue, 27 Sep 2022 19:05:52 +0800 |
From: Bin Meng <bin.meng@windriver.com>
This case was written to use hardcoded /tmp directory for temporary
files. Update to use g_dir_make_tmp() for a portable implementation.
Signed-off-by: Bin Meng <bin.meng@windriver.com>
---
Changes in v4:
- Update the error reporting by using the GError "error" argument
of g_dir_make_tmp()
- Remove the const from tmpfs declaration
Changes in v3:
- Split to a separate patch
tests/qtest/migration-test.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
index 4728d528bb..f57e07fe2d 100644
--- a/tests/qtest/migration-test.c
+++ b/tests/qtest/migration-test.c
@@ -102,7 +102,7 @@ static bool ufd_version_check(void)
#endif
-static const char *tmpfs;
+static char *tmpfs;
/* The boot file modifies memory area in [start_address, end_address)
* repeatedly. It outputs a 'B' at a fixed rate while it's still running.
@@ -2434,10 +2434,10 @@ static bool kvm_dirty_ring_supported(void)
int main(int argc, char **argv)
{
- char template[] = "/tmp/migration-test-XXXXXX";
const bool has_kvm = qtest_has_accel("kvm");
const bool has_uffd = ufd_version_check();
const char *arch = qtest_get_arch();
+ GError *err = NULL;
int ret;
g_test_init(&argc, &argv, NULL);
@@ -2462,9 +2462,11 @@ int main(int argc, char **argv)
return g_test_run();
}
- tmpfs = g_mkdtemp(template);
+ tmpfs = g_dir_make_tmp("migration-test-XXXXXX", &err);
if (!tmpfs) {
- g_test_message("g_mkdtemp on path (%s): %s", template,
strerror(errno));
+ g_test_message("g_dir_make_tmp on path (%s): %s", tmpfs,
+ err->message);
+ g_error_free(err);
}
g_assert(tmpfs);
@@ -2589,6 +2591,7 @@ int main(int argc, char **argv)
g_test_message("unable to rmdir: path (%s): %s",
tmpfs, strerror(errno));
}
+ g_free(tmpfs);
return ret;
}
--
2.34.1
- [PATCH v4 07/54] tests/qtest: boot-serial-test: Avoid using hardcoded /tmp, (continued)
- [PATCH v4 07/54] tests/qtest: boot-serial-test: Avoid using hardcoded /tmp, Bin Meng, 2022/09/27
- [PATCH v4 09/54] tests/qtest: fdc-test: Avoid using hardcoded /tmp, Bin Meng, 2022/09/27
- [PATCH v4 08/54] tests/qtest: cxl-test: Avoid using hardcoded /tmp, Bin Meng, 2022/09/27
- [PATCH v4 10/54] tests/qtest: generic_fuzz: Avoid using hardcoded /tmp, Bin Meng, 2022/09/27
- [PATCH v4 06/54] tests/qtest: aspeed_smc-test: Avoid using hardcoded /tmp, Bin Meng, 2022/09/27
- [PATCH v4 04/54] util/qemu-sockets: Use g_get_tmp_dir() to get the directory for temporary files, Bin Meng, 2022/09/27
- [PATCH v4 05/54] tests/qtest: ahci-test: Avoid using hardcoded /tmp, Bin Meng, 2022/09/27
- [PATCH v4 12/54] tests/qtest: hd-geo-test: Avoid using hardcoded /tmp, Bin Meng, 2022/09/27
- [PATCH v4 14/54] tests/qtest: migration-test: Avoid using hardcoded /tmp,
Bin Meng <=
- [PATCH v4 21/54] tests/qtest: libqtest: Avoid using hardcoded /tmp, Bin Meng, 2022/09/27
- [PATCH v4 19/54] tests/qtest: virtio-blk-test: Avoid using hardcoded /tmp, Bin Meng, 2022/09/27
- [PATCH v4 20/54] tests/qtest: virtio-scsi-test: Avoid using hardcoded /tmp, Bin Meng, 2022/09/27
- [PATCH v4 22/54] tests/unit: test-image-locking: Avoid using hardcoded /tmp, Bin Meng, 2022/09/27
- [PATCH v4 25/54] block/vvfat: Unify the mkdir() call, Bin Meng, 2022/09/27
- [PATCH v4 24/54] tests: vhost-user-bridge: Avoid using hardcoded /tmp, Bin Meng, 2022/09/27
- [PATCH v4 15/54] tests/qtest: pflash-cfi02-test: Avoid using hardcoded /tmp, Bin Meng, 2022/09/27