diff mbox series

[13/51] tests/qtest: migration-test: Handle link() for win32

Message ID 20220824094029.1634519-14-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:39 a.m. UTC
From: Bin Meng <bin.meng@windriver.com>

Windows does not provide a link() API like POSIX. Instead it provides
a similar API CreateHardLink() that does the same thing, but with
different argument order and return value.

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

 tests/qtest/migration-test.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Dr. David Alan Gilbert Aug. 24, 2022, 6:41 p.m. UTC | #1
* Bin Meng (bmeng.cn@gmail.com) wrote:
> From: Bin Meng <bin.meng@windriver.com>
> 
> Windows does not provide a link() API like POSIX. Instead it provides
> a similar API CreateHardLink() that does the same thing, but with
> different argument order and return value.
> 
> Signed-off-by: Bin Meng <bin.meng@windriver.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
> 
>  tests/qtest/migration-test.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
> index 38356d4aba..af9250750b 100644
> --- a/tests/qtest/migration-test.c
> +++ b/tests/qtest/migration-test.c
> @@ -876,9 +876,17 @@ test_migrate_tls_x509_start_common(QTestState *from,
>      g_mkdir_with_parents(data->workdir, 0700);
>  
>      test_tls_init(data->keyfile);
> +#ifndef _WIN32
>      g_assert(link(data->keyfile, data->serverkey) == 0);
> +#else
> +    g_assert(CreateHardLink(data->serverkey, data->keyfile, NULL) != 0);
> +#endif
>      if (args->clientcert) {
> +#ifndef _WIN32
>          g_assert(link(data->keyfile, data->clientkey) == 0);
> +#else
> +        g_assert(CreateHardLink(data->clientkey, data->keyfile, NULL) != 0);
> +#endif
>      }
>  
>      TLS_ROOT_REQ_SIMPLE(cacertreq, data->cacert);
> -- 
> 2.34.1
>
diff mbox series

Patch

diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
index 38356d4aba..af9250750b 100644
--- a/tests/qtest/migration-test.c
+++ b/tests/qtest/migration-test.c
@@ -876,9 +876,17 @@  test_migrate_tls_x509_start_common(QTestState *from,
     g_mkdir_with_parents(data->workdir, 0700);
 
     test_tls_init(data->keyfile);
+#ifndef _WIN32
     g_assert(link(data->keyfile, data->serverkey) == 0);
+#else
+    g_assert(CreateHardLink(data->serverkey, data->keyfile, NULL) != 0);
+#endif
     if (args->clientcert) {
+#ifndef _WIN32
         g_assert(link(data->keyfile, data->clientkey) == 0);
+#else
+        g_assert(CreateHardLink(data->clientkey, data->keyfile, NULL) != 0);
+#endif
     }
 
     TLS_ROOT_REQ_SIMPLE(cacertreq, data->cacert);