[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v8 13/27] tests: Enable crypto tests under msys2/mingw
From: |
Thomas Huth |
Subject: |
Re: [PATCH v8 13/27] tests: Enable crypto tests under msys2/mingw |
Date: |
Mon, 14 Sep 2020 09:23:33 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 |
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 commit description.
Thanks,
Thomas
- Re: [PATCH v8 11/27] meson: Use -b to ignore CR vs. CR-LF issues on Windows, (continued)
- [PATCH v8 10/27] osdep: file locking functions are not available on Win32, Yonggang Luo, 2020/09/12
- [PATCH v8 09/27] tests: test-replication disable /replication/secondary/* on msys2/mingw., Yonggang Luo, 2020/09/12
- [PATCH v8 08/27] tests: Fixes test-replication.c on msys2/mingw., Yonggang Luo, 2020/09/12
- [PATCH v8 12/27] gcrypt: test_tls_psk_init should write binary file instead text file., Yonggang Luo, 2020/09/12
- [PATCH v8 13/27] tests: Enable crypto tests under msys2/mingw, Yonggang Luo, 2020/09/12
- Re: [PATCH v8 13/27] tests: Enable crypto tests under msys2/mingw,
Thomas Huth <=
- Re: [PATCH v8 13/27] tests: Enable crypto tests under msys2/mingw, Yonggang Luo, 2020/09/14
- Re: [PATCH v8 13/27] tests: Enable crypto tests under msys2/mingw, Thomas Huth, 2020/09/14
- Re: [PATCH v8 13/27] tests: Enable crypto tests under msys2/mingw, Yonggang Luo, 2020/09/14
- Re: [PATCH v8 13/27] tests: Enable crypto tests under msys2/mingw, Daniel P . Berrangé, 2020/09/14
- Re: [PATCH v8 13/27] tests: Enable crypto tests under msys2/mingw, Yonggang Luo, 2020/09/14
[PATCH v8 14/27] meson: remove empty else and duplicated gio deps, Yonggang Luo, 2020/09/12
[PATCH v8 15/27] vmstate: Fixes test-vmstate.c on msys2/mingw, Yonggang Luo, 2020/09/12
[PATCH v8 16/27] cirrus: Building freebsd in a single short, Yonggang Luo, 2020/09/12