windows: add tests for uv_tcp_simultaneous_accepts
This commit is contained in:
parent
78f4b120a1
commit
9c6103a479
@ -321,6 +321,6 @@ int uv_tcp_keepalive(uv_tcp_t* handle, int enable, unsigned int delay) {
|
||||
}
|
||||
|
||||
|
||||
int uv_tcp_multiple_simultaneous_accepts(uv_tcp_t* handle, int enable) {
|
||||
int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1094,7 +1094,7 @@ int uv_tcp_duplicate_socket(uv_tcp_t* handle, int pid,
|
||||
}
|
||||
|
||||
|
||||
int uv_tcp_multiple_simultaneous_accepts(uv_tcp_t* handle, int enable) {
|
||||
int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable) {
|
||||
if (handle->flags & UV_HANDLE_CONNECTION) {
|
||||
uv__set_artificial_error(handle->loop, UV_EINVAL);
|
||||
return -1;
|
||||
|
||||
@ -230,3 +230,49 @@ TEST_IMPL(ipc_listen_before_write) {
|
||||
TEST_IMPL(ipc_listen_after_write) {
|
||||
return run_ipc_test("ipc_helper_listen_after_write");
|
||||
}
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
TEST_IMPL(listen_with_simultaneous_accepts) {
|
||||
uv_tcp_t server;
|
||||
int r;
|
||||
struct sockaddr_in addr = uv_ip4_addr("0.0.0.0", TEST_PORT);
|
||||
|
||||
r = uv_tcp_init(uv_default_loop(), &server);
|
||||
ASSERT(r == 0);
|
||||
|
||||
r = uv_tcp_bind(&server, addr);
|
||||
ASSERT(r == 0);
|
||||
|
||||
r = uv_tcp_simultaneous_accepts(&server, 1);
|
||||
ASSERT(r == 0);
|
||||
|
||||
r = uv_listen((uv_stream_t*)&server, SOMAXCONN, NULL);
|
||||
ASSERT(r == 0);
|
||||
ASSERT(server.reqs_pending == 32);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
TEST_IMPL(listen_no_simultaneous_accepts) {
|
||||
uv_tcp_t server;
|
||||
int r;
|
||||
struct sockaddr_in addr = uv_ip4_addr("0.0.0.0", TEST_PORT);
|
||||
|
||||
r = uv_tcp_init(uv_default_loop(), &server);
|
||||
ASSERT(r == 0);
|
||||
|
||||
r = uv_tcp_bind(&server, addr);
|
||||
ASSERT(r == 0);
|
||||
|
||||
r = uv_tcp_simultaneous_accepts(&server, 0);
|
||||
ASSERT(r == 0);
|
||||
|
||||
r = uv_listen((uv_stream_t*)&server, SOMAXCONN, NULL);
|
||||
ASSERT(r == 0);
|
||||
ASSERT(server.reqs_pending == 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@ -113,6 +113,8 @@ TEST_DECLARE (threadpool_queue_work_simple)
|
||||
TEST_DECLARE (spawn_detect_pipe_name_collisions_on_windows)
|
||||
TEST_DECLARE (argument_escaping)
|
||||
TEST_DECLARE (environment_creation)
|
||||
TEST_DECLARE (listen_with_simultaneous_accepts)
|
||||
TEST_DECLARE (listen_no_simultaneous_accepts)
|
||||
#endif
|
||||
HELPER_DECLARE (tcp4_echo_server)
|
||||
HELPER_DECLARE (tcp6_echo_server)
|
||||
@ -229,6 +231,8 @@ TASK_LIST_START
|
||||
TEST_ENTRY (spawn_detect_pipe_name_collisions_on_windows)
|
||||
TEST_ENTRY (argument_escaping)
|
||||
TEST_ENTRY (environment_creation)
|
||||
TEST_ENTRY (listen_with_simultaneous_accepts)
|
||||
TEST_ENTRY (listen_no_simultaneous_accepts)
|
||||
#endif
|
||||
|
||||
TEST_ENTRY (fs_file_noent)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user