On Thu, Sep 1, 2022 at 4:58 PM Marc-André Lureau <marcandre.lur...@gmail.com> wrote: > > > > On Wed, Aug 24, 2022 at 2:55 PM Bin Meng <bmeng...@gmail.com> wrote: >> >> From: Bin Meng <bin.m...@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. >> > > hmm.. maybe it should learn to escape paths.. > > >> Signed-off-by: Bin Meng <bin.m...@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 > > > Meanwhile, that seems reasonable. Perhaps chdir() to the temporary directory > first? (assuming other paths are absolute)
Other paths in the QEMU command line indeed are absolute, however the QEMU executable path is set to a relative path from meson.build thus we cannot chdir() to the temporary directory here. > >> >> + >> /* 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 Regards, Bin