Re: [PATCH v2 20/39] tests/qtest: {ahci, ide}-test: Use relative path for temporary files for win32
On Thu, Sep 22, 2022 at 4:03 PM Marc-André Lureau wrote: > > Hi > > On Tue, Sep 20, 2022 at 1:50 PM Bin Meng wrote: >> >> From: Bin Meng >> >> 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 > > > I don't have a much better solution to propose at this point (to actually use > a temp directory), so: > Reviewed-by: Marc-André Lureau I assume we can switch to using the node-based specifications instead of -file=blkdebug:%s and just spell out the tree more meticulously, either on the CLI or by switching to using QMP for the test. These tests were written a long time ago. --js
Re: [PATCH v2 20/39] tests/qtest: {ahci, ide}-test: Use relative path for temporary files for win32
Hi On Tue, Sep 20, 2022 at 1:50 PM Bin Meng wrote: > From: Bin Meng > > 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 > I don't have a much better solution to propose at this point (to actually use a temp directory), so: Reviewed-by: Marc-André Lureau > --- > > (no changes since v1) > > 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 00524f14c6..c57576b08c 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.XX", _path, NULL); > +tmp_path = g_strdup_printf("%s/qtest.XX", 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.XX", _path, NULL); > +debug_path = g_strdup_printf("%s/qtest-blkdebug.XX", 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.XX", _path, NULL); > +debug_path = g_strdup_printf("%s/qtest-blkdebug.XX", base); > +fd = g_mkstemp(debug_path); > g_assert(fd >= 0); > close(fd); > > /* Create a temporary raw image */ > -fd = g_file_open_tmp("qtest.XX", _path, NULL); > +tmp_path = g_strdup_printf("%s/qtest.XX", base); > +fd = g_mkstemp(tmp_path); > g_assert(fd >= 0); > ret = ftruncate(fd, TEST_IMAGE_SIZE); > g_assert(ret == 0); > -- > 2.34.1 > > > -- Marc-André Lureau
[PATCH v2 20/39] tests/qtest: {ahci, ide}-test: Use relative path for temporary files for win32
From: Bin Meng 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 --- (no changes since v1) 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 00524f14c6..c57576b08c 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.XX", _path, NULL); +tmp_path = g_strdup_printf("%s/qtest.XX", 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.XX", _path, NULL); +debug_path = g_strdup_printf("%s/qtest-blkdebug.XX", 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.XX", _path, NULL); +debug_path = g_strdup_printf("%s/qtest-blkdebug.XX", base); +fd = g_mkstemp(debug_path); g_assert(fd >= 0); close(fd); /* Create a temporary raw image */ -fd = g_file_open_tmp("qtest.XX", _path, NULL); +tmp_path = g_strdup_printf("%s/qtest.XX", base); +fd = g_mkstemp(tmp_path); g_assert(fd >= 0); ret = ftruncate(fd, TEST_IMAGE_SIZE); g_assert(ret == 0); -- 2.34.1