[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
- [PATCH 31/51] tests/qtest: Support libqtest to build and run on Windows, (continued)
- [PATCH 31/51] tests/qtest: Support libqtest to build and run on Windows, Bin Meng, 2022/08/24
- [PATCH 32/51] tests/qtest: Fix ERROR_SHARING_VIOLATION for win32, Bin Meng, 2022/08/24
- [PATCH 34/51] tests/qtest: bios-tables-test: Adapt the case for win32, Bin Meng, 2022/08/24
- [PATCH 39/51] tests/qtest: virtio-net-failover: Disable migration tests for win32, Bin Meng, 2022/08/24
- [PATCH 43/51] tests/qtest: npcm7xx_emc-test: Skip running test_{tx, rx} on 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
- [PATCH 35/51] tests/qtest: device-plug-test: Reverse the usage of double/single quotes, Bin Meng, 2022/08/24
- [PATCH 37/51] tests/qtest: migration-test: Disable IO redirection for win32, Bin Meng, 2022/08/24
- [PATCH 42/51] hw/ppc: spapr: Use qemu_vfree() to free spapr->htab, Bin Meng, 2022/08/24
- [PATCH 41/51] tests/qtest: migration-test: Kill "to" after migration is canceled, Bin Meng, 2022/08/24