diff mbox series

[37/51] tests/qtest: migration-test: Disable IO redirection for win32

Message ID 20220824094029.1634519-38-bmeng.cn@gmail.com (mailing list archive)
State New, archived
Headers show
Series tests/qtest: Enable running qtest on Windows | expand

Commit Message

Bin Meng Aug. 24, 2022, 9:40 a.m. UTC
From: Bin Meng <bin.meng@windriver.com>

On Windows the QEMU executable is created via CreateProcess() and IO
redirection does not work, so we need to set MigrateStart::hide_stderr
to false to disable adding IO redirection to the command line.

Signed-off-by: Bin Meng <bin.meng@windriver.com>
---

 tests/qtest/migration-test.c | 39 +++++++++++++++++++++++-------------
 1 file changed, 25 insertions(+), 14 deletions(-)

Comments

Dr. David Alan Gilbert Aug. 24, 2022, 6:53 p.m. UTC | #1
* Bin Meng (bmeng.cn@gmail.com) wrote:
> From: Bin Meng <bin.meng@windriver.com>
> 
> On Windows the QEMU executable is created via CreateProcess() and IO
> redirection does not work, so we need to set MigrateStart::hide_stderr
> to false to disable adding IO redirection to the command line.
> 
> Signed-off-by: Bin Meng <bin.meng@windriver.com>

Isn't it easier just to change the one place that tests this?

Dave

> ---
> 
>  tests/qtest/migration-test.c | 39 +++++++++++++++++++++++-------------
>  1 file changed, 25 insertions(+), 14 deletions(-)
> 
> diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
> index 2ae7498d5d..125d48d855 100644
> --- a/tests/qtest/migration-test.c
> +++ b/tests/qtest/migration-test.c
> @@ -53,6 +53,17 @@ static bool uffd_feature_thread_id;
>   */
>  #define DIRTYLIMIT_TOLERANCE_RANGE  25  /* MB/s */
>  
> +/*
> + * On Windows the QEMU executable is created via CreateProcess() and IO
> + * redirection does not work, so we need to set MigrateStart::hide_stderr
> + * to false to disable adding IO redirection to the command line.
> + */
> +#ifndef _WIN32
> +# define HIDE_STDERR true
> +#else
> +# define HIDE_STDERR false
> +#endif
> +
>  #if defined(__linux__)
>  #include <sys/syscall.h>
>  #include <sys/vfs.h>
> @@ -1186,7 +1197,7 @@ static void test_postcopy_recovery_common(MigrateCommon *args)
>      g_autofree char *uri = NULL;
>  
>      /* Always hide errors for postcopy recover tests since they're expected */
> -    args->start.hide_stderr = true;
> +    args->start.hide_stderr = HIDE_STDERR;
>  
>      if (migrate_postcopy_prepare(&from, &to, args)) {
>          return;
> @@ -1287,7 +1298,7 @@ static void test_postcopy_preempt_all(void)
>  static void test_baddest(void)
>  {
>      MigrateStart args = {
> -        .hide_stderr = true
> +        .hide_stderr = HIDE_STDERR
>      };
>      QTestState *from, *to;
>  
> @@ -1410,7 +1421,7 @@ static void test_precopy_unix_tls_x509_default_host(void)
>      g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
>      MigrateCommon args = {
>          .start = {
> -            .hide_stderr = true,
> +            .hide_stderr = HIDE_STDERR,
>          },
>          .connect_uri = uri,
>          .listen_uri = uri,
> @@ -1526,7 +1537,7 @@ static void test_precopy_tcp_tls_psk_mismatch(void)
>  {
>      MigrateCommon args = {
>          .start = {
> -            .hide_stderr = true,
> +            .hide_stderr = HIDE_STDERR,
>          },
>          .listen_uri = "tcp:127.0.0.1:0",
>          .start_hook = test_migrate_tls_psk_start_mismatch,
> @@ -1564,7 +1575,7 @@ static void test_precopy_tcp_tls_x509_mismatch_host(void)
>  {
>      MigrateCommon args = {
>          .start = {
> -            .hide_stderr = true,
> +            .hide_stderr = HIDE_STDERR,
>          },
>          .listen_uri = "tcp:127.0.0.1:0",
>          .start_hook = test_migrate_tls_x509_start_mismatch_host,
> @@ -1590,7 +1601,7 @@ static void test_precopy_tcp_tls_x509_hostile_client(void)
>  {
>      MigrateCommon args = {
>          .start = {
> -            .hide_stderr = true,
> +            .hide_stderr = HIDE_STDERR,
>          },
>          .listen_uri = "tcp:127.0.0.1:0",
>          .start_hook = test_migrate_tls_x509_start_hostile_client,
> @@ -1616,7 +1627,7 @@ static void test_precopy_tcp_tls_x509_reject_anon_client(void)
>  {
>      MigrateCommon args = {
>          .start = {
> -            .hide_stderr = true,
> +            .hide_stderr = HIDE_STDERR,
>          },
>          .listen_uri = "tcp:127.0.0.1:0",
>          .start_hook = test_migrate_tls_x509_start_reject_anon_client,
> @@ -1747,7 +1758,7 @@ static void test_validate_uuid_error(void)
>      MigrateStart args = {
>          .opts_source = "-uuid 11111111-1111-1111-1111-111111111111",
>          .opts_target = "-uuid 22222222-2222-2222-2222-222222222222",
> -        .hide_stderr = true,
> +        .hide_stderr = HIDE_STDERR,
>      };
>  
>      do_test_validate_uuid(&args, true);
> @@ -1757,7 +1768,7 @@ static void test_validate_uuid_src_not_set(void)
>  {
>      MigrateStart args = {
>          .opts_target = "-uuid 22222222-2222-2222-2222-222222222222",
> -        .hide_stderr = true,
> +        .hide_stderr = HIDE_STDERR,
>      };
>  
>      do_test_validate_uuid(&args, false);
> @@ -1767,7 +1778,7 @@ static void test_validate_uuid_dst_not_set(void)
>  {
>      MigrateStart args = {
>          .opts_source = "-uuid 11111111-1111-1111-1111-111111111111",
> -        .hide_stderr = true,
> +        .hide_stderr = HIDE_STDERR,
>      };
>  
>      do_test_validate_uuid(&args, false);
> @@ -1990,7 +2001,7 @@ static void test_multifd_tcp_tls_psk_mismatch(void)
>  {
>      MigrateCommon args = {
>          .start = {
> -            .hide_stderr = true,
> +            .hide_stderr = HIDE_STDERR,
>          },
>          .listen_uri = "defer",
>          .start_hook = test_migrate_multifd_tcp_tls_psk_start_mismatch,
> @@ -2038,7 +2049,7 @@ static void test_multifd_tcp_tls_x509_mismatch_host(void)
>       */
>      MigrateCommon args = {
>          .start = {
> -            .hide_stderr = true,
> +            .hide_stderr = HIDE_STDERR,
>          },
>          .listen_uri = "defer",
>          .start_hook = test_migrate_multifd_tls_x509_start_mismatch_host,
> @@ -2062,7 +2073,7 @@ static void test_multifd_tcp_tls_x509_reject_anon_client(void)
>  {
>      MigrateCommon args = {
>          .start = {
> -            .hide_stderr = true,
> +            .hide_stderr = HIDE_STDERR,
>          },
>          .listen_uri = "defer",
>          .start_hook = test_migrate_multifd_tls_x509_start_reject_anon_client,
> @@ -2088,7 +2099,7 @@ static void test_multifd_tcp_tls_x509_reject_anon_client(void)
>  static void test_multifd_tcp_cancel(void)
>  {
>      MigrateStart args = {
> -        .hide_stderr = true,
> +        .hide_stderr = HIDE_STDERR,
>      };
>      QTestState *from, *to, *to2;
>      QDict *rsp;
> -- 
> 2.34.1
>
Bin Meng Aug. 26, 2022, 10:48 a.m. UTC | #2
On Thu, Aug 25, 2022 at 2:53 AM Dr. David Alan Gilbert
<dgilbert@redhat.com> wrote:
>
> * Bin Meng (bmeng.cn@gmail.com) wrote:
> > From: Bin Meng <bin.meng@windriver.com>
> >
> > On Windows the QEMU executable is created via CreateProcess() and IO
> > redirection does not work, so we need to set MigrateStart::hide_stderr
> > to false to disable adding IO redirection to the command line.
> >
> > Signed-off-by: Bin Meng <bin.meng@windriver.com>
>
> Isn't it easier just to change the one place that tests this?
>

Yeah, will do in v2.

Regards,
Bin
diff mbox series

Patch

diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
index 2ae7498d5d..125d48d855 100644
--- a/tests/qtest/migration-test.c
+++ b/tests/qtest/migration-test.c
@@ -53,6 +53,17 @@  static bool uffd_feature_thread_id;
  */
 #define DIRTYLIMIT_TOLERANCE_RANGE  25  /* MB/s */
 
+/*
+ * On Windows the QEMU executable is created via CreateProcess() and IO
+ * redirection does not work, so we need to set MigrateStart::hide_stderr
+ * to false to disable adding IO redirection to the command line.
+ */
+#ifndef _WIN32
+# define HIDE_STDERR true
+#else
+# define HIDE_STDERR false
+#endif
+
 #if defined(__linux__)
 #include <sys/syscall.h>
 #include <sys/vfs.h>
@@ -1186,7 +1197,7 @@  static void test_postcopy_recovery_common(MigrateCommon *args)
     g_autofree char *uri = NULL;
 
     /* Always hide errors for postcopy recover tests since they're expected */
-    args->start.hide_stderr = true;
+    args->start.hide_stderr = HIDE_STDERR;
 
     if (migrate_postcopy_prepare(&from, &to, args)) {
         return;
@@ -1287,7 +1298,7 @@  static void test_postcopy_preempt_all(void)
 static void test_baddest(void)
 {
     MigrateStart args = {
-        .hide_stderr = true
+        .hide_stderr = HIDE_STDERR
     };
     QTestState *from, *to;
 
@@ -1410,7 +1421,7 @@  static void test_precopy_unix_tls_x509_default_host(void)
     g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
     MigrateCommon args = {
         .start = {
-            .hide_stderr = true,
+            .hide_stderr = HIDE_STDERR,
         },
         .connect_uri = uri,
         .listen_uri = uri,
@@ -1526,7 +1537,7 @@  static void test_precopy_tcp_tls_psk_mismatch(void)
 {
     MigrateCommon args = {
         .start = {
-            .hide_stderr = true,
+            .hide_stderr = HIDE_STDERR,
         },
         .listen_uri = "tcp:127.0.0.1:0",
         .start_hook = test_migrate_tls_psk_start_mismatch,
@@ -1564,7 +1575,7 @@  static void test_precopy_tcp_tls_x509_mismatch_host(void)
 {
     MigrateCommon args = {
         .start = {
-            .hide_stderr = true,
+            .hide_stderr = HIDE_STDERR,
         },
         .listen_uri = "tcp:127.0.0.1:0",
         .start_hook = test_migrate_tls_x509_start_mismatch_host,
@@ -1590,7 +1601,7 @@  static void test_precopy_tcp_tls_x509_hostile_client(void)
 {
     MigrateCommon args = {
         .start = {
-            .hide_stderr = true,
+            .hide_stderr = HIDE_STDERR,
         },
         .listen_uri = "tcp:127.0.0.1:0",
         .start_hook = test_migrate_tls_x509_start_hostile_client,
@@ -1616,7 +1627,7 @@  static void test_precopy_tcp_tls_x509_reject_anon_client(void)
 {
     MigrateCommon args = {
         .start = {
-            .hide_stderr = true,
+            .hide_stderr = HIDE_STDERR,
         },
         .listen_uri = "tcp:127.0.0.1:0",
         .start_hook = test_migrate_tls_x509_start_reject_anon_client,
@@ -1747,7 +1758,7 @@  static void test_validate_uuid_error(void)
     MigrateStart args = {
         .opts_source = "-uuid 11111111-1111-1111-1111-111111111111",
         .opts_target = "-uuid 22222222-2222-2222-2222-222222222222",
-        .hide_stderr = true,
+        .hide_stderr = HIDE_STDERR,
     };
 
     do_test_validate_uuid(&args, true);
@@ -1757,7 +1768,7 @@  static void test_validate_uuid_src_not_set(void)
 {
     MigrateStart args = {
         .opts_target = "-uuid 22222222-2222-2222-2222-222222222222",
-        .hide_stderr = true,
+        .hide_stderr = HIDE_STDERR,
     };
 
     do_test_validate_uuid(&args, false);
@@ -1767,7 +1778,7 @@  static void test_validate_uuid_dst_not_set(void)
 {
     MigrateStart args = {
         .opts_source = "-uuid 11111111-1111-1111-1111-111111111111",
-        .hide_stderr = true,
+        .hide_stderr = HIDE_STDERR,
     };
 
     do_test_validate_uuid(&args, false);
@@ -1990,7 +2001,7 @@  static void test_multifd_tcp_tls_psk_mismatch(void)
 {
     MigrateCommon args = {
         .start = {
-            .hide_stderr = true,
+            .hide_stderr = HIDE_STDERR,
         },
         .listen_uri = "defer",
         .start_hook = test_migrate_multifd_tcp_tls_psk_start_mismatch,
@@ -2038,7 +2049,7 @@  static void test_multifd_tcp_tls_x509_mismatch_host(void)
      */
     MigrateCommon args = {
         .start = {
-            .hide_stderr = true,
+            .hide_stderr = HIDE_STDERR,
         },
         .listen_uri = "defer",
         .start_hook = test_migrate_multifd_tls_x509_start_mismatch_host,
@@ -2062,7 +2073,7 @@  static void test_multifd_tcp_tls_x509_reject_anon_client(void)
 {
     MigrateCommon args = {
         .start = {
-            .hide_stderr = true,
+            .hide_stderr = HIDE_STDERR,
         },
         .listen_uri = "defer",
         .start_hook = test_migrate_multifd_tls_x509_start_reject_anon_client,
@@ -2088,7 +2099,7 @@  static void test_multifd_tcp_tls_x509_reject_anon_client(void)
 static void test_multifd_tcp_cancel(void)
 {
     MigrateStart args = {
-        .hide_stderr = true,
+        .hide_stderr = HIDE_STDERR,
     };
     QTestState *from, *to, *to2;
     QDict *rsp;