[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 33/51] tests/qtest: {ahci, ide}-test: Use relative path for tempo
From: |
Bin Meng |
Subject: |
[PATCH 33/51] tests/qtest: {ahci, ide}-test: Use relative path for temporary files |
Date: |
Wed, 24 Aug 2022 17:40:11 +0800 |
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>
---
tests/qtest/ahci-test.c | 19 ++++++++++++++++---
tests/qtest/ide-test.c | 18 ++++++++++++++++--
2 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/tests/qtest/ahci-test.c b/tests/qtest/ahci-test.c
index 0e88cd0eef..bce9ff770c 100644
--- a/tests/qtest/ahci-test.c
+++ b/tests/qtest/ahci-test.c
@@ -1848,7 +1848,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;
@@ -1886,8 +1886,21 @@ 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 */
- tmp_path = g_strdup_printf("%s/qtest.XXXXXX", g_get_tmp_dir());
+ tmp_path = g_strdup_printf("%s/qtest.XXXXXX", base);
fd = mkstemp(tmp_path);
g_assert(fd >= 0);
if (have_qemu_img()) {
@@ -1905,7 +1918,7 @@ int main(int argc, char **argv)
close(fd);
/* Create temporary blkdebug instructions */
- debug_path = g_strdup_printf("%s/qtest-blkdebug.XXXXXX", g_get_tmp_dir());
+ debug_path = g_strdup_printf("%s/qtest-blkdebug.XXXXXX", base);
fd = mkstemp(debug_path);
g_assert(fd >= 0);
close(fd);
diff --git a/tests/qtest/ide-test.c b/tests/qtest/ide-test.c
index ebbf8e0126..c5cad6c0be 100644
--- a/tests/qtest/ide-test.c
+++ b/tests/qtest/ide-test.c
@@ -1011,17 +1011,31 @@ 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 */
- debug_path = g_strdup_printf("%s/qtest-blkdebug.XXXXXX", g_get_tmp_dir());
+ debug_path = g_strdup_printf("%s/qtest-blkdebug.XXXXXX", base);
fd = mkstemp(debug_path);
g_assert(fd >= 0);
close(fd);
/* Create a temporary raw image */
- tmp_path = g_strdup_printf("%s/qtest.XXXXXX", g_get_tmp_dir());
+ tmp_path = g_strdup_printf("%s/qtest.XXXXXX", base);
fd = mkstemp(tmp_path);
g_assert(fd >= 0);
ret = ftruncate(fd, TEST_IMAGE_SIZE);
--
2.34.1
- Re: [PATCH 02/51] tests/qtest: Use g_mkdtemp(), (continued)
- [PATCH 03/51] block: Unify the get_tmp_filename() implementation, Bin Meng, 2022/08/24
- [PATCH 07/51] tests: Avoid using hardcoded /tmp in test cases, Bin Meng, 2022/08/24
- [PATCH 08/51] block/vvfat: Unify the mkdir() call, Bin Meng, 2022/08/24
- [PATCH 30/51] tests: Skip iotests and qtest when '--without-default-devices', Bin Meng, 2022/08/24
- [PATCH 32/51] tests/qtest: Fix ERROR_SHARING_VIOLATION for win32, Bin Meng, 2022/08/24
- [PATCH 33/51] tests/qtest: {ahci, ide}-test: Use relative path for temporary files,
Bin Meng <=
- [PATCH 38/51] tests/qtest: {ahci,ide}-test: Open file in binary mode, Bin Meng, 2022/08/24