[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 22/37] tests/qtest: {ahci, ide}-test: Use relative path for tempor
From: |
Thomas Huth |
Subject: |
[PULL 22/37] tests/qtest: {ahci, ide}-test: Use relative path for temporary files for win32 |
Date: |
Wed, 28 Sep 2022 09:18:28 +0200 |
From: Bin Meng <bin.meng@windriver.com>
These test cases uses "blkdebug:path/to/config:path/to/image" for
testing. On Windows, absolute file paths contain the delimiter ':'
which causes the blkdebug filename parser fail to parse filenames.
Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20220925113032.1949844-38-bmeng.cn@gmail.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/qtest/ahci-test.c | 21 ++++++++++++++++++---
tests/qtest/ide-test.c | 20 ++++++++++++++++++--
2 files changed, 36 insertions(+), 5 deletions(-)
diff --git a/tests/qtest/ahci-test.c b/tests/qtest/ahci-test.c
index 1d5929d8c3..66652fed04 100644
--- a/tests/qtest/ahci-test.c
+++ b/tests/qtest/ahci-test.c
@@ -1833,7 +1833,7 @@ static void create_ahci_io_test(enum IOMode type, enum
AddrMode addr,
int main(int argc, char **argv)
{
- const char *arch;
+ const char *arch, *base;
int ret;
int fd;
int c;
@@ -1871,8 +1871,22 @@ int main(int argc, char **argv)
return 0;
}
+ /*
+ * "base" stores the starting point where we create temporary files.
+ *
+ * On Windows, this is set to the relative path of current working
+ * directory, because the absolute path causes the blkdebug filename
+ * parser fail to parse "blkdebug:path/to/config:path/to/image".
+ */
+#ifndef _WIN32
+ base = g_get_tmp_dir();
+#else
+ base = ".";
+#endif
+
/* Create a temporary image */
- fd = g_file_open_tmp("qtest.XXXXXX", &tmp_path, NULL);
+ tmp_path = g_strdup_printf("%s/qtest.XXXXXX", base);
+ fd = g_mkstemp(tmp_path);
g_assert(fd >= 0);
if (have_qemu_img()) {
imgfmt = "qcow2";
@@ -1889,7 +1903,8 @@ int main(int argc, char **argv)
close(fd);
/* Create temporary blkdebug instructions */
- fd = g_file_open_tmp("qtest-blkdebug.XXXXXX", &debug_path, NULL);
+ debug_path = g_strdup_printf("%s/qtest-blkdebug.XXXXXX", base);
+ fd = g_mkstemp(debug_path);
g_assert(fd >= 0);
close(fd);
diff --git a/tests/qtest/ide-test.c b/tests/qtest/ide-test.c
index 25302be6dc..5e3e28aea2 100644
--- a/tests/qtest/ide-test.c
+++ b/tests/qtest/ide-test.c
@@ -1011,16 +1011,32 @@ static void test_cdrom_dma(void)
int main(int argc, char **argv)
{
+ const char *base;
int fd;
int ret;
+ /*
+ * "base" stores the starting point where we create temporary files.
+ *
+ * On Windows, this is set to the relative path of current working
+ * directory, because the absolute path causes the blkdebug filename
+ * parser fail to parse "blkdebug:path/to/config:path/to/image".
+ */
+#ifndef _WIN32
+ base = g_get_tmp_dir();
+#else
+ base = ".";
+#endif
+
/* Create temporary blkdebug instructions */
- fd = g_file_open_tmp("qtest-blkdebug.XXXXXX", &debug_path, NULL);
+ debug_path = g_strdup_printf("%s/qtest-blkdebug.XXXXXX", base);
+ fd = g_mkstemp(debug_path);
g_assert(fd >= 0);
close(fd);
/* Create a temporary raw image */
- fd = g_file_open_tmp("qtest.XXXXXX", &tmp_path, NULL);
+ tmp_path = g_strdup_printf("%s/qtest.XXXXXX", base);
+ fd = g_mkstemp(tmp_path);
g_assert(fd >= 0);
ret = ftruncate(fd, TEST_IMAGE_SIZE);
g_assert(ret == 0);
--
2.31.1
- [PULL 03/37] tests/qtest: aspeed_smc-test: Avoid using hardcoded /tmp, (continued)
- [PULL 03/37] tests/qtest: aspeed_smc-test: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 01/37] tests/qtest: i440fx-test: Rewrite create_blob_file() to be portable, Thomas Huth, 2022/09/28
- [PULL 06/37] tests/qtest: fdc-test: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 04/37] tests/qtest: boot-serial-test: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 07/37] tests/qtest: generic_fuzz: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 15/37] tests/unit: test-qga: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 13/37] tests/qtest: libqtest: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 05/37] tests/qtest: cxl-test: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 10/37] tests/qtest: vhost-user-blk-test: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 21/37] tests/qtest: libqtest: Exclude the *_fds APIs for win32, Thomas Huth, 2022/09/28
- [PULL 22/37] tests/qtest: {ahci, ide}-test: Use relative path for temporary files for win32,
Thomas Huth <=
- [PULL 11/37] tests/qtest: virtio-blk-test: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [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