diff mbox series

[v8,13/27] tests: Enable crypto tests under msys2/mingw

Message ID 20200912224431.1428-14-luoyonggang@gmail.com
State Superseded
Headers show
Series W32, W64 msys2/mingw patches | expand

Commit Message

罗勇刚(Yonggang Luo) Sept. 12, 2020, 10:44 p.m. UTC
Fixes following tests on msys2/mingw
      'test-crypto-tlscredsx509': ['crypto-tls-x509-helpers.c', 'pkix_asn1_tab.c',
                                   tasn1, crypto],
      'test-crypto-tlssession': ['crypto-tls-x509-helpers.c', 'pkix_asn1_tab.c', 'crypto-tls-psk-helpers.c',
                                 tasn1, crypto],
      'test-io-channel-tls': ['io-channel-helpers.c', 'crypto-tls-x509-helpers.c', 'pkix_asn1_tab.c',
                              tasn1, io, crypto]}
These tests are failure with:
ERROR test-crypto-tlscredsx509 - missing test plan
ERROR test-crypto-tlssession - missing test plan
ERROR test-io-channel-tls - missing test plan

Because on win32 those test case are all disabled in the header

Add qemu_socket_pair for cross platform support, convert file system
handling functions to glib
Add qemu_link function instead posix only link function.
Use send ad recv from qemu that convert Windows Socks error
to errno properly.

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 tests/crypto-tls-x509-helpers.c  | 169 ++++++++++++++++++++++++++++++-
 tests/crypto-tls-x509-helpers.h  |   9 +-
 tests/test-crypto-tlscredsx509.c |  47 +++++----
 tests/test-crypto-tlssession.c   |  68 +++++++------
 tests/test-io-channel-tls.c      |  51 ++++++----
 5 files changed, 266 insertions(+), 78 deletions(-)

Comments

罗勇刚(Yonggang Luo) Sept. 14, 2020, 8:19 a.m. UTC | #1
On Mon, Sep 14, 2020 at 3:23 PM Thomas Huth <thuth@redhat.com> wrote:
>
> On 13/09/2020 00.44, Yonggang Luo wrote:
> > Fixes following tests on msys2/mingw
> >       'test-crypto-tlscredsx509': ['crypto-tls-x509-helpers.c',
'pkix_asn1_tab.c',
> >                                    tasn1, crypto],
> >       'test-crypto-tlssession': ['crypto-tls-x509-helpers.c',
'pkix_asn1_tab.c', 'crypto-tls-psk-helpers.c',
> >                                  tasn1, crypto],
> >       'test-io-channel-tls': ['io-channel-helpers.c',
'crypto-tls-x509-helpers.c', 'pkix_asn1_tab.c',
> >                               tasn1, io, crypto]}
> > These tests are failure with:
> > ERROR test-crypto-tlscredsx509 - missing test plan
> > ERROR test-crypto-tlssession - missing test plan
> > ERROR test-io-channel-tls - missing test plan
> >
> > Because on win32 those test case are all disabled in the header
> >
> > Add qemu_socket_pair for cross platform support, convert file system
> > handling functions to glib
> > Add qemu_link function instead posix only link function.
> > Use send ad recv from qemu that convert Windows Socks error
> > to errno properly.
> >
> > Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
> > ---
> [...]
> > +static int __stream_socketpair(struct addrinfo* addr_info, int
sock[2]){
> > +    SOCKET listener, client, server;
> > +    int opt = 1;
> > +
> > +    listener = server = client = INVALID_SOCKET;
> > +    listener = socket(addr_info->ai_family, addr_info->ai_socktype,
addr_info->ai_protocol);
> > +    if (INVALID_SOCKET == listener)
> > +        goto fail;
> > +
> > +    setsockopt(listener, SOL_SOCKET, SO_REUSEADDR,(const char*)&opt,
sizeof(opt));
> > +
> > +    if(SOCKET_ERROR == bind(listener, addr_info->ai_addr,
addr_info->ai_addrlen))
> > +        goto fail;
> > +
> > +    if (SOCKET_ERROR == getsockname(listener, addr_info->ai_addr,
(int*)&addr_info->ai_addrlen))
> > +        goto fail;
> > +
> > +    if(SOCKET_ERROR == listen(listener, 5))
> > +        goto fail;
> > +
> > +    client = socket(addr_info->ai_family, addr_info->ai_socktype,
addr_info->ai_protocol);
> > +
> > +    if (INVALID_SOCKET == client)
> > +        goto fail;
> > +
> > +    if (SOCKET_ERROR ==
connect(client,addr_info->ai_addr,addr_info->ai_addrlen))
> > +        goto fail;
> > +
> > +    server = accept(listener, 0, 0);
> > +
> > +    if (INVALID_SOCKET == server)
> > +        goto fail;
> > +
> > +    closesocket(listener);
> > +
> > +    sock[0] = client;
> > +    sock[1] = server;
> > +
> > +    return 0;
> > +fail:
> > +    if(INVALID_SOCKET!=listener)
> > +        closesocket(listener);
> > +    if (INVALID_SOCKET!=client)
> > +        closesocket(client);
> > +    return -1;
> > +}
> > +
> > +static int __dgram_socketpair(struct addrinfo* addr_info, int sock[2])
> > +{
> > +    SOCKET client, server;
> > +    struct addrinfo addr, *result = NULL;
> > +    const char* address;
> > +    int opt = 1;
> > +
> > +    server = client = INVALID_SOCKET;
> > +
> > +    server = socket(addr_info->ai_family, addr_info->ai_socktype,
addr_info->ai_protocol);
> > +    if (INVALID_SOCKET == server)
> > +        goto fail;
> > +
> > +    setsockopt(server, SOL_SOCKET,SO_REUSEADDR, (const char*)&opt,
sizeof(opt));
> > +
> > +    if(SOCKET_ERROR == bind(server, addr_info->ai_addr,
addr_info->ai_addrlen))
> > +        goto fail;
> > +
> > +    if (SOCKET_ERROR == getsockname(server, addr_info->ai_addr,
(int*)&addr_info->ai_addrlen))
> > +        goto fail;
> > +
> > +    client = socket(addr_info->ai_family, addr_info->ai_socktype,
addr_info->ai_protocol);
> > +    if (INVALID_SOCKET == client)
> > +        goto fail;
> > +
> > +    memset(&addr,0,sizeof(addr));
> > +    addr.ai_family = addr_info->ai_family;
> > +    addr.ai_socktype = addr_info->ai_socktype;
> > +    addr.ai_protocol = addr_info->ai_protocol;
> > +
> > +    if (AF_INET6==addr.ai_family)
> > +        address = "0:0:0:0:0:0:0:1";
> > +    else
> > +        address = "127.0.0.1";
> > +
> > +    if (getaddrinfo(address, "0", &addr, &result))
> > +        goto fail;
> > +
> > +    setsockopt(client,SOL_SOCKET,SO_REUSEADDR,(const char*)&opt,
sizeof(opt));
> > +    if(SOCKET_ERROR == bind(client, result->ai_addr,
result->ai_addrlen))
> > +        goto fail;
> > +
> > +    if (SOCKET_ERROR == getsockname(client, result->ai_addr,
(int*)&result->ai_addrlen))
> > +        goto fail;
> > +
> > +    if (SOCKET_ERROR == connect(server, result->ai_addr,
result->ai_addrlen))
> > +        goto fail;
> > +
> > +    if (SOCKET_ERROR == connect(client, addr_info->ai_addr,
addr_info->ai_addrlen))
> > +        goto fail;
> > +
> > +    freeaddrinfo(result);
> > +    sock[0] = client;
> > +    sock[1] = server;
> > +    return 0;
> > +
> > +fail:
> > +    if (INVALID_SOCKET!=client)
> > +        closesocket(client);
> > +    if (INVALID_SOCKET!=server)
> > +        closesocket(server);
> > +    if (result)
> > +        freeaddrinfo(result);
> > +    return -1;
> > +}
> > +
> > +int qemu_socketpair(int family, int type, int protocol,int recv[2]){
> > +    const char* address;
> > +    struct addrinfo addr_info,*p_addrinfo;
> > +    int result = -1;
> > +
> > +    if (family == AF_UNIX)
> > +    {
> > +        family = AF_INET;
> > +    }
> > +
> > +    memset(&addr_info, 0, sizeof(addr_info));
> > +    addr_info.ai_family = family;
> > +    addr_info.ai_socktype = type;
> > +    addr_info.ai_protocol = protocol;
> > +    if (AF_INET6==family)
> > +        address = "0:0:0:0:0:0:0:1";
> > +    else
> > +        address = "127.0.0.1";
> > +
> > +    if (0 == getaddrinfo(address, "0", &addr_info, &p_addrinfo)){
> > +        if (SOCK_STREAM == type)
> > +            result = __stream_socketpair(p_addrinfo, recv);
> > +        else if(SOCK_DGRAM == type)
> > +            result = __dgram_socketpair(p_addrinfo, recv);
> > +        freeaddrinfo(p_addrinfo);
> > +    }
> > +    return result;
> > +}
>
> Where do you've got this code from? It seems like this has been taken
> from a 3rd party source? E.g.:
>
>  https://blog.csdn.net/wufuhuai/article/details/79761889
>
> What's the license of this new code? ... please clarify such details in
The original code have no license information, neither copyleft nor
copyright, what's your suggestion
or rewrite it?

>
> the commit description.
>
>  Thanks,
>   Thomas
>


--
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
<div dir="ltr"><br><br>On Mon, Sep 14, 2020 at 3:23 PM Thomas Huth &lt;<a href="mailto:thuth@redhat.com">thuth@redhat.com</a>&gt; wrote:<br>&gt;<br>&gt; On 13/09/2020 00.44, Yonggang Luo wrote:<br>&gt; &gt; Fixes following tests on msys2/mingw<br>&gt; &gt;       &#39;test-crypto-tlscredsx509&#39;: [&#39;crypto-tls-x509-helpers.c&#39;, &#39;pkix_asn1_tab.c&#39;,<br>&gt; &gt;                                    tasn1, crypto],<br>&gt; &gt;       &#39;test-crypto-tlssession&#39;: [&#39;crypto-tls-x509-helpers.c&#39;, &#39;pkix_asn1_tab.c&#39;, &#39;crypto-tls-psk-helpers.c&#39;,<br>&gt; &gt;                                  tasn1, crypto],<br>&gt; &gt;       &#39;test-io-channel-tls&#39;: [&#39;io-channel-helpers.c&#39;, &#39;crypto-tls-x509-helpers.c&#39;, &#39;pkix_asn1_tab.c&#39;,<br>&gt; &gt;                               tasn1, io, crypto]}<br>&gt; &gt; These tests are failure with:<br>&gt; &gt; ERROR test-crypto-tlscredsx509 - missing test plan<br>&gt; &gt; ERROR test-crypto-tlssession - missing test plan<br>&gt; &gt; ERROR test-io-channel-tls - missing test plan<br>&gt; &gt;<br>&gt; &gt; Because on win32 those test case are all disabled in the header<br>&gt; &gt;<br>&gt; &gt; Add qemu_socket_pair for cross platform support, convert file system<br>&gt; &gt; handling functions to glib<br>&gt; &gt; Add qemu_link function instead posix only link function.<br>&gt; &gt; Use send ad recv from qemu that convert Windows Socks error<br>&gt; &gt; to errno properly.<br>&gt; &gt;<br>&gt; &gt; Signed-off-by: Yonggang Luo &lt;<a href="mailto:luoyonggang@gmail.com">luoyonggang@gmail.com</a>&gt;<br>&gt; &gt; ---<br>&gt; [...]<br>&gt; &gt; +static int __stream_socketpair(struct addrinfo* addr_info, int sock[2]){<br>&gt; &gt; +    SOCKET listener, client, server;<br>&gt; &gt; +    int opt = 1;<br>&gt; &gt; +<br>&gt; &gt; +    listener = server = client = INVALID_SOCKET;<br>&gt; &gt; +    listener = socket(addr_info-&gt;ai_family, addr_info-&gt;ai_socktype, addr_info-&gt;ai_protocol);<br>&gt; &gt; +    if (INVALID_SOCKET == listener)<br>&gt; &gt; +        goto fail;<br>&gt; &gt; +<br>&gt; &gt; +    setsockopt(listener, SOL_SOCKET, SO_REUSEADDR,(const char*)&amp;opt, sizeof(opt));<br>&gt; &gt; +<br>&gt; &gt; +    if(SOCKET_ERROR == bind(listener, addr_info-&gt;ai_addr, addr_info-&gt;ai_addrlen))<br>&gt; &gt; +        goto fail;<br>&gt; &gt; +<br>&gt; &gt; +    if (SOCKET_ERROR == getsockname(listener, addr_info-&gt;ai_addr, (int*)&amp;addr_info-&gt;ai_addrlen))<br>&gt; &gt; +        goto fail;<br>&gt; &gt; +<br>&gt; &gt; +    if(SOCKET_ERROR == listen(listener, 5))<br>&gt; &gt; +        goto fail;<br>&gt; &gt; +<br>&gt; &gt; +    client = socket(addr_info-&gt;ai_family, addr_info-&gt;ai_socktype, addr_info-&gt;ai_protocol);<br>&gt; &gt; +<br>&gt; &gt; +    if (INVALID_SOCKET == client)<br>&gt; &gt; +        goto fail;<br>&gt; &gt; +<br>&gt; &gt; +    if (SOCKET_ERROR == connect(client,addr_info-&gt;ai_addr,addr_info-&gt;ai_addrlen))<br>&gt; &gt; +        goto fail;<br>&gt; &gt; +<br>&gt; &gt; +    server = accept(listener, 0, 0);<br>&gt; &gt; +<br>&gt; &gt; +    if (INVALID_SOCKET == server)<br>&gt; &gt; +        goto fail;<br>&gt; &gt; +<br>&gt; &gt; +    closesocket(listener);<br>&gt; &gt; +<br>&gt; &gt; +    sock[0] = client;<br>&gt; &gt; +    sock[1] = server;<br>&gt; &gt; +<br>&gt; &gt; +    return 0;<br>&gt; &gt; +fail:<br>&gt; &gt; +    if(INVALID_SOCKET!=listener)<br>&gt; &gt; +        closesocket(listener);<br>&gt; &gt; +    if (INVALID_SOCKET!=client)<br>&gt; &gt; +        closesocket(client);<br>&gt; &gt; +    return -1;<br>&gt; &gt; +}<br>&gt; &gt; +<br>&gt; &gt; +static int __dgram_socketpair(struct addrinfo* addr_info, int sock[2])<br>&gt; &gt; +{<br>&gt; &gt; +    SOCKET client, server;<br>&gt; &gt; +    struct addrinfo addr, *result = NULL;<br>&gt; &gt; +    const char* address;<br>&gt; &gt; +    int opt = 1;<br>&gt; &gt; +<br>&gt; &gt; +    server = client = INVALID_SOCKET;<br>&gt; &gt; +<br>&gt; &gt; +    server = socket(addr_info-&gt;ai_family, addr_info-&gt;ai_socktype, addr_info-&gt;ai_protocol); <br>&gt; &gt; +    if (INVALID_SOCKET == server)<br>&gt; &gt; +        goto fail;<br>&gt; &gt; +<br>&gt; &gt; +    setsockopt(server, SOL_SOCKET,SO_REUSEADDR, (const char*)&amp;opt, sizeof(opt));<br>&gt; &gt; +<br>&gt; &gt; +    if(SOCKET_ERROR == bind(server, addr_info-&gt;ai_addr, addr_info-&gt;ai_addrlen))<br>&gt; &gt; +        goto fail;<br>&gt; &gt; +<br>&gt; &gt; +    if (SOCKET_ERROR == getsockname(server, addr_info-&gt;ai_addr, (int*)&amp;addr_info-&gt;ai_addrlen))<br>&gt; &gt; +        goto fail;<br>&gt; &gt; +<br>&gt; &gt; +    client = socket(addr_info-&gt;ai_family, addr_info-&gt;ai_socktype, addr_info-&gt;ai_protocol);<br>&gt; &gt; +    if (INVALID_SOCKET == client)<br>&gt; &gt; +        goto fail;<br>&gt; &gt; +<br>&gt; &gt; +    memset(&amp;addr,0,sizeof(addr));<br>&gt; &gt; +    addr.ai_family = addr_info-&gt;ai_family;<br>&gt; &gt; +    addr.ai_socktype = addr_info-&gt;ai_socktype;<br>&gt; &gt; +    addr.ai_protocol = addr_info-&gt;ai_protocol;<br>&gt; &gt; +<br>&gt; &gt; +    if (AF_INET6==addr.ai_family)<br>&gt; &gt; +        address = &quot;0:0:0:0:0:0:0:1&quot;;<br>&gt; &gt; +    else<br>&gt; &gt; +        address = &quot;127.0.0.1&quot;;<br>&gt; &gt; +<br>&gt; &gt; +    if (getaddrinfo(address, &quot;0&quot;, &amp;addr, &amp;result))<br>&gt; &gt; +        goto fail;<br>&gt; &gt; +<br>&gt; &gt; +    setsockopt(client,SOL_SOCKET,SO_REUSEADDR,(const char*)&amp;opt, sizeof(opt));<br>&gt; &gt; +    if(SOCKET_ERROR == bind(client, result-&gt;ai_addr, result-&gt;ai_addrlen))<br>&gt; &gt; +        goto fail;<br>&gt; &gt; +<br>&gt; &gt; +    if (SOCKET_ERROR == getsockname(client, result-&gt;ai_addr, (int*)&amp;result-&gt;ai_addrlen))<br>&gt; &gt; +        goto fail;<br>&gt; &gt; +<br>&gt; &gt; +    if (SOCKET_ERROR == connect(server, result-&gt;ai_addr, result-&gt;ai_addrlen))<br>&gt; &gt; +        goto fail;<br>&gt; &gt; +<br>&gt; &gt; +    if (SOCKET_ERROR == connect(client, addr_info-&gt;ai_addr, addr_info-&gt;ai_addrlen))<br>&gt; &gt; +        goto fail;<br>&gt; &gt; +<br>&gt; &gt; +    freeaddrinfo(result);<br>&gt; &gt; +    sock[0] = client;<br>&gt; &gt; +    sock[1] = server;<br>&gt; &gt; +    return 0;<br>&gt; &gt; +<br>&gt; &gt; +fail:<br>&gt; &gt; +    if (INVALID_SOCKET!=client)<br>&gt; &gt; +        closesocket(client);<br>&gt; &gt; +    if (INVALID_SOCKET!=server)<br>&gt; &gt; +        closesocket(server);<br>&gt; &gt; +    if (result)<br>&gt; &gt; +        freeaddrinfo(result);<br>&gt; &gt; +    return -1;<br>&gt; &gt; +}<br>&gt; &gt; +<br>&gt; &gt; +int qemu_socketpair(int family, int type, int protocol,int recv[2]){<br>&gt; &gt; +    const char* address;<br>&gt; &gt; +    struct addrinfo addr_info,*p_addrinfo;<br>&gt; &gt; +    int result = -1;<br>&gt; &gt; +<br>&gt; &gt; +    if (family == AF_UNIX)<br>&gt; &gt; +    {<br>&gt; &gt; +        family = AF_INET;<br>&gt; &gt; +    }<br>&gt; &gt; +<br>&gt; &gt; +    memset(&amp;addr_info, 0, sizeof(addr_info));<br>&gt; &gt; +    addr_info.ai_family = family;<br>&gt; &gt; +    addr_info.ai_socktype = type;<br>&gt; &gt; +    addr_info.ai_protocol = protocol;<br>&gt; &gt; +    if (AF_INET6==family)<br>&gt; &gt; +        address = &quot;0:0:0:0:0:0:0:1&quot;;<br>&gt; &gt; +    else<br>&gt; &gt; +        address = &quot;127.0.0.1&quot;;<br>&gt; &gt; +<br>&gt; &gt; +    if (0 == getaddrinfo(address, &quot;0&quot;, &amp;addr_info, &amp;p_addrinfo)){<br>&gt; &gt; +        if (SOCK_STREAM == type)<br>&gt; &gt; +            result = __stream_socketpair(p_addrinfo, recv);<br>&gt; &gt; +        else if(SOCK_DGRAM == type)<br>&gt; &gt; +            result = __dgram_socketpair(p_addrinfo, recv);<br>&gt; &gt; +        freeaddrinfo(p_addrinfo);<br>&gt; &gt; +    }<br>&gt; &gt; +    return result;<br>&gt; &gt; +}<br>&gt;<br>&gt; Where do you&#39;ve got this code from? It seems like this has been taken<br>&gt; from a 3rd party source? E.g.:<br>&gt;<br>&gt;  <a href="https://blog.csdn.net/wufuhuai/article/details/79761889">https://blog.csdn.net/wufuhuai/article/details/79761889</a><br>&gt;<br>&gt; What&#39;s the license of this new code? ... please clarify such details in<br>The original code have no license information, neither copyleft nor copyright, what&#39;s your suggestion<div>or rewrite it?<br> <br>&gt;<br>&gt; the commit description.<br>&gt;<br>&gt;  Thanks,<br>&gt;   Thomas<br>&gt;<br><br><br>--<br>         此致<br>礼<br>罗勇刚<br>Yours<br>    sincerely,<br>Yonggang Luo</div></div>
Thomas Huth Sept. 14, 2020, 11:07 a.m. UTC | #2
On 14/09/2020 10.19, 罗勇刚(Yonggang Luo) wrote:
> 
> 
> On Mon, Sep 14, 2020 at 3:23 PM Thomas Huth <thuth@redhat.com
> <mailto:thuth@redhat.com>> wrote:
>>
>> On 13/09/2020 00.44, Yonggang Luo wrote:
>> > Fixes following tests on msys2/mingw
>> >       'test-crypto-tlscredsx509': ['crypto-tls-x509-helpers.c',
> 'pkix_asn1_tab.c',
>> >                                    tasn1, crypto],
>> >       'test-crypto-tlssession': ['crypto-tls-x509-helpers.c',
> 'pkix_asn1_tab.c', 'crypto-tls-psk-helpers.c',
>> >                                  tasn1, crypto],
>> >       'test-io-channel-tls': ['io-channel-helpers.c',
> 'crypto-tls-x509-helpers.c', 'pkix_asn1_tab.c',
>> >                               tasn1, io, crypto]}
>> > These tests are failure with:
>> > ERROR test-crypto-tlscredsx509 - missing test plan
>> > ERROR test-crypto-tlssession - missing test plan
>> > ERROR test-io-channel-tls - missing test plan
>> >
>> > Because on win32 those test case are all disabled in the header
>> >
>> > Add qemu_socket_pair for cross platform support, convert file system
>> > handling functions to glib
>> > Add qemu_link function instead posix only link function.
>> > Use send ad recv from qemu that convert Windows Socks error
>> > to errno properly.
>> >
>> > Signed-off-by: Yonggang Luo <luoyonggang@gmail.com
> <mailto:luoyonggang@gmail.com>>
>> > ---
[...]
>> Where do you've got this code from? It seems like this has been taken
>> from a 3rd party source? E.g.:
>>
>>  https://blog.csdn.net/wufuhuai/article/details/79761889
>>
>> What's the license of this new code? ... please clarify such details in
>> the commit description.
>
> The original code have no license information, neither copyleft nor
> copyright, what's your suggestion
> or rewrite it?
>  

You can not simply copy code without license information and submit this
as if it was your own! Please never do that again!
With your Signed-off-by line, you basically acknowledge that you've read
and followed the Developer Certificate of Origin:

 https://developercertificate.org/

If you haven't done that yet, please do it now!

And for this patch here, I don't think that it is acceptable without
proper license information.

 Thomas
罗勇刚(Yonggang Luo) Sept. 14, 2020, 3:58 p.m. UTC | #3
On Mon, Sep 14, 2020 at 7:07 PM Thomas Huth <thuth@redhat.com> wrote:
>

> On 14/09/2020 10.19, 罗勇刚(Yonggang Luo) wrote:

> >

> >

> > On Mon, Sep 14, 2020 at 3:23 PM Thomas Huth <thuth@redhat.com

> > <mailto:thuth@redhat.com>> wrote:

> >>

> >> On 13/09/2020 00.44, Yonggang Luo wrote:

> >> > Fixes following tests on msys2/mingw

> >> >       'test-crypto-tlscredsx509': ['crypto-tls-x509-helpers.c',

> > 'pkix_asn1_tab.c',

> >> >                                    tasn1, crypto],

> >> >       'test-crypto-tlssession': ['crypto-tls-x509-helpers.c',

> > 'pkix_asn1_tab.c', 'crypto-tls-psk-helpers.c',

> >> >                                  tasn1, crypto],

> >> >       'test-io-channel-tls': ['io-channel-helpers.c',

> > 'crypto-tls-x509-helpers.c', 'pkix_asn1_tab.c',

> >> >                               tasn1, io, crypto]}

> >> > These tests are failure with:

> >> > ERROR test-crypto-tlscredsx509 - missing test plan

> >> > ERROR test-crypto-tlssession - missing test plan

> >> > ERROR test-io-channel-tls - missing test plan

> >> >

> >> > Because on win32 those test case are all disabled in the header

> >> >

> >> > Add qemu_socket_pair for cross platform support, convert file system

> >> > handling functions to glib

> >> > Add qemu_link function instead posix only link function.

> >> > Use send ad recv from qemu that convert Windows Socks error

> >> > to errno properly.

> >> >

> >> > Signed-off-by: Yonggang Luo <luoyonggang@gmail.com

> > <mailto:luoyonggang@gmail.com>>

> >> > ---

> [...]

> >> Where do you've got this code from? It seems like this has been taken

> >> from a 3rd party source? E.g.:

> >>

> >>  https://blog.csdn.net/wufuhuai/article/details/79761889

> >>

> >> What's the license of this new code? ... please clarify such details in

> >> the commit description.

> >

> > The original code have no license information, neither copyleft nor

> > copyright, what's your suggestion

> > or rewrite it?

> >

>

> You can not simply copy code without license information and submit this

> as if it was your own! Please never do that again!

> With your Signed-off-by line, you basically acknowledge that you've read

> and followed the Developer Certificate of Origin:

>

>  https://developercertificate.org/

>

> If you haven't done that yet, please do it now!

>

> And for this patch here, I don't think that it is acceptable without

> proper license information.

>

>  Thomas

>

See that, How about using
https://developer.gnome.org/glib/stable/glib-IO-Channels.html#g-io-channel-new-file
to act as socketpair? and it's cross-platform, I don't need to add
platform-dependent codes.

--
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
<div dir="ltr"><br><br>On Mon, Sep 14, 2020 at 7:07 PM Thomas Huth &lt;<a href="mailto:thuth@redhat.com">thuth@redhat.com</a>&gt; wrote:<br>&gt;<br>&gt; On 14/09/2020 10.19, 罗勇刚(Yonggang Luo) wrote:<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; On Mon, Sep 14, 2020 at 3:23 PM Thomas Huth &lt;<a href="mailto:thuth@redhat.com">thuth@redhat.com</a><br>&gt; &gt; &lt;mailto:<a href="mailto:thuth@redhat.com">thuth@redhat.com</a>&gt;&gt; wrote:<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; On 13/09/2020 00.44, Yonggang Luo wrote:<br>&gt; &gt;&gt; &gt; Fixes following tests on msys2/mingw<br>&gt; &gt;&gt; &gt;       &#39;test-crypto-tlscredsx509&#39;: [&#39;crypto-tls-x509-helpers.c&#39;,<br>&gt; &gt; &#39;pkix_asn1_tab.c&#39;,<br>&gt; &gt;&gt; &gt;                                    tasn1, crypto],<br>&gt; &gt;&gt; &gt;       &#39;test-crypto-tlssession&#39;: [&#39;crypto-tls-x509-helpers.c&#39;,<br>&gt; &gt; &#39;pkix_asn1_tab.c&#39;, &#39;crypto-tls-psk-helpers.c&#39;,<br>&gt; &gt;&gt; &gt;                                  tasn1, crypto],<br>&gt; &gt;&gt; &gt;       &#39;test-io-channel-tls&#39;: [&#39;io-channel-helpers.c&#39;,<br>&gt; &gt; &#39;crypto-tls-x509-helpers.c&#39;, &#39;pkix_asn1_tab.c&#39;,<br>&gt; &gt;&gt; &gt;                               tasn1, io, crypto]}<br>&gt; &gt;&gt; &gt; These tests are failure with:<br>&gt; &gt;&gt; &gt; ERROR test-crypto-tlscredsx509 - missing test plan<br>&gt; &gt;&gt; &gt; ERROR test-crypto-tlssession - missing test plan<br>&gt; &gt;&gt; &gt; ERROR test-io-channel-tls - missing test plan<br>&gt; &gt;&gt; &gt;<br>&gt; &gt;&gt; &gt; Because on win32 those test case are all disabled in the header<br>&gt; &gt;&gt; &gt;<br>&gt; &gt;&gt; &gt; Add qemu_socket_pair for cross platform support, convert file system<br>&gt; &gt;&gt; &gt; handling functions to glib<br>&gt; &gt;&gt; &gt; Add qemu_link function instead posix only link function.<br>&gt; &gt;&gt; &gt; Use send ad recv from qemu that convert Windows Socks error<br>&gt; &gt;&gt; &gt; to errno properly.<br>&gt; &gt;&gt; &gt;<br>&gt; &gt;&gt; &gt; Signed-off-by: Yonggang Luo &lt;<a href="mailto:luoyonggang@gmail.com">luoyonggang@gmail.com</a><br>&gt; &gt; &lt;mailto:<a href="mailto:luoyonggang@gmail.com">luoyonggang@gmail.com</a>&gt;&gt;<br>&gt; &gt;&gt; &gt; ---<br>&gt; [...]<br>&gt; &gt;&gt; Where do you&#39;ve got this code from? It seems like this has been taken<br>&gt; &gt;&gt; from a 3rd party source? E.g.:<br>&gt; &gt;&gt;<br>&gt; &gt;&gt;  <a href="https://blog.csdn.net/wufuhuai/article/details/79761889">https://blog.csdn.net/wufuhuai/article/details/79761889</a><br>&gt; &gt;&gt;<br>&gt; &gt;&gt; What&#39;s the license of this new code? ... please clarify such details in<br>&gt; &gt;&gt; the commit description.<br>&gt; &gt;<br>&gt; &gt; The original code have no license information, neither copyleft nor<br>&gt; &gt; copyright, what&#39;s your suggestion<br>&gt; &gt; or rewrite it?<br>&gt; &gt;  <br>&gt;<br>&gt; You can not simply copy code without license information and submit this<br>&gt; as if it was your own! Please never do that again!<br>&gt; With your Signed-off-by line, you basically acknowledge that you&#39;ve read<br>&gt; and followed the Developer Certificate of Origin:<br>&gt;<br>&gt;  <a href="https://developercertificate.org/">https://developercertificate.org/</a><br>&gt;<br>&gt; If you haven&#39;t done that yet, please do it now!<br>&gt;<br>&gt; And for this patch here, I don&#39;t think that it is acceptable without<br>&gt; proper license information.<br>&gt;<br>&gt;  Thomas<br>&gt;<br>See that, How about using <a href="https://developer.gnome.org/glib/stable/glib-IO-Channels.html#g-io-channel-new-file">https://developer.gnome.org/glib/stable/glib-IO-Channels.html#g-io-channel-new-file</a><div>to act as socketpair? and it&#39;s cross-platform, I don&#39;t need to add platform-dependent codes.<br><br>--<br>         此致<br>礼<br>罗勇刚<br>Yours<br>    sincerely,<br>Yonggang Luo</div></div>
Daniel P. Berrangé Sept. 14, 2020, 4:13 p.m. UTC | #4
On Mon, Sep 14, 2020 at 11:58:24PM +0800, 罗勇刚(Yonggang Luo) wrote:
> On Mon, Sep 14, 2020 at 7:07 PM Thomas Huth <thuth@redhat.com> wrote:

> >

> > On 14/09/2020 10.19, 罗勇刚(Yonggang Luo) wrote:

> > >

> > >

> > > On Mon, Sep 14, 2020 at 3:23 PM Thomas Huth <thuth@redhat.com

> > > <mailto:thuth@redhat.com>> wrote:

> > >>

> > >> On 13/09/2020 00.44, Yonggang Luo wrote:

> > >> > Fixes following tests on msys2/mingw

> > >> >       'test-crypto-tlscredsx509': ['crypto-tls-x509-helpers.c',

> > > 'pkix_asn1_tab.c',

> > >> >                                    tasn1, crypto],

> > >> >       'test-crypto-tlssession': ['crypto-tls-x509-helpers.c',

> > > 'pkix_asn1_tab.c', 'crypto-tls-psk-helpers.c',

> > >> >                                  tasn1, crypto],

> > >> >       'test-io-channel-tls': ['io-channel-helpers.c',

> > > 'crypto-tls-x509-helpers.c', 'pkix_asn1_tab.c',

> > >> >                               tasn1, io, crypto]}

> > >> > These tests are failure with:

> > >> > ERROR test-crypto-tlscredsx509 - missing test plan

> > >> > ERROR test-crypto-tlssession - missing test plan

> > >> > ERROR test-io-channel-tls - missing test plan

> > >> >

> > >> > Because on win32 those test case are all disabled in the header

> > >> >

> > >> > Add qemu_socket_pair for cross platform support, convert file system

> > >> > handling functions to glib

> > >> > Add qemu_link function instead posix only link function.

> > >> > Use send ad recv from qemu that convert Windows Socks error

> > >> > to errno properly.

> > >> >

> > >> > Signed-off-by: Yonggang Luo <luoyonggang@gmail.com

> > > <mailto:luoyonggang@gmail.com>>

> > >> > ---

> > [...]

> > >> Where do you've got this code from? It seems like this has been taken

> > >> from a 3rd party source? E.g.:

> > >>

> > >>  https://blog.csdn.net/wufuhuai/article/details/79761889

> > >>

> > >> What's the license of this new code? ... please clarify such details in

> > >> the commit description.

> > >

> > > The original code have no license information, neither copyleft nor

> > > copyright, what's your suggestion

> > > or rewrite it?

> > >

> >

> > You can not simply copy code without license information and submit this

> > as if it was your own! Please never do that again!

> > With your Signed-off-by line, you basically acknowledge that you've read

> > and followed the Developer Certificate of Origin:

> >

> >  https://developercertificate.org/

> >

> > If you haven't done that yet, please do it now!

> >

> > And for this patch here, I don't think that it is acceptable without

> > proper license information.

> >

> >  Thomas

> >

> See that, How about using

> https://developer.gnome.org/glib/stable/glib-IO-Channels.html#g-io-channel-new-file

> to act as socketpair? and it's cross-platform, I don't need to add

> platform-dependent codes.


That doesn't provide socketpair functionality. QEMU already has its
QIOChannel impl that is more advanced, but again that doesn't have
socketpair either because Windows lacks that.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
罗勇刚(Yonggang Luo) Sept. 14, 2020, 6:31 p.m. UTC | #5
On Tue, Sep 15, 2020 at 12:14 AM Daniel P. Berrangé <berrange@redhat.com>
wrote:
>

> On Mon, Sep 14, 2020 at 11:58:24PM +0800, 罗勇刚(Yonggang Luo) wrote:

> > On Mon, Sep 14, 2020 at 7:07 PM Thomas Huth <thuth@redhat.com> wrote:

> > >

> > > On 14/09/2020 10.19, 罗勇刚(Yonggang Luo) wrote:

> > > >

> > > >

> > > > On Mon, Sep 14, 2020 at 3:23 PM Thomas Huth <thuth@redhat.com

> > > > <mailto:thuth@redhat.com>> wrote:

> > > >>

> > > >> On 13/09/2020 00.44, Yonggang Luo wrote:

> > > >> > Fixes following tests on msys2/mingw

> > > >> >       'test-crypto-tlscredsx509': ['crypto-tls-x509-helpers.c',

> > > > 'pkix_asn1_tab.c',

> > > >> >                                    tasn1, crypto],

> > > >> >       'test-crypto-tlssession': ['crypto-tls-x509-helpers.c',

> > > > 'pkix_asn1_tab.c', 'crypto-tls-psk-helpers.c',

> > > >> >                                  tasn1, crypto],

> > > >> >       'test-io-channel-tls': ['io-channel-helpers.c',

> > > > 'crypto-tls-x509-helpers.c', 'pkix_asn1_tab.c',

> > > >> >                               tasn1, io, crypto]}

> > > >> > These tests are failure with:

> > > >> > ERROR test-crypto-tlscredsx509 - missing test plan

> > > >> > ERROR test-crypto-tlssession - missing test plan

> > > >> > ERROR test-io-channel-tls - missing test plan

> > > >> >

> > > >> > Because on win32 those test case are all disabled in the header

> > > >> >

> > > >> > Add qemu_socket_pair for cross platform support, convert file

system
> > > >> > handling functions to glib

> > > >> > Add qemu_link function instead posix only link function.

> > > >> > Use send ad recv from qemu that convert Windows Socks error

> > > >> > to errno properly.

> > > >> >

> > > >> > Signed-off-by: Yonggang Luo <luoyonggang@gmail.com

> > > > <mailto:luoyonggang@gmail.com>>

> > > >> > ---

> > > [...]

> > > >> Where do you've got this code from? It seems like this has been

taken
> > > >> from a 3rd party source? E.g.:

> > > >>

> > > >>  https://blog.csdn.net/wufuhuai/article/details/79761889

> > > >>

> > > >> What's the license of this new code? ... please clarify such

details in
> > > >> the commit description.

> > > >

> > > > The original code have no license information, neither copyleft nor

> > > > copyright, what's your suggestion

> > > > or rewrite it?

> > > >

> > >

> > > You can not simply copy code without license information and submit

this
> > > as if it was your own! Please never do that again!

> > > With your Signed-off-by line, you basically acknowledge that you've

read
> > > and followed the Developer Certificate of Origin:

> > >

> > >  https://developercertificate.org/

> > >

> > > If you haven't done that yet, please do it now!

> > >

> > > And for this patch here, I don't think that it is acceptable without

> > > proper license information.

> > >

> > >  Thomas

> > >

> > See that, How about using

> >

https://developer.gnome.org/glib/stable/glib-IO-Channels.html#g-io-channel-new-file
> > to act as socketpair? and it's cross-platform, I don't need to add

> > platform-dependent codes.

>

> That doesn't provide socketpair functionality. QEMU already has its

> QIOChannel impl that is more advanced, but again that doesn't have

> socketpair either because Windows lacks that.


Doesn't need the   socketpair  functionality, we just need two FIFO, and
handle the fifo full empty by raising
EAGAIN error at
```
static ssize_t testWrite(const char *buf, size_t len, void *opaque)
{
    int *fd = opaque;
    int written = send(*fd, buf, len, 0);
    return written;
}

static ssize_t testRead(char *buf, size_t len, void *opaque)
{
    int *fd = opaque;

    int readed = recv(*fd, buf, len, 0);
    return readed;
}
```
>

> Regards,

> Daniel

> --

> |: https://berrange.com      -o-

https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org         -o-

https://fstop138.berrange.com :|
> |: https://entangle-photo.org    -o-

https://www.instagram.com/dberrange :|
>



--
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
<div dir="ltr"><br><br>On Tue, Sep 15, 2020 at 12:14 AM Daniel P. Berrangé &lt;<a href="mailto:berrange@redhat.com">berrange@redhat.com</a>&gt; wrote:<br>&gt;<br>&gt; On Mon, Sep 14, 2020 at 11:58:24PM +0800, 罗勇刚(Yonggang Luo) wrote:<br>&gt; &gt; On Mon, Sep 14, 2020 at 7:07 PM Thomas Huth &lt;<a href="mailto:thuth@redhat.com">thuth@redhat.com</a>&gt; wrote:<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; On 14/09/2020 10.19, 罗勇刚(Yonggang Luo) wrote:<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; On Mon, Sep 14, 2020 at 3:23 PM Thomas Huth &lt;<a href="mailto:thuth@redhat.com">thuth@redhat.com</a><br>&gt; &gt; &gt; &gt; &lt;mailto:<a href="mailto:thuth@redhat.com">thuth@redhat.com</a>&gt;&gt; wrote:<br>&gt; &gt; &gt; &gt;&gt;<br>&gt; &gt; &gt; &gt;&gt; On 13/09/2020 00.44, Yonggang Luo wrote:<br>&gt; &gt; &gt; &gt;&gt; &gt; Fixes following tests on msys2/mingw<br>&gt; &gt; &gt; &gt;&gt; &gt;       &#39;test-crypto-tlscredsx509&#39;: [&#39;crypto-tls-x509-helpers.c&#39;,<br>&gt; &gt; &gt; &gt; &#39;pkix_asn1_tab.c&#39;,<br>&gt; &gt; &gt; &gt;&gt; &gt;                                    tasn1, crypto],<br>&gt; &gt; &gt; &gt;&gt; &gt;       &#39;test-crypto-tlssession&#39;: [&#39;crypto-tls-x509-helpers.c&#39;,<br>&gt; &gt; &gt; &gt; &#39;pkix_asn1_tab.c&#39;, &#39;crypto-tls-psk-helpers.c&#39;,<br>&gt; &gt; &gt; &gt;&gt; &gt;                                  tasn1, crypto],<br>&gt; &gt; &gt; &gt;&gt; &gt;       &#39;test-io-channel-tls&#39;: [&#39;io-channel-helpers.c&#39;,<br>&gt; &gt; &gt; &gt; &#39;crypto-tls-x509-helpers.c&#39;, &#39;pkix_asn1_tab.c&#39;,<br>&gt; &gt; &gt; &gt;&gt; &gt;                               tasn1, io, crypto]}<br>&gt; &gt; &gt; &gt;&gt; &gt; These tests are failure with:<br>&gt; &gt; &gt; &gt;&gt; &gt; ERROR test-crypto-tlscredsx509 - missing test plan<br>&gt; &gt; &gt; &gt;&gt; &gt; ERROR test-crypto-tlssession - missing test plan<br>&gt; &gt; &gt; &gt;&gt; &gt; ERROR test-io-channel-tls - missing test plan<br>&gt; &gt; &gt; &gt;&gt; &gt;<br>&gt; &gt; &gt; &gt;&gt; &gt; Because on win32 those test case are all disabled in the header<br>&gt; &gt; &gt; &gt;&gt; &gt;<br>&gt; &gt; &gt; &gt;&gt; &gt; Add qemu_socket_pair for cross platform support, convert file system<br>&gt; &gt; &gt; &gt;&gt; &gt; handling functions to glib<br>&gt; &gt; &gt; &gt;&gt; &gt; Add qemu_link function instead posix only link function.<br>&gt; &gt; &gt; &gt;&gt; &gt; Use send ad recv from qemu that convert Windows Socks error<br>&gt; &gt; &gt; &gt;&gt; &gt; to errno properly.<br>&gt; &gt; &gt; &gt;&gt; &gt;<br>&gt; &gt; &gt; &gt;&gt; &gt; Signed-off-by: Yonggang Luo &lt;<a href="mailto:luoyonggang@gmail.com">luoyonggang@gmail.com</a><br>&gt; &gt; &gt; &gt; &lt;mailto:<a href="mailto:luoyonggang@gmail.com">luoyonggang@gmail.com</a>&gt;&gt;<br>&gt; &gt; &gt; &gt;&gt; &gt; ---<br>&gt; &gt; &gt; [...]<br>&gt; &gt; &gt; &gt;&gt; Where do you&#39;ve got this code from? It seems like this has been taken<br>&gt; &gt; &gt; &gt;&gt; from a 3rd party source? E.g.:<br>&gt; &gt; &gt; &gt;&gt;<br>&gt; &gt; &gt; &gt;&gt;  <a href="https://blog.csdn.net/wufuhuai/article/details/79761889">https://blog.csdn.net/wufuhuai/article/details/79761889</a><br>&gt; &gt; &gt; &gt;&gt;<br>&gt; &gt; &gt; &gt;&gt; What&#39;s the license of this new code? ... please clarify such details in<br>&gt; &gt; &gt; &gt;&gt; the commit description.<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; The original code have no license information, neither copyleft nor<br>&gt; &gt; &gt; &gt; copyright, what&#39;s your suggestion<br>&gt; &gt; &gt; &gt; or rewrite it?<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; You can not simply copy code without license information and submit this<br>&gt; &gt; &gt; as if it was your own! Please never do that again!<br>&gt; &gt; &gt; With your Signed-off-by line, you basically acknowledge that you&#39;ve read<br>&gt; &gt; &gt; and followed the Developer Certificate of Origin:<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;  <a href="https://developercertificate.org/">https://developercertificate.org/</a><br>&gt; &gt; &gt;<br>&gt; &gt; &gt; If you haven&#39;t done that yet, please do it now!<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; And for this patch here, I don&#39;t think that it is acceptable without<br>&gt; &gt; &gt; proper license information.<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;  Thomas<br>&gt; &gt; &gt;<br>&gt; &gt; See that, How about using<br>&gt; &gt; <a href="https://developer.gnome.org/glib/stable/glib-IO-Channels.html#g-io-channel-new-file">https://developer.gnome.org/glib/stable/glib-IO-Channels.html#g-io-channel-new-file</a><br>&gt; &gt; to act as socketpair? and it&#39;s cross-platform, I don&#39;t need to add<br>&gt; &gt; platform-dependent codes.<br>&gt;<br>&gt; That doesn&#39;t provide socketpair functionality. QEMU already has its<br>&gt; QIOChannel impl that is more advanced, but again that doesn&#39;t have<br>&gt; socketpair either because Windows lacks that.<br><br>Doesn&#39;t need the   socketpair  functionality, we just need two FIFO, and handle the fifo full empty by raising <br>EAGAIN error at<br>```<br>static ssize_t testWrite(const char *buf, size_t len, void *opaque)<br>{<br>    int *fd = opaque;<br>    int written = send(*fd, buf, len, 0);<br>    return written;<br>}<br><br>static ssize_t testRead(char *buf, size_t len, void *opaque)<br>{<br>    int *fd = opaque;<br><br>    int readed = recv(*fd, buf, len, 0);<br>    return readed;<br>}<br>```<br>&gt;<br>&gt; Regards,<br>&gt; Daniel<br>&gt; --<br>&gt; |: <a href="https://berrange.com">https://berrange.com</a>      -o-    <a href="https://www.flickr.com/photos/dberrange">https://www.flickr.com/photos/dberrange</a> :|<br>&gt; |: <a href="https://libvirt.org">https://libvirt.org</a>         -o-            <a href="https://fstop138.berrange.com">https://fstop138.berrange.com</a> :|<br>&gt; |: <a href="https://entangle-photo.org">https://entangle-photo.org</a>    -o-    <a href="https://www.instagram.com/dberrange">https://www.instagram.com/dberrange</a> :|<br>&gt;<br><br><br>--<br>         此致<br>礼<br>罗勇刚<br>Yours<br>    sincerely,<br>Yonggang Luo</div>
diff mbox series

Patch

diff --git a/tests/crypto-tls-x509-helpers.c b/tests/crypto-tls-x509-helpers.c
index 01b3daf358..c624d8799b 100644
--- a/tests/crypto-tls-x509-helpers.c
+++ b/tests/crypto-tls-x509-helpers.c
@@ -23,6 +23,8 @@ 
 #include "crypto-tls-x509-helpers.h"
 #include "crypto/init.h"
 #include "qemu/sockets.h"
+#include <glib.h>
+#include <glib/gstdio.h>
 
 #ifdef QCRYPTO_HAVE_TLS_TEST_SUPPORT
 
@@ -133,7 +135,7 @@  void test_tls_init(const char *keyfile)
 void test_tls_cleanup(const char *keyfile)
 {
     asn1_delete_structure(&pkix_asn1);
-    unlink(keyfile);
+    g_remove(keyfile);
 }
 
 /*
@@ -501,8 +503,171 @@  void test_tls_discard_cert(QCryptoTLSTestCertReq *req)
     req->crt = NULL;
 
     if (getenv("QEMU_TEST_DEBUG_CERTS") == NULL) {
-        unlink(req->filename);
+        g_remove(req->filename);
     }
 }
 
+int qemu_link(const char *exist_path1, const char *new_path2)
+{
+#ifdef _WIN32
+    g_autofree gchar *current_dir = g_get_current_dir();
+    g_autofree gchar *full_path = g_build_filename(current_dir, exist_path1, NULL);
+    return CreateSymbolicLinkA(new_path2, full_path, 0 | SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE) ? 0 : -1;
+#else
+    return link(exist_path1, new_path2);
+#endif
+}
+
+#ifdef _WIN32
+
+static int __stream_socketpair(struct addrinfo* addr_info, int sock[2]){
+    SOCKET listener, client, server;
+    int opt = 1;
+
+    listener = server = client = INVALID_SOCKET;
+    listener = socket(addr_info->ai_family, addr_info->ai_socktype, addr_info->ai_protocol);
+    if (INVALID_SOCKET == listener)
+        goto fail;
+
+    setsockopt(listener, SOL_SOCKET, SO_REUSEADDR,(const char*)&opt, sizeof(opt));
+
+    if(SOCKET_ERROR == bind(listener, addr_info->ai_addr, addr_info->ai_addrlen))
+        goto fail;
+
+    if (SOCKET_ERROR == getsockname(listener, addr_info->ai_addr, (int*)&addr_info->ai_addrlen))
+        goto fail;
+
+    if(SOCKET_ERROR == listen(listener, 5))
+        goto fail;
+
+    client = socket(addr_info->ai_family, addr_info->ai_socktype, addr_info->ai_protocol);
+
+    if (INVALID_SOCKET == client)
+        goto fail;
+
+    if (SOCKET_ERROR == connect(client,addr_info->ai_addr,addr_info->ai_addrlen))
+        goto fail;
+
+    server = accept(listener, 0, 0);
+
+    if (INVALID_SOCKET == server)
+        goto fail;
+
+    closesocket(listener);
+
+    sock[0] = client;
+    sock[1] = server;
+
+    return 0;
+fail:
+    if(INVALID_SOCKET!=listener)
+        closesocket(listener);
+    if (INVALID_SOCKET!=client)
+        closesocket(client);
+    return -1;
+}
+
+static int __dgram_socketpair(struct addrinfo* addr_info, int sock[2])
+{
+    SOCKET client, server;
+    struct addrinfo addr, *result = NULL;
+    const char* address;
+    int opt = 1;
+
+    server = client = INVALID_SOCKET;
+
+    server = socket(addr_info->ai_family, addr_info->ai_socktype, addr_info->ai_protocol);  
+    if (INVALID_SOCKET == server)
+        goto fail;
+
+    setsockopt(server, SOL_SOCKET,SO_REUSEADDR, (const char*)&opt, sizeof(opt));
+
+    if(SOCKET_ERROR == bind(server, addr_info->ai_addr, addr_info->ai_addrlen))
+        goto fail;
+
+    if (SOCKET_ERROR == getsockname(server, addr_info->ai_addr, (int*)&addr_info->ai_addrlen))
+        goto fail;
+
+    client = socket(addr_info->ai_family, addr_info->ai_socktype, addr_info->ai_protocol); 
+    if (INVALID_SOCKET == client)
+        goto fail;
+
+    memset(&addr,0,sizeof(addr));
+    addr.ai_family = addr_info->ai_family;
+    addr.ai_socktype = addr_info->ai_socktype;
+    addr.ai_protocol = addr_info->ai_protocol;
+
+    if (AF_INET6==addr.ai_family)
+        address = "0:0:0:0:0:0:0:1";
+    else
+        address = "127.0.0.1";
+
+    if (getaddrinfo(address, "0", &addr, &result))
+        goto fail;
+
+    setsockopt(client,SOL_SOCKET,SO_REUSEADDR,(const char*)&opt, sizeof(opt));
+    if(SOCKET_ERROR == bind(client, result->ai_addr, result->ai_addrlen))
+        goto fail;
+
+    if (SOCKET_ERROR == getsockname(client, result->ai_addr, (int*)&result->ai_addrlen))
+        goto fail;
+
+    if (SOCKET_ERROR == connect(server, result->ai_addr, result->ai_addrlen))
+        goto fail;
+
+    if (SOCKET_ERROR == connect(client, addr_info->ai_addr, addr_info->ai_addrlen))
+        goto fail;
+
+    freeaddrinfo(result);
+    sock[0] = client;
+    sock[1] = server;
+    return 0;
+
+fail:
+    if (INVALID_SOCKET!=client)
+        closesocket(client);
+    if (INVALID_SOCKET!=server)
+        closesocket(server);
+    if (result)
+        freeaddrinfo(result);
+    return -1;
+}
+
+int qemu_socketpair(int family, int type, int protocol,int recv[2]){
+    const char* address;
+    struct addrinfo addr_info,*p_addrinfo;
+    int result = -1;
+
+    if (family == AF_UNIX)
+    {
+        family = AF_INET;
+    }
+
+    memset(&addr_info, 0, sizeof(addr_info));
+    addr_info.ai_family = family;
+    addr_info.ai_socktype = type;
+    addr_info.ai_protocol = protocol;
+    if (AF_INET6==family)
+        address = "0:0:0:0:0:0:0:1";
+    else
+        address = "127.0.0.1";
+
+    if (0 == getaddrinfo(address, "0", &addr_info, &p_addrinfo)){
+        if (SOCK_STREAM == type)
+            result = __stream_socketpair(p_addrinfo, recv);
+        else if(SOCK_DGRAM == type)
+            result = __dgram_socketpair(p_addrinfo, recv);
+        freeaddrinfo(p_addrinfo);
+    }
+    return result;
+}
+
+#else
+
+int qemu_socketpair(int family, int type, int protocol,int recv[2]) {
+    return socketpair(family, type, protocol, recv);
+}
+
+#endif
+
 #endif /* QCRYPTO_HAVE_TLS_TEST_SUPPORT */
diff --git a/tests/crypto-tls-x509-helpers.h b/tests/crypto-tls-x509-helpers.h
index 08efba4e19..75a902278c 100644
--- a/tests/crypto-tls-x509-helpers.h
+++ b/tests/crypto-tls-x509-helpers.h
@@ -24,8 +24,9 @@ 
 #include <gnutls/gnutls.h>
 #include <gnutls/x509.h>
 
-#if !(defined WIN32) && \
-    defined(CONFIG_TASN1)
+#include "qemu/osdep.h"
+
+#if defined(CONFIG_TASN1)
 # define QCRYPTO_HAVE_TLS_TEST_SUPPORT
 #endif
 
@@ -127,6 +128,10 @@  void test_tls_cleanup(const char *keyfile);
 
 extern const ASN1_ARRAY_TYPE pkix_asn1_tab[];
 
+int qemu_link(const char *exist_path1, const char *new_path2);
+
+int qemu_socketpair(int family, int type, int protocol,int recv[2]);
+
 #endif /* QCRYPTO_HAVE_TLS_TEST_SUPPORT */
 
 #endif
diff --git a/tests/test-crypto-tlscredsx509.c b/tests/test-crypto-tlscredsx509.c
index f487349c32..620fbde1ca 100644
--- a/tests/test-crypto-tlscredsx509.c
+++ b/tests/test-crypto-tlscredsx509.c
@@ -25,6 +25,9 @@ 
 #include "qapi/error.h"
 #include "qemu/module.h"
 
+#include <glib.h>
+#include <glib/gstdio.h>
+
 #ifdef QCRYPTO_HAVE_TLS_TEST_SUPPORT
 
 #define WORKDIR "tests/test-crypto-tlscredsx509-work/"
@@ -77,34 +80,34 @@  static void test_tls_creds(const void *opaque)
     QCryptoTLSCreds *creds;
 
 #define CERT_DIR "tests/test-crypto-tlscredsx509-certs/"
-    mkdir(CERT_DIR, 0700);
+    g_mkdir_with_parents(CERT_DIR, 0700);
 
-    unlink(CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
+    g_remove (CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
     if (data->isServer) {
-        unlink(CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_CERT);
-        unlink(CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_KEY);
+        g_remove (CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_CERT);
+        g_remove (CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_KEY);
     } else {
-        unlink(CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_CERT);
-        unlink(CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_KEY);
+        g_remove (CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_CERT);
+        g_remove (CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_KEY);
     }
 
-    if (access(data->cacrt, R_OK) == 0) {
-        g_assert(link(data->cacrt,
+    if (g_access(data->cacrt, R_OK) == 0) {
+        g_assert(qemu_link(data->cacrt,
                       CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT) == 0);
     }
     if (data->isServer) {
-        if (access(data->crt, R_OK) == 0) {
-            g_assert(link(data->crt,
+        if (g_access(data->crt, R_OK) == 0) {
+            g_assert(qemu_link(data->crt,
                           CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_CERT) == 0);
         }
-        g_assert(link(KEYFILE,
+        g_assert(qemu_link(KEYFILE,
                       CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_KEY) == 0);
     } else {
-        if (access(data->crt, R_OK) == 0) {
-            g_assert(link(data->crt,
+        if (g_access(data->crt, R_OK) == 0) {
+            g_assert(qemu_link(data->crt,
                           CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_CERT) == 0);
         }
-        g_assert(link(KEYFILE,
+        g_assert(qemu_link(KEYFILE,
                       CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_KEY) == 0);
     }
 
@@ -121,15 +124,15 @@  static void test_tls_creds(const void *opaque)
         g_assert(creds != NULL);
     }
 
-    unlink(CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
+    g_remove(CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
     if (data->isServer) {
-        unlink(CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_CERT);
-        unlink(CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_KEY);
+        g_remove(CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_CERT);
+        g_remove(CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_KEY);
     } else {
-        unlink(CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_CERT);
-        unlink(CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_KEY);
+        g_remove(CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_CERT);
+        g_remove(CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_KEY);
     }
-    rmdir(CERT_DIR);
+    g_rmdir(CERT_DIR);
     if (creds) {
         object_unparent(OBJECT(creds));
     }
@@ -143,7 +146,7 @@  int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
 
-    mkdir(WORKDIR, 0700);
+    g_mkdir_with_parents(WORKDIR, 0700);
 
     test_tls_init(KEYFILE);
 
@@ -699,7 +702,7 @@  int main(int argc, char **argv)
     test_tls_discard_cert(&cacertlevel2areq);
     test_tls_discard_cert(&servercertlevel3areq);
     test_tls_discard_cert(&clientcertlevel2breq);
-    unlink(WORKDIR "cacertchain-ctx.pem");
+    g_remove(WORKDIR "cacertchain-ctx.pem");
 
     test_tls_cleanup(KEYFILE);
     rmdir(WORKDIR);
diff --git a/tests/test-crypto-tlssession.c b/tests/test-crypto-tlssession.c
index 8b2453fa79..f726219593 100644
--- a/tests/test-crypto-tlssession.c
+++ b/tests/test-crypto-tlssession.c
@@ -28,9 +28,13 @@ 
 #include "qom/object_interfaces.h"
 #include "qapi/error.h"
 #include "qemu/module.h"
+#include "qemu/main-loop.h"
 #include "qemu/sockets.h"
 #include "authz/list.h"
 
+#include <glib.h>
+#include <glib/gstdio.h>
+
 #ifdef QCRYPTO_HAVE_TLS_TEST_SUPPORT
 
 #define WORKDIR "tests/test-crypto-tlssession-work/"
@@ -40,15 +44,16 @@ 
 static ssize_t testWrite(const char *buf, size_t len, void *opaque)
 {
     int *fd = opaque;
-
-    return write(*fd, buf, len);
+    int written = send(*fd, buf, len, 0);
+    return written;
 }
 
 static ssize_t testRead(char *buf, size_t len, void *opaque)
 {
     int *fd = opaque;
 
-    return read(*fd, buf, len);
+    int readed = recv(*fd, buf, len, 0);
+    return readed;
 }
 
 static QCryptoTLSCreds *test_tls_creds_psk_create(
@@ -84,7 +89,7 @@  static void test_crypto_tls_session_psk(void)
     int ret;
 
     /* We'll use this for our fake client-server connection */
-    ret = socketpair(AF_UNIX, SOCK_STREAM, 0, channel);
+    ret = qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, channel);
     g_assert(ret == 0);
 
     /*
@@ -238,7 +243,7 @@  static void test_crypto_tls_session_x509(const void *opaque)
     int ret;
 
     /* We'll use this for our fake client-server connection */
-    ret = socketpair(AF_UNIX, SOCK_STREAM, 0, channel);
+    ret = qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, channel);
     g_assert(ret == 0);
 
     /*
@@ -251,29 +256,29 @@  static void test_crypto_tls_session_x509(const void *opaque)
 
 #define CLIENT_CERT_DIR "tests/test-crypto-tlssession-client/"
 #define SERVER_CERT_DIR "tests/test-crypto-tlssession-server/"
-    mkdir(CLIENT_CERT_DIR, 0700);
-    mkdir(SERVER_CERT_DIR, 0700);
+    g_mkdir_with_parents(CLIENT_CERT_DIR, 0700);
+    g_mkdir_with_parents(SERVER_CERT_DIR, 0700);
 
-    unlink(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
-    unlink(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_CERT);
-    unlink(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_KEY);
+    g_remove(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
+    g_remove(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_CERT);
+    g_remove(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_KEY);
 
-    unlink(CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
-    unlink(CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_CERT);
-    unlink(CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_KEY);
+    g_remove(CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
+    g_remove(CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_CERT);
+    g_remove(CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_KEY);
 
-    g_assert(link(data->servercacrt,
+    g_assert(qemu_link(data->servercacrt,
                   SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT) == 0);
-    g_assert(link(data->servercrt,
+    g_assert(qemu_link(data->servercrt,
                   SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_CERT) == 0);
-    g_assert(link(KEYFILE,
+    g_assert(qemu_link(KEYFILE,
                   SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_KEY) == 0);
 
-    g_assert(link(data->clientcacrt,
+    g_assert(qemu_link(data->clientcacrt,
                   CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT) == 0);
-    g_assert(link(data->clientcrt,
+    g_assert(qemu_link(data->clientcrt,
                   CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_CERT) == 0);
-    g_assert(link(KEYFILE,
+    g_assert(qemu_link(KEYFILE,
                   CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_KEY) == 0);
 
     clientCreds = test_tls_creds_x509_create(
@@ -369,16 +374,16 @@  static void test_crypto_tls_session_x509(const void *opaque)
         g_assert(!data->expectClientFail);
     }
 
-    unlink(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
-    unlink(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_CERT);
-    unlink(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_KEY);
+    g_remove(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
+    g_remove(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_CERT);
+    g_remove(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_KEY);
 
-    unlink(CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
-    unlink(CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_CERT);
-    unlink(CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_KEY);
+    g_remove(CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
+    g_remove(CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_CERT);
+    g_remove(CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_KEY);
 
-    rmdir(CLIENT_CERT_DIR);
-    rmdir(SERVER_CERT_DIR);
+    g_rmdir(CLIENT_CERT_DIR);
+    g_rmdir(SERVER_CERT_DIR);
 
     object_unparent(OBJECT(serverCreds));
     object_unparent(OBJECT(clientCreds));
@@ -397,10 +402,13 @@  int main(int argc, char **argv)
     int ret;
 
     module_call_init(MODULE_INIT_QOM);
+    qemu_init_main_loop(&error_abort);
+    socket_init();
+
     g_test_init(&argc, &argv, NULL);
     g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
 
-    mkdir(WORKDIR, 0700);
+    g_mkdir_with_parents(WORKDIR, 0700);
 
     test_tls_init(KEYFILE);
     test_tls_psk_init(PSKFILE);
@@ -640,11 +648,11 @@  int main(int argc, char **argv)
     test_tls_discard_cert(&cacertlevel2areq);
     test_tls_discard_cert(&servercertlevel3areq);
     test_tls_discard_cert(&clientcertlevel2breq);
-    unlink(WORKDIR "cacertchain-sess.pem");
+    g_remove(WORKDIR "cacertchain-sess.pem");
 
     test_tls_psk_cleanup(PSKFILE);
     test_tls_cleanup(KEYFILE);
-    rmdir(WORKDIR);
+    g_rmdir(WORKDIR);
 
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test-io-channel-tls.c b/tests/test-io-channel-tls.c
index ad7554c534..e858716192 100644
--- a/tests/test-io-channel-tls.c
+++ b/tests/test-io-channel-tls.c
@@ -31,9 +31,13 @@ 
 #include "crypto/tlscredsx509.h"
 #include "qapi/error.h"
 #include "qemu/module.h"
+#include "qemu/main-loop.h"
 #include "authz/list.h"
 #include "qom/object_interfaces.h"
 
+#include <glib.h>
+#include <glib/gstdio.h>
+
 #ifdef QCRYPTO_HAVE_TLS_TEST_SUPPORT
 
 #define WORKDIR "tests/test-io-channel-tls-work/"
@@ -123,33 +127,33 @@  static void test_io_channel_tls(const void *opaque)
     GMainContext *mainloop;
 
     /* We'll use this for our fake client-server connection */
-    g_assert(socketpair(AF_UNIX, SOCK_STREAM, 0, channel) == 0);
+    g_assert(qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, channel) == 0);
 
 #define CLIENT_CERT_DIR "tests/test-io-channel-tls-client/"
 #define SERVER_CERT_DIR "tests/test-io-channel-tls-server/"
-    mkdir(CLIENT_CERT_DIR, 0700);
-    mkdir(SERVER_CERT_DIR, 0700);
+    g_mkdir(CLIENT_CERT_DIR, 0700);
+    g_mkdir(SERVER_CERT_DIR, 0700);
 
-    unlink(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
-    unlink(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_CERT);
-    unlink(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_KEY);
+    g_remove(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
+    g_remove(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_CERT);
+    g_remove(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_KEY);
 
-    unlink(CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
-    unlink(CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_CERT);
-    unlink(CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_KEY);
+    g_remove(CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
+    g_remove(CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_CERT);
+    g_remove(CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_KEY);
 
-    g_assert(link(data->servercacrt,
+    g_assert(qemu_link(data->servercacrt,
                   SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT) == 0);
-    g_assert(link(data->servercrt,
+    g_assert(qemu_link(data->servercrt,
                   SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_CERT) == 0);
-    g_assert(link(KEYFILE,
+    g_assert(qemu_link(KEYFILE,
                   SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_KEY) == 0);
 
-    g_assert(link(data->clientcacrt,
+    g_assert(qemu_link(data->clientcacrt,
                   CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT) == 0);
-    g_assert(link(data->clientcrt,
+    g_assert(qemu_link(data->clientcrt,
                   CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_CERT) == 0);
-    g_assert(link(KEYFILE,
+    g_assert(qemu_link(KEYFILE,
                   CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_KEY) == 0);
 
     clientCreds = test_tls_creds_create(
@@ -238,13 +242,13 @@  static void test_io_channel_tls(const void *opaque)
                                  QIO_CHANNEL(serverChanTLS));
     qio_channel_test_validate(test);
 
-    unlink(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
-    unlink(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_CERT);
-    unlink(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_KEY);
+    g_remove(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
+    g_remove(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_CERT);
+    g_remove(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_KEY);
 
-    unlink(CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
-    unlink(CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_CERT);
-    unlink(CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_KEY);
+    g_remove(CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
+    g_remove(CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_CERT);
+    g_remove(CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_KEY);
 
     rmdir(CLIENT_CERT_DIR);
     rmdir(SERVER_CERT_DIR);
@@ -272,10 +276,13 @@  int main(int argc, char **argv)
     g_assert(qcrypto_init(NULL) == 0);
 
     module_call_init(MODULE_INIT_QOM);
+    qemu_init_main_loop(&error_abort);
+    socket_init();
+
     g_test_init(&argc, &argv, NULL);
     g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
 
-    mkdir(WORKDIR, 0700);
+    g_mkdir(WORKDIR, 0700);
 
     test_tls_init(KEYFILE);