[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 09/37] tests/qtest: ide-test: Avoid using hardcoded /tmp
From: |
Thomas Huth |
Subject: |
[PULL 09/37] tests/qtest: ide-test: Avoid using hardcoded /tmp |
Date: |
Wed, 28 Sep 2022 09:18:15 +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-14-bmeng.cn@gmail.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/qtest/ide-test.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/tests/qtest/ide-test.c b/tests/qtest/ide-test.c
index 5bcb75a7e5..25302be6dc 100644
--- a/tests/qtest/ide-test.c
+++ b/tests/qtest/ide-test.c
@@ -121,8 +121,8 @@ enum {
static QPCIBus *pcibus = NULL;
static QGuestAllocator guest_malloc;
-static char tmp_path[] = "/tmp/qtest.XXXXXX";
-static char debug_path[] = "/tmp/qtest-blkdebug.XXXXXX";
+static char *tmp_path;
+static char *debug_path;
static QTestState *ide_test_start(const char *cmdline_fmt, ...)
{
@@ -1015,12 +1015,12 @@ int main(int argc, char **argv)
int ret;
/* Create temporary blkdebug instructions */
- fd = mkstemp(debug_path);
+ fd = g_file_open_tmp("qtest-blkdebug.XXXXXX", &debug_path, NULL);
g_assert(fd >= 0);
close(fd);
/* Create a temporary raw image */
- fd = mkstemp(tmp_path);
+ fd = g_file_open_tmp("qtest.XXXXXX", &tmp_path, NULL);
g_assert(fd >= 0);
ret = ftruncate(fd, TEST_IMAGE_SIZE);
g_assert(ret == 0);
@@ -1049,7 +1049,9 @@ int main(int argc, char **argv)
/* Cleanup */
unlink(tmp_path);
+ g_free(tmp_path);
unlink(debug_path);
+ g_free(debug_path);
return ret;
}
--
2.31.1
- [PULL 20/37] tests/qtest: libqtest: Adapt global_qtest declaration for win32, (continued)
- [PULL 20/37] tests/qtest: libqtest: Adapt global_qtest declaration for win32, Thomas Huth, 2022/09/28
- [PULL 24/37] tests/qtest: migration-test: Disable IO redirection for win32, Thomas Huth, 2022/09/28
- [PULL 27/37] tests/qtest: microbit-test: Fix socket access for win32, Thomas Huth, 2022/09/28
- [PULL 28/37] tests/qtest: libqtest: Replace the call to close a socket with closesocket(), Thomas Huth, 2022/09/28
- [PULL 30/37] .gitlab-ci.d/windows.yml: Display meson test logs, Thomas Huth, 2022/09/28
- [PULL 32/37] tests/qtest: hd-geo-test: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 34/37] tests/qtest: qmp-test: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 33/37] tests/qtest: pflash-cfi02-test: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [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 <=
- [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, 2022/09/28
- [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