qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 37/54] tests/qtest: {ahci, ide}-test: Use relative path fo


From: Thomas Huth
Subject: Re: [PATCH v3 37/54] tests/qtest: {ahci, ide}-test: Use relative path for temporary files for win32
Date: Mon, 26 Sep 2022 18:20:36 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0

On 25/09/2022 13.30, Bin Meng wrote:
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>
---

(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 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);

It would maybe make sense to merge this with patch 05 ("tests/qtest: ahci-test: Avoid using hardcoded /tmp") ? ... but if you want to keep it separate, that's fine for me, too.

Reviewed-by: Thomas Huth <thuth@redhat.com>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]