зеркало из https://github.com/Azure/c-pal.git
changing async_socket open close signature (#338)
Co-authored-by: Jelani Brandon <jebrando@microsoft.com>
This commit is contained in:
Родитель
1d6d29a682
Коммит
b9bc7ab2fa
|
@ -74,11 +74,11 @@ typedef struct ASYNC_SOCKET_BUFFER_TAG
|
|||
uint32_t length;
|
||||
} ASYNC_SOCKET_BUFFER;
|
||||
|
||||
MOCKABLE_FUNCTION(, ASYNC_SOCKET_HANDLE, async_socket_create, EXECUTION_ENGINE_HANDLE, execution_engine, SOCKET_HANDLE, socket_handle);
|
||||
MOCKABLE_FUNCTION(, ASYNC_SOCKET_HANDLE, async_socket_create_with_transport, EXECUTION_ENGINE_HANDLE, execution_engine, SOCKET_HANDLE, socket_handle, ON_ASYNC_SOCKET_SEND, on_send, void*, on_send_context, ON_ASYNC_SOCKET_RECV, on_recv, void*, on_recv_context);
|
||||
MOCKABLE_FUNCTION(, ASYNC_SOCKET_HANDLE, async_socket_create, EXECUTION_ENGINE_HANDLE, execution_engine);
|
||||
MOCKABLE_FUNCTION(, ASYNC_SOCKET_HANDLE, async_socket_create_with_transport, EXECUTION_ENGINE_HANDLE, execution_engine, ON_ASYNC_SOCKET_SEND, on_send, void*, on_send_context, ON_ASYNC_SOCKET_RECV, on_recv, void*, on_recv_context);
|
||||
MOCKABLE_FUNCTION(, void, async_socket_destroy, ASYNC_SOCKET_HANDLE, async_socket);
|
||||
|
||||
MOCKABLE_FUNCTION(, int, async_socket_open_async, ASYNC_SOCKET_HANDLE, async_socket, ON_ASYNC_SOCKET_OPEN_COMPLETE, on_open_complete, void*, on_open_complete_context);
|
||||
MOCKABLE_FUNCTION(, int, async_socket_open_async, ASYNC_SOCKET_HANDLE, async_socket, SOCKET_HANDLE, socket_handle, ON_ASYNC_SOCKET_OPEN_COMPLETE, on_open_complete, void*, on_open_complete_context);
|
||||
MOCKABLE_FUNCTION(, void, async_socket_close, ASYNC_SOCKET_HANDLE, async_socket);
|
||||
MOCKABLE_FUNCTION(, ASYNC_SOCKET_SEND_SYNC_RESULT, async_socket_send_async, ASYNC_SOCKET_HANDLE, async_socket, const ASYNC_SOCKET_BUFFER*, payload, uint32_t, buffer_count, ON_ASYNC_SOCKET_SEND_COMPLETE, on_send_complete, void*, on_send_complete_context);
|
||||
MOCKABLE_FUNCTION(, int, async_socket_receive_async, ASYNC_SOCKET_HANDLE, async_socket, ASYNC_SOCKET_BUFFER*, payload, uint32_t, buffer_count, ON_ASYNC_SOCKET_RECEIVE_COMPLETE, on_receive_complete, void*, on_receive_complete_context);
|
||||
|
|
|
@ -120,8 +120,6 @@ MOCKABLE_FUNCTION(, ASYNC_SOCKET_HANDLE, async_socket_create_with_transport, EXE
|
|||
|
||||
**SRS_ASYNC_SOCKET_LINUX_11_002: [** `execution_engine` shall be allowed to be `NULL`. **]**
|
||||
|
||||
**SRS_ASYNC_SOCKET_LINUX_11_003: [** If `socket_handle` is `INVALID_SOCKET`, `async_socket_create_with_transport` shall fail and return `NULL`. **]**
|
||||
|
||||
**SRS_ASYNC_SOCKET_LINUX_04_002: [** If `on_send` is `NULL` , `async_socket_create_with_transport` shall fail and return `NULL`. **]**
|
||||
|
||||
**SRS_ASYNC_SOCKET_LINUX_04_003: [** If `on_recv` is `NULL` , `async_socket_create_with_transport` shall fail and return `NULL`. **]**
|
||||
|
@ -162,14 +160,14 @@ MOCKABLE_FUNCTION(, int, async_socket_open_async, ASYNC_SOCKET_HANDLE, async_soc
|
|||
|
||||
**SRS_ASYNC_SOCKET_LINUX_11_026: [** `on_open_complete_context` shall be allowed to be `NULL`. **]**
|
||||
|
||||
**SRS_ASYNC_SOCKET_LINUX_11_003: [** If `socket_handle` is `INVALID_SOCKET`, `async_socket_open_async` shall fail and return non-zero value. **]**
|
||||
|
||||
**SRS_ASYNC_SOCKET_LINUX_11_027: [** Otherwise, `async_socket_open_async` shall switch the state to `OPENING`. **]**
|
||||
|
||||
**SRS_ASYNC_SOCKET_LINUX_11_028: [** On success, `async_socket_open_async` shall return 0. **]**
|
||||
|
||||
**SRS_ASYNC_SOCKET_LINUX_11_029: [** If `async_socket` is already OPEN or OPENING, `async_socket_open_async` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_ASYNC_SOCKET_LINUX_11_030: [** If `async_socket` has already closed the underlying socket handle then `async_socket_open_async` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_ASYNC_SOCKET_LINUX_11_031: [** `async_socket_open_async` shall add the socket to the epoll system by calling `epoll_ctl` with `EPOLL_CTL_ADD`. **]**
|
||||
|
||||
**SRS_ASYNC_SOCKET_LINUX_11_032: [** `async_socket_open_async` shall set the state to OPEN. **]**
|
||||
|
|
|
@ -210,7 +210,7 @@ static void event_complete_callback(void* context, COMPLETION_PORT_EPOLL_ACTION
|
|||
// Codes_SRS_ASYNC_SOCKET_LINUX_04_008: [ event_complete_callback shall call the notify complete callback with an ABANDONED flag when the IO type is ASYNC_SOCKET_IO_TYPE_NOTIFY. ]
|
||||
io_context->on_notify_io_complete(io_context->callback_context, ASYNC_SOCKET_NOTIFY_IO_RESULT_ABANDONED);
|
||||
}
|
||||
|
||||
|
||||
// Codes_SRS_ASYNC_SOCKET_LINUX_11_084: [ Then event_complete_callback shall free the context memory. ]
|
||||
free(io_context);
|
||||
break;
|
||||
|
@ -404,23 +404,24 @@ static void internal_close(ASYNC_SOCKET_HANDLE async_socket)
|
|||
wake_by_address_single(&async_socket->state);
|
||||
}
|
||||
|
||||
ASYNC_SOCKET_HANDLE async_socket_create(EXECUTION_ENGINE_HANDLE execution_engine, SOCKET_HANDLE socket_handle)
|
||||
ASYNC_SOCKET_HANDLE async_socket_create(EXECUTION_ENGINE_HANDLE execution_engine)
|
||||
{
|
||||
// Codes_SRS_ASYNC_SOCKET_LINUX_04_001: [ async_socket_create shall delegate to async_socket_create_with_transport passing in callbacks for on_send and on_recv that implement socket read and write by calling send and recv respectively from system socket API. ]
|
||||
return async_socket_create_with_transport(execution_engine, socket_handle, on_socket_send, NULL, on_socket_recv, NULL);
|
||||
return async_socket_create_with_transport(execution_engine, on_socket_send, NULL, on_socket_recv, NULL);
|
||||
}
|
||||
|
||||
ASYNC_SOCKET_HANDLE async_socket_create_with_transport(EXECUTION_ENGINE_HANDLE execution_engine, SOCKET_HANDLE socket_handle, ON_ASYNC_SOCKET_SEND on_send, void* on_send_context, ON_ASYNC_SOCKET_RECV on_recv, void* on_recv_context)
|
||||
ASYNC_SOCKET_HANDLE async_socket_create_with_transport(EXECUTION_ENGINE_HANDLE execution_engine, ON_ASYNC_SOCKET_SEND on_send, void* on_send_context, ON_ASYNC_SOCKET_RECV on_recv, void* on_recv_context)
|
||||
{
|
||||
ASYNC_SOCKET_HANDLE result;
|
||||
// Codes_SRS_ASYNC_SOCKET_LINUX_11_002: [ execution_engine shall be allowed to be NULL. ]
|
||||
|
||||
// Codes_SRS_ASYNC_SOCKET_LINUX_11_003: [ If socket_handle is INVALID_SOCKET, async_socket_create_with_transport shall fail and return NULL. ]
|
||||
// Codes_SRS_ASYNC_SOCKET_LINUX_04_002: [ If on_send is NULL , async_socket_create_with_transport shall fail and return NULL. ]
|
||||
// Codes_SRS_ASYNC_SOCKET_LINUX_04_003: [ If on_recv is NULL , async_socket_create_with_transport shall fail and return NULL. ]
|
||||
if (socket_handle == INVALID_SOCKET || on_send == NULL || on_recv == NULL)
|
||||
if (
|
||||
on_send == NULL ||
|
||||
on_recv == NULL)
|
||||
{
|
||||
LogError("EXECUTION_ENGINE_HANDLE execution_engine:%p, SOCKET_HANDLE socket_handle:%" PRI_SOCKET ", ON_ASYNC_SOCKET_SEND on_send: %p, void* on_send_context: %p, ON_ASYNC_SOCKET_RECV on_recv: %p, void* on_recv_context: %p", execution_engine, socket_handle, on_send, on_send_context, on_recv, on_recv_context);
|
||||
LogError("EXECUTION_ENGINE_HANDLE execution_engine:%p, ON_ASYNC_SOCKET_SEND on_send: %p, void* on_send_context: %p, ON_ASYNC_SOCKET_RECV on_recv: %p, void* on_recv_context: %p", execution_engine, on_send, on_send_context, on_recv, on_recv_context);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -439,7 +440,6 @@ ASYNC_SOCKET_HANDLE async_socket_create_with_transport(EXECUTION_ENGINE_HANDLE e
|
|||
}
|
||||
else
|
||||
{
|
||||
result->socket_handle = socket_handle;
|
||||
result->on_send = on_send;
|
||||
result->on_send_context = on_send_context;
|
||||
result->on_recv = on_recv;
|
||||
|
@ -493,7 +493,7 @@ void async_socket_destroy(ASYNC_SOCKET_HANDLE async_socket)
|
|||
}
|
||||
}
|
||||
|
||||
int async_socket_open_async(ASYNC_SOCKET_HANDLE async_socket, ON_ASYNC_SOCKET_OPEN_COMPLETE on_open_complete, void* on_open_complete_context)
|
||||
int async_socket_open_async(ASYNC_SOCKET_HANDLE async_socket, SOCKET_HANDLE socket_handle, ON_ASYNC_SOCKET_OPEN_COMPLETE on_open_complete, void* on_open_complete_context)
|
||||
{
|
||||
int result;
|
||||
// Codes_SRS_ASYNC_SOCKET_LINUX_11_026: [ on_open_complete_context shall be allowed to be NULL. ]
|
||||
|
@ -501,7 +501,10 @@ int async_socket_open_async(ASYNC_SOCKET_HANDLE async_socket, ON_ASYNC_SOCKET_OP
|
|||
// Codes_SRS_ASYNC_SOCKET_LINUX_11_024: [ If async_socket is NULL, async_socket_open_async shall fail and return a non-zero value. ]
|
||||
async_socket == NULL ||
|
||||
// Codes_SRS_ASYNC_SOCKET_LINUX_11_025: [ If on_open_complete is NULL, async_socket_open_async shall fail and return a non-zero value. ]
|
||||
on_open_complete == NULL)
|
||||
on_open_complete == NULL ||
|
||||
// Codes_SRS_ASYNC_SOCKET_LINUX_11_003: [ If socket_handle is INVALID_SOCKET, async_socket_open_async shall fail and return a non-zero value. ]
|
||||
socket_handle == INVALID_SOCKET
|
||||
)
|
||||
{
|
||||
LogError("ASYNC_SOCKET_HANDLE async_socket=%p, ON_ASYNC_SOCKET_OPEN_COMPLETE on_open_complete=%p, void* on_open_complete_context=%p",
|
||||
async_socket, on_open_complete, on_open_complete_context);
|
||||
|
@ -514,30 +517,24 @@ int async_socket_open_async(ASYNC_SOCKET_HANDLE async_socket, ON_ASYNC_SOCKET_OP
|
|||
// Codes_SRS_ASYNC_SOCKET_LINUX_11_029: [ If async_socket is already OPEN or OPENING, async_socket_open_async shall fail and return a non-zero value. ]
|
||||
if (current_state != ASYNC_SOCKET_LINUX_STATE_CLOSED)
|
||||
{
|
||||
// Codes_SRS_ASYNC_SOCKET_LINUX_11_034: [ If any error occurs, async_socket_open_async shall fail and return a non-zero value. ]
|
||||
LogError("Open called in state %" PRI_MU_ENUM "", MU_ENUM_VALUE(ASYNC_SOCKET_LINUX_STATE, current_state));
|
||||
result = MU_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Codes_SRS_ASYNC_SOCKET_LINUX_11_030: [ If async_socket has already closed the underlying socket handle then async_socket_open_async shall fail and return a non-zero value. ]
|
||||
if (async_socket->socket_handle == INVALID_SOCKET)
|
||||
{
|
||||
// Codes_SRS_ASYNC_SOCKET_LINUX_11_034: [ If any error occurs, async_socket_open_async shall fail and return a non-zero value. ]
|
||||
LogError("Open called after socket was closed");
|
||||
result = MU_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Codes_SRS_ASYNC_SOCKET_LINUX_11_031: [ async_socket_open_async shall add the socket to the epoll system by calling epoll_ctl with EPOLL_CTL_ADD. ]
|
||||
// Codes_SRS_ASYNC_SOCKET_LINUX_11_032: [ async_socket_open_async shall set the state to OPEN. ]
|
||||
(void)interlocked_exchange(&async_socket->state, ASYNC_SOCKET_LINUX_STATE_OPEN);
|
||||
// Codes_SRS_ASYNC_SOCKET_LINUX_11_033: [ On success async_socket_open_async shall call on_open_complete_context with ASYNC_SOCKET_OPEN_OK. ]
|
||||
on_open_complete(on_open_complete_context, ASYNC_SOCKET_OPEN_OK);
|
||||
async_socket->socket_handle = socket_handle;
|
||||
|
||||
// Codes_SRS_ASYNC_SOCKET_LINUX_11_031: [ async_socket_open_async shall add the socket to the epoll system by calling epoll_ctl with EPOLL_CTL_ADD. ]
|
||||
// Codes_SRS_ASYNC_SOCKET_LINUX_11_032: [ async_socket_open_async shall set the state to OPEN. ]
|
||||
(void)interlocked_exchange(&async_socket->state, ASYNC_SOCKET_LINUX_STATE_OPEN);
|
||||
// Codes_SRS_ASYNC_SOCKET_LINUX_11_033: [ On success async_socket_open_async shall call on_open_complete_context with ASYNC_SOCKET_OPEN_OK. ]
|
||||
on_open_complete(on_open_complete_context, ASYNC_SOCKET_OPEN_OK);
|
||||
|
||||
// Codes_SRS_ASYNC_SOCKET_LINUX_11_028: [ On success, async_socket_open_async shall return 0. ]
|
||||
result = 0;
|
||||
goto all_ok;
|
||||
|
||||
// Codes_SRS_ASYNC_SOCKET_LINUX_11_028: [ On success, async_socket_open_async shall return 0. ]
|
||||
result = 0;
|
||||
goto all_ok;
|
||||
}
|
||||
(void)interlocked_exchange(&async_socket->state, ASYNC_SOCKET_LINUX_STATE_CLOSED);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -161,11 +161,11 @@ static void wait_for_value(volatile_atomic int32_t* counter, int32_t target_valu
|
|||
}
|
||||
}
|
||||
|
||||
static void open_async_handle(ASYNC_SOCKET_HANDLE handle)
|
||||
static void open_async_handle(ASYNC_SOCKET_HANDLE handle, SOCKET_HANDLE socket)
|
||||
{
|
||||
volatile_atomic int32_t counter = 0;
|
||||
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(handle, on_open_complete, (void*)&counter), "Failure opening async socket");
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(handle, socket, on_open_complete, (void*)&counter), "Failure opening async socket");
|
||||
|
||||
wait_for_value(&counter, 1);
|
||||
}
|
||||
|
@ -221,14 +221,14 @@ TEST_FUNCTION(connect_no_send_succeeds)
|
|||
setup_test_socket(g_port_num, &client_socket, &listen_socket, &accept_socket);
|
||||
|
||||
// create the async socket object
|
||||
ASYNC_SOCKET_HANDLE server_async_socket = async_socket_create(execution_engine, accept_socket);
|
||||
ASYNC_SOCKET_HANDLE server_async_socket = async_socket_create(execution_engine);
|
||||
ASSERT_IS_NOT_NULL(server_async_socket);
|
||||
ASYNC_SOCKET_HANDLE client_async_socket = async_socket_create(execution_engine, client_socket);
|
||||
ASYNC_SOCKET_HANDLE client_async_socket = async_socket_create(execution_engine);
|
||||
ASSERT_IS_NOT_NULL(client_async_socket);
|
||||
|
||||
// wait for open to complete
|
||||
open_async_handle(server_async_socket);
|
||||
open_async_handle(client_async_socket);
|
||||
open_async_handle(server_async_socket, accept_socket);
|
||||
open_async_handle(client_async_socket, client_socket);
|
||||
|
||||
uint8_t receive_buffer[2];
|
||||
ASYNC_SOCKET_BUFFER receive_payload_buffers[1];
|
||||
|
@ -262,14 +262,14 @@ TEST_FUNCTION(send_and_receive_1_byte_succeeds)
|
|||
setup_test_socket(g_port_num, &client_socket, &listen_socket, &accept_socket);
|
||||
|
||||
// create the async socket object
|
||||
ASYNC_SOCKET_HANDLE server_async_socket = async_socket_create(execution_engine, accept_socket);
|
||||
ASYNC_SOCKET_HANDLE server_async_socket = async_socket_create(execution_engine);
|
||||
ASSERT_IS_NOT_NULL(server_async_socket);
|
||||
ASYNC_SOCKET_HANDLE client_async_socket = async_socket_create(execution_engine, client_socket);
|
||||
ASYNC_SOCKET_HANDLE client_async_socket = async_socket_create(execution_engine);
|
||||
ASSERT_IS_NOT_NULL(client_async_socket);
|
||||
|
||||
// wait for open to complete
|
||||
open_async_handle(server_async_socket);
|
||||
open_async_handle(client_async_socket);
|
||||
open_async_handle(server_async_socket, accept_socket);
|
||||
open_async_handle(client_async_socket, client_socket);
|
||||
|
||||
uint8_t data_payload[] = { 0x42, 0x43 };
|
||||
uint8_t receive_buffer[2];
|
||||
|
@ -320,14 +320,14 @@ TEST_FUNCTION(receive_and_send_2_buffers_succeeds)
|
|||
setup_test_socket(g_port_num, &client_socket, &listen_socket, &accept_socket);
|
||||
|
||||
// create the async socket object
|
||||
ASYNC_SOCKET_HANDLE server_async_socket = async_socket_create(execution_engine, accept_socket);
|
||||
ASYNC_SOCKET_HANDLE server_async_socket = async_socket_create(execution_engine);
|
||||
ASSERT_IS_NOT_NULL(server_async_socket);
|
||||
ASYNC_SOCKET_HANDLE client_async_socket = async_socket_create(execution_engine, client_socket);
|
||||
ASYNC_SOCKET_HANDLE client_async_socket = async_socket_create(execution_engine);
|
||||
ASSERT_IS_NOT_NULL(client_async_socket);
|
||||
|
||||
// wait for open to complete
|
||||
open_async_handle(server_async_socket);
|
||||
open_async_handle(client_async_socket);
|
||||
open_async_handle(server_async_socket, accept_socket);
|
||||
open_async_handle(client_async_socket, client_socket);
|
||||
|
||||
uint8_t data_payload_1[] = { 0x42, 0x43 };
|
||||
uint8_t data_payload_2[] = { 0x02 };
|
||||
|
@ -383,11 +383,11 @@ TEST_FUNCTION(when_server_socket_is_closed_receive_errors_on_client_side)
|
|||
setup_test_socket(g_port_num, &client_socket, &listen_socket, &accept_socket);
|
||||
|
||||
// create the async socket object
|
||||
ASYNC_SOCKET_HANDLE client_async_socket = async_socket_create(execution_engine, client_socket);
|
||||
ASYNC_SOCKET_HANDLE client_async_socket = async_socket_create(execution_engine);
|
||||
ASSERT_IS_NOT_NULL(client_async_socket);
|
||||
|
||||
// open and wait for open to complete
|
||||
open_async_handle(client_async_socket);
|
||||
open_async_handle(client_async_socket, client_socket);
|
||||
|
||||
uint8_t receive_buffer_1[1];
|
||||
ASYNC_SOCKET_BUFFER receive_payload_buffers[1];
|
||||
|
@ -428,14 +428,14 @@ TEST_FUNCTION(multiple_sends_and_receives_succeeds)
|
|||
setup_test_socket(g_port_num, &client_socket, &listen_socket, &accept_socket);
|
||||
|
||||
// create the async socket object
|
||||
ASYNC_SOCKET_HANDLE server_async_socket = async_socket_create(execution_engine, accept_socket);
|
||||
ASYNC_SOCKET_HANDLE server_async_socket = async_socket_create(execution_engine);
|
||||
ASSERT_IS_NOT_NULL(server_async_socket);
|
||||
ASYNC_SOCKET_HANDLE client_async_socket = async_socket_create(execution_engine, client_socket);
|
||||
ASYNC_SOCKET_HANDLE client_async_socket = async_socket_create(execution_engine);
|
||||
ASSERT_IS_NOT_NULL(client_async_socket);
|
||||
|
||||
// wait for open to complete
|
||||
open_async_handle(server_async_socket);
|
||||
open_async_handle(client_async_socket);
|
||||
open_async_handle(server_async_socket, accept_socket);
|
||||
open_async_handle(client_async_socket, client_socket);
|
||||
|
||||
uint8_t data_payload[] = { 0x42, 0x43, 0x44, 0x45 };
|
||||
uint8_t receive_buffer[4];
|
||||
|
@ -501,12 +501,12 @@ TEST_FUNCTION(MU_C3(scheduling_, N_WORK_ITEMS, _sockets_items))
|
|||
setup_test_socket(g_port_num, &client_socket, &listen_socket, &accept_socket);
|
||||
|
||||
// create the async socket object
|
||||
ASSERT_IS_NOT_NULL(server_async_socket[index] = async_socket_create(execution_engine, accept_socket));
|
||||
ASSERT_IS_NOT_NULL(client_async_socket[index] = async_socket_create(execution_engine, client_socket));
|
||||
ASSERT_IS_NOT_NULL(server_async_socket[index] = async_socket_create(execution_engine));
|
||||
ASSERT_IS_NOT_NULL(client_async_socket[index] = async_socket_create(execution_engine));
|
||||
|
||||
// wait for open to complete
|
||||
open_async_handle(server_async_socket[index]);
|
||||
open_async_handle(client_async_socket[index]);
|
||||
open_async_handle(server_async_socket[index], accept_socket);
|
||||
open_async_handle(client_async_socket[index], client_socket);
|
||||
}
|
||||
|
||||
uint8_t data_payload[] = { 0x42, 0x43, 0x44, 0x45 };
|
||||
|
|
|
@ -236,7 +236,7 @@ TEST_FUNCTION(async_socket_create_succeeds)
|
|||
mock_async_socket_create_with_transport_setup();
|
||||
|
||||
// act
|
||||
async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
async_socket = async_socket_create(test_execution_engine);
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
|
@ -257,7 +257,7 @@ TEST_FUNCTION(async_socket_create_with_transport_with_NULL_execution_engine_succ
|
|||
mock_async_socket_create_with_transport_setup();
|
||||
|
||||
// act
|
||||
async_socket = async_socket_create_with_transport(NULL, test_socket, mocked_on_send, test_send_ctx, mocked_on_recv, test_recv_ctx);
|
||||
async_socket = async_socket_create_with_transport(NULL, mocked_on_send, test_send_ctx, mocked_on_recv, test_recv_ctx);
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
|
@ -267,20 +267,6 @@ TEST_FUNCTION(async_socket_create_with_transport_with_NULL_execution_engine_succ
|
|||
async_socket_destroy(async_socket);
|
||||
}
|
||||
|
||||
// Tests_SRS_ASYNC_SOCKET_LINUX_11_003: [ If socket_handle is INVALID_SOCKET, async_socket_create_with_transport shall fail and return NULL. ]
|
||||
TEST_FUNCTION(async_socket_create_with_transport_with_INVALID_SOCKET_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket;
|
||||
|
||||
// act
|
||||
async_socket = async_socket_create_with_transport(test_execution_engine, INVALID_SOCKET, mocked_on_send, test_send_ctx, mocked_on_recv, test_recv_ctx);
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
ASSERT_IS_NULL(async_socket);
|
||||
}
|
||||
|
||||
// Tests_SRS_ASYNC_SOCKET_LINUX_04_002: [ If on_send is NULL , async_socket_create_with_transport shall fail and return NULL. ]
|
||||
TEST_FUNCTION(async_socket_create_with_transport_with_NULL_on_send_fails)
|
||||
{
|
||||
|
@ -288,7 +274,7 @@ TEST_FUNCTION(async_socket_create_with_transport_with_NULL_on_send_fails)
|
|||
ASYNC_SOCKET_HANDLE async_socket;
|
||||
|
||||
// act
|
||||
async_socket = async_socket_create_with_transport(test_execution_engine, test_socket, NULL, NULL, mocked_on_recv, test_recv_ctx);
|
||||
async_socket = async_socket_create_with_transport(test_execution_engine, NULL, NULL, mocked_on_recv, test_recv_ctx);
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
|
@ -302,7 +288,7 @@ TEST_FUNCTION(async_socket_create_with_transport_with_NULL_on_recv_fails)
|
|||
ASYNC_SOCKET_HANDLE async_socket;
|
||||
|
||||
// act
|
||||
async_socket = async_socket_create_with_transport(test_execution_engine, test_socket, mocked_on_send, test_send_ctx, NULL, NULL);
|
||||
async_socket = async_socket_create_with_transport(test_execution_engine, mocked_on_send, test_send_ctx, NULL, NULL);
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
|
@ -319,7 +305,7 @@ TEST_FUNCTION(async_socket_create_with_transport_succeeds)
|
|||
mock_async_socket_create_with_transport_setup();
|
||||
|
||||
// act
|
||||
async_socket = async_socket_create_with_transport(test_execution_engine, test_socket, mocked_on_send, test_send_ctx, mocked_on_recv, test_recv_ctx);
|
||||
async_socket = async_socket_create_with_transport(test_execution_engine, mocked_on_send, test_send_ctx, mocked_on_recv, test_recv_ctx);
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
|
@ -347,7 +333,7 @@ TEST_FUNCTION(async_socket_create_with_transport_fails)
|
|||
umock_c_negative_tests_fail_call(index);
|
||||
|
||||
// act
|
||||
async_socket = async_socket_create_with_transport(test_execution_engine, test_socket, mocked_on_send, test_send_ctx, mocked_on_recv, test_recv_ctx);
|
||||
async_socket = async_socket_create_with_transport(test_execution_engine, mocked_on_send, test_send_ctx, mocked_on_recv, test_recv_ctx);
|
||||
|
||||
// assert
|
||||
ASSERT_IS_NULL(async_socket, "On failed call %zu", index);
|
||||
|
@ -375,7 +361,7 @@ TEST_FUNCTION(async_socket_destroy_with_NULL_returns)
|
|||
TEST_FUNCTION(async_socket_destroy_frees_resources)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -396,9 +382,9 @@ TEST_FUNCTION(async_socket_destroy_frees_resources)
|
|||
TEST_FUNCTION(async_socket_destroy_closes_first_if_open)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// close first
|
||||
|
@ -423,25 +409,44 @@ TEST_FUNCTION(async_socket_open_async_with_NULL_async_socket_fails)
|
|||
int result;
|
||||
|
||||
// act
|
||||
result = async_socket_open_async(NULL, test_on_open_complete, test_callback_ctx);
|
||||
result = async_socket_open_async(NULL, test_socket, test_on_open_complete, test_callback_ctx);
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
ASSERT_ARE_NOT_EQUAL(int, 0, result);
|
||||
}
|
||||
|
||||
// Tests_SRS_ASYNC_SOCKET_LINUX_11_003: [ If socket_handle is INVALID_SOCKET, async_socket_open_async shall fail and return NULL. ]
|
||||
TEST_FUNCTION(async_socket_open_async_with_INVALID_SOCKET_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// act
|
||||
int result = async_socket_open_async(async_socket, INVALID_SOCKET, test_on_open_complete, test_callback_ctx);
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
ASSERT_ARE_NOT_EQUAL(int, 0, result);
|
||||
|
||||
// cleanup
|
||||
async_socket_destroy(async_socket);
|
||||
}
|
||||
|
||||
// Tests_SRS_ASYNC_SOCKET_LINUX_11_025: [ If on_open_complete is NULL, async_socket_open_async shall fail and return a non-zero value. ]
|
||||
TEST_FUNCTION(async_socket_open_async_with_NULL_on_open_complete_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
|
||||
int result;
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// act
|
||||
result = async_socket_open_async(async_socket, NULL, test_callback_ctx);
|
||||
result = async_socket_open_async(async_socket, test_socket, NULL, test_callback_ctx);
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
|
@ -459,7 +464,7 @@ TEST_FUNCTION(async_socket_open_async_with_NULL_on_open_complete_fails)
|
|||
TEST_FUNCTION(async_socket_open_async_succeeds)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -468,7 +473,7 @@ TEST_FUNCTION(async_socket_open_async_succeeds)
|
|||
STRICT_EXPECTED_CALL(test_on_open_complete(test_callback_ctx, ASYNC_SOCKET_OPEN_OK));
|
||||
|
||||
// act
|
||||
int result = async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx);
|
||||
int result = async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx);
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
|
@ -483,7 +488,7 @@ TEST_FUNCTION(async_socket_open_async_succeeds)
|
|||
TEST_FUNCTION(async_socket_open_async_succeeds_with_NULL_context)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
int result;
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -493,7 +498,7 @@ TEST_FUNCTION(async_socket_open_async_succeeds_with_NULL_context)
|
|||
STRICT_EXPECTED_CALL(test_on_open_complete(NULL, ASYNC_SOCKET_OPEN_OK));
|
||||
|
||||
// act
|
||||
result = async_socket_open_async(async_socket, test_on_open_complete, NULL);
|
||||
result = async_socket_open_async(async_socket, test_socket, test_on_open_complete, NULL);
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
|
@ -508,7 +513,7 @@ TEST_FUNCTION(async_socket_open_async_succeeds_with_NULL_context)
|
|||
TEST_FUNCTION(when_underlying_calls_fail_async_socket_open_async_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
int result;
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -529,7 +534,7 @@ TEST_FUNCTION(when_underlying_calls_fail_async_socket_open_async_fails)
|
|||
umock_c_negative_tests_fail_call(index);
|
||||
|
||||
// act
|
||||
result = async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx);
|
||||
result = async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx);
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_NOT_EQUAL(int, 0, result, "On failed call %zu", index);
|
||||
|
@ -544,41 +549,16 @@ TEST_FUNCTION(when_underlying_calls_fail_async_socket_open_async_fails)
|
|||
TEST_FUNCTION(async_socket_open_async_after_async_socket_open_async_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
int result;
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(interlocked_compare_exchange(IGNORED_ARG, IGNORED_ARG, IGNORED_ARG));
|
||||
|
||||
// act
|
||||
result = async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx);
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
ASSERT_ARE_NOT_EQUAL(int, 0, result);
|
||||
|
||||
// cleanup
|
||||
async_socket_destroy(async_socket);
|
||||
}
|
||||
|
||||
// Tests_SRS_ASYNC_SOCKET_LINUX_11_030: [ If async_socket has already closed the underlying socket handle then async_socket_open_async shall fail and return a non-zero value. ]
|
||||
TEST_FUNCTION(async_socket_open_async_after_close_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
async_socket_close(async_socket);
|
||||
int result;
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(interlocked_compare_exchange(IGNORED_ARG, IGNORED_ARG, IGNORED_ARG));
|
||||
STRICT_EXPECTED_CALL(interlocked_exchange(IGNORED_ARG, IGNORED_ARG));
|
||||
|
||||
// act
|
||||
result = async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx);
|
||||
result = async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx);
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
|
@ -609,9 +589,9 @@ TEST_FUNCTION(async_socket_close_with_NULL_returns)
|
|||
TEST_FUNCTION(async_socket_close_reverses_the_actions_from_open)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(interlocked_compare_exchange(IGNORED_ARG, IGNORED_ARG, IGNORED_ARG));
|
||||
|
@ -631,7 +611,7 @@ TEST_FUNCTION(async_socket_close_reverses_the_actions_from_open)
|
|||
TEST_FUNCTION(async_socket_close_when_not_open_returns)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -651,9 +631,9 @@ TEST_FUNCTION(async_socket_close_when_not_open_returns)
|
|||
TEST_FUNCTION(async_socket_close_after_close_returns)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
async_socket_close(async_socket);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -673,9 +653,9 @@ TEST_FUNCTION(async_socket_close_after_close_returns)
|
|||
TEST_FUNCTION(async_socket_close_after_open_and_recv)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
payload_buffers[0].buffer = payload_bytes;
|
||||
|
@ -726,9 +706,9 @@ TEST_FUNCTION(async_socket_send_async_with_NULL_async_socket_fails)
|
|||
TEST_FUNCTION(async_socket_send_async_with_NULL_payload_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -748,9 +728,9 @@ TEST_FUNCTION(async_socket_send_async_with_NULL_payload_fails)
|
|||
TEST_FUNCTION(async_socket_send_async_with_0_payload_count_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -774,9 +754,9 @@ TEST_FUNCTION(async_socket_send_async_with_0_payload_count_fails)
|
|||
TEST_FUNCTION(async_socket_send_async_with_first_out_of_2_buffers_having_buffer_NULL_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
|
@ -803,9 +783,9 @@ TEST_FUNCTION(async_socket_send_async_with_first_out_of_2_buffers_having_buffer_
|
|||
TEST_FUNCTION(async_socket_send_async_with_second_out_of_2_buffers_having_buffer_NULL_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
|
@ -832,9 +812,9 @@ TEST_FUNCTION(async_socket_send_async_with_second_out_of_2_buffers_having_buffer
|
|||
TEST_FUNCTION(async_socket_send_async_with_first_out_of_2_buffers_having_length_0_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[2];
|
||||
|
@ -860,9 +840,9 @@ TEST_FUNCTION(async_socket_send_async_with_first_out_of_2_buffers_having_length_
|
|||
TEST_FUNCTION(async_socket_send_async_with_second_out_of_2_buffers_having_length_0_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[2];
|
||||
|
@ -888,9 +868,9 @@ TEST_FUNCTION(async_socket_send_async_with_second_out_of_2_buffers_having_length
|
|||
TEST_FUNCTION(async_socket_send_async_with_UINT32_MAX_buffers_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[2];
|
||||
|
@ -917,9 +897,9 @@ TEST_FUNCTION(async_socket_send_async_with_UINT32_MAX_buffers_fails)
|
|||
TEST_FUNCTION(async_socket_send_async_with_on_send_complete_NULL_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -942,7 +922,7 @@ TEST_FUNCTION(async_socket_send_async_with_on_send_complete_NULL_fails)
|
|||
TEST_FUNCTION(async_socket_send_async_when_not_open_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
|
@ -971,14 +951,14 @@ TEST_FUNCTION(async_socket_send_async_when_not_open_fails)
|
|||
TEST_FUNCTION(async_socket_send_async_after_close_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
payload_buffers[0].buffer = payload_bytes;
|
||||
payload_buffers[0].length = sizeof(payload_bytes);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
async_socket_close(async_socket);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -1007,9 +987,9 @@ TEST_FUNCTION(async_socket_send_async_after_close_fails)
|
|||
TEST_FUNCTION(async_socket_send_async_succeeds)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1043,9 +1023,9 @@ TEST_FUNCTION(async_socket_send_async_succeeds)
|
|||
TEST_FUNCTION(async_socket_send_async_multiple_sends_succeeds)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes[] = { 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x50 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1082,9 +1062,9 @@ TEST_FUNCTION(async_socket_send_async_multiple_sends_succeeds)
|
|||
TEST_FUNCTION(async_socket_send_async_multiple_sends_WOULDBLOCK_succeeds)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes[] = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x50 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1123,9 +1103,9 @@ TEST_FUNCTION(async_socket_send_async_multiple_sends_WOULDBLOCK_succeeds)
|
|||
TEST_FUNCTION(async_socket_send_async_with_NULL_on_send_complete_context_succeeds)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1157,9 +1137,9 @@ TEST_FUNCTION(async_socket_send_async_with_NULL_on_send_complete_context_succeed
|
|||
TEST_FUNCTION(when_underlying_calls_fail_async_socket_send_async_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1193,9 +1173,9 @@ TEST_FUNCTION(when_underlying_calls_fail_async_socket_send_async_fails)
|
|||
TEST_FUNCTION(when_errno_for_send_returns_EWOULDBLOCK_it_uses_completion_port_treated_as_successfull)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
|
@ -1231,9 +1211,9 @@ TEST_FUNCTION(when_errno_for_send_returns_EWOULDBLOCK_it_uses_completion_port_tr
|
|||
TEST_FUNCTION(when_errno_for_send_returns_ECONNRESET_async_socket_send_async_returns_ABANDONED)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1265,9 +1245,9 @@ TEST_FUNCTION(when_errno_for_send_returns_ECONNRESET_async_socket_send_async_ret
|
|||
TEST_FUNCTION(when_errno_for_send_returns_error_async_socket_send_async_returns_ERROR)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1299,9 +1279,9 @@ TEST_FUNCTION(when_errno_for_send_returns_error_async_socket_send_async_returns_
|
|||
TEST_FUNCTION(async_socket_send_async_with_sum_of_buffer_lengths_exceeding_UINT32_MAX_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
|
@ -1347,9 +1327,9 @@ TEST_FUNCTION(async_socket_receive_async_with_NULL_async_socket_fails)
|
|||
TEST_FUNCTION(async_socket_receive_async_with_NULL_payload_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// act
|
||||
|
@ -1367,9 +1347,9 @@ TEST_FUNCTION(async_socket_receive_async_with_NULL_payload_fails)
|
|||
TEST_FUNCTION(async_socket_receive_async_with_0_payload_count_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
uint8_t payload_bytes[1];
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
payload_buffers[0].buffer = payload_bytes;
|
||||
|
@ -1391,9 +1371,9 @@ TEST_FUNCTION(async_socket_receive_async_with_0_payload_count_fails)
|
|||
TEST_FUNCTION(async_socket_receive_async_with_first_out_of_2_buffers_having_buffer_NULL_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes_1[1];
|
||||
uint8_t payload_bytes_2[1];
|
||||
|
@ -1419,9 +1399,9 @@ TEST_FUNCTION(async_socket_receive_async_with_first_out_of_2_buffers_having_buff
|
|||
TEST_FUNCTION(async_socket_receive_async_with_second_out_of_2_buffers_having_buffer_NULL_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes_1[1];
|
||||
uint8_t payload_bytes_2[1];
|
||||
|
@ -1447,9 +1427,9 @@ TEST_FUNCTION(async_socket_receive_async_with_second_out_of_2_buffers_having_buf
|
|||
TEST_FUNCTION(async_socket_receive_async_with_first_out_of_2_buffers_having_length_0_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes_1[1];
|
||||
uint8_t payload_bytes_2[1];
|
||||
|
@ -1475,9 +1455,9 @@ TEST_FUNCTION(async_socket_receive_async_with_first_out_of_2_buffers_having_leng
|
|||
TEST_FUNCTION(async_socket_receive_async_with_second_out_of_2_buffers_having_length_0_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes_1[1];
|
||||
uint8_t payload_bytes_2[1];
|
||||
|
@ -1503,9 +1483,9 @@ TEST_FUNCTION(async_socket_receive_async_with_second_out_of_2_buffers_having_len
|
|||
TEST_FUNCTION(async_socket_receive_async_with_sum_of_buffer_lengths_exceeding_UINT32_MAX_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[2];
|
||||
|
@ -1530,9 +1510,9 @@ TEST_FUNCTION(async_socket_receive_async_with_sum_of_buffer_lengths_exceeding_UI
|
|||
TEST_FUNCTION(async_socket_receive_async_with_on_recv_complete_NULL_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1555,7 +1535,7 @@ TEST_FUNCTION(async_socket_receive_async_with_on_recv_complete_NULL_fails)
|
|||
TEST_FUNCTION(async_socket_receive_async_when_not_open_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
|
@ -1585,9 +1565,9 @@ TEST_FUNCTION(async_socket_receive_async_when_not_open_fails)
|
|||
TEST_FUNCTION(async_socket_receive_async_after_close_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
(void)async_socket_close(async_socket);
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
|
@ -1619,9 +1599,9 @@ TEST_FUNCTION(async_socket_receive_async_after_close_fails)
|
|||
TEST_FUNCTION(async_socket_receive_async_succeeds)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1647,9 +1627,9 @@ TEST_FUNCTION(async_socket_receive_async_succeeds)
|
|||
TEST_FUNCTION(async_socket_receive_async_with_NULL_on_recv_complete_context_succeeds)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1675,9 +1655,9 @@ TEST_FUNCTION(async_socket_receive_async_with_NULL_on_recv_complete_context_succ
|
|||
TEST_FUNCTION(when_underlying_calls_fail_async_socket_receive_async_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1715,9 +1695,9 @@ TEST_FUNCTION(when_underlying_calls_fail_async_socket_receive_async_fails)
|
|||
TEST_FUNCTION(event_complete_func_context_NULL_fail)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42, 0x43 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1748,9 +1728,9 @@ TEST_FUNCTION(event_complete_func_context_NULL_fail)
|
|||
TEST_FUNCTION(event_complete_func_EPOLLIN_action)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42, 0x43 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1781,9 +1761,9 @@ TEST_FUNCTION(event_complete_func_EPOLLIN_action)
|
|||
TEST_FUNCTION(event_complete_func_recv_returns_EWOULDBLOCK)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42, 0x43 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1814,9 +1794,9 @@ TEST_FUNCTION(event_complete_func_recv_returns_EWOULDBLOCK)
|
|||
TEST_FUNCTION(event_complete_func_recv_returns_ECONNRESET)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42, 0x43 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1847,9 +1827,9 @@ TEST_FUNCTION(event_complete_func_recv_returns_ECONNRESET)
|
|||
TEST_FUNCTION(event_complete_callback_recv_returns_any_random_error_no)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42, 0x43 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1880,9 +1860,9 @@ TEST_FUNCTION(event_complete_callback_recv_returns_any_random_error_no)
|
|||
TEST_FUNCTION(event_complete_func_recv_returns_0_bytes_success)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42, 0x43 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1912,9 +1892,9 @@ TEST_FUNCTION(event_complete_func_recv_returns_0_bytes_success)
|
|||
TEST_FUNCTION(event_complete_func_notify_for_io_type_IN_EPOLLRDHUP_and_abandons_the_connection)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_notify_io_async(async_socket, ASYNC_SOCKET_NOTIFY_IO_TYPE_IN, test_on_notify_complete, test_callback_ctx));
|
||||
|
||||
|
@ -1938,9 +1918,9 @@ TEST_FUNCTION(event_complete_func_notify_for_io_type_IN_EPOLLRDHUP_and_abandons_
|
|||
TEST_FUNCTION(event_complete_func_notify_for_io_type_IN_ABANDONED_and_abandons_the_connection)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_notify_io_async(async_socket, ASYNC_SOCKET_NOTIFY_IO_TYPE_IN, test_on_notify_complete, test_callback_ctx));
|
||||
|
||||
|
@ -1964,9 +1944,9 @@ TEST_FUNCTION(event_complete_func_notify_for_io_type_IN_ABANDONED_and_abandons_t
|
|||
TEST_FUNCTION(event_complete_func_notify_for_io_type_OUT_EPOLLRDHUP_and_abandons_the_connection)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_notify_io_async(async_socket, ASYNC_SOCKET_NOTIFY_IO_TYPE_OUT, test_on_notify_complete, test_callback_ctx));
|
||||
|
||||
|
@ -1990,9 +1970,9 @@ TEST_FUNCTION(event_complete_func_notify_for_io_type_OUT_EPOLLRDHUP_and_abandons
|
|||
TEST_FUNCTION(event_complete_func_notify_for_io_type_OUT_ABANDONED_and_abandons_the_connection)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_notify_io_async(async_socket, ASYNC_SOCKET_NOTIFY_IO_TYPE_OUT, test_on_notify_complete, test_callback_ctx));
|
||||
|
||||
|
@ -2016,9 +1996,9 @@ TEST_FUNCTION(event_complete_func_notify_for_io_type_OUT_ABANDONED_and_abandons_
|
|||
TEST_FUNCTION(event_complete_func_notify_EPOLLIN_calls_callback_with_IN_flag)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_notify_io_async(async_socket, ASYNC_SOCKET_NOTIFY_IO_TYPE_IN, test_on_notify_complete, test_callback_ctx));
|
||||
|
||||
|
@ -2042,9 +2022,9 @@ TEST_FUNCTION(event_complete_func_notify_EPOLLIN_calls_callback_with_IN_flag)
|
|||
TEST_FUNCTION(event_complete_func_notify_EPOLLOUT_calls_callback_with_OUT_flag)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_notify_io_async(async_socket, ASYNC_SOCKET_NOTIFY_IO_TYPE_OUT, test_on_notify_complete, test_callback_ctx));
|
||||
|
||||
|
@ -2068,9 +2048,9 @@ TEST_FUNCTION(event_complete_func_notify_EPOLLOUT_calls_callback_with_OUT_flag)
|
|||
TEST_FUNCTION(event_complete_func_notify_for_io_type_IN_ERROR_calls_callback_with_ERROR_flag)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_notify_io_async(async_socket, ASYNC_SOCKET_NOTIFY_IO_TYPE_IN, test_on_notify_complete, test_callback_ctx));
|
||||
|
||||
|
@ -2094,9 +2074,9 @@ TEST_FUNCTION(event_complete_func_notify_for_io_type_IN_ERROR_calls_callback_wit
|
|||
TEST_FUNCTION(event_complete_func_notify_for_io_type_OUT_ERROR_calls_callback_with_ERROR_flag)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_notify_io_async(async_socket, ASYNC_SOCKET_NOTIFY_IO_TYPE_OUT, test_on_notify_complete, test_callback_ctx));
|
||||
|
||||
|
@ -2122,9 +2102,9 @@ TEST_FUNCTION(event_complete_func_notify_for_io_type_OUT_ERROR_calls_callback_wi
|
|||
TEST_FUNCTION(event_complete_func_recv_EPOLLRDHUP_and_abandons_the_connection)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42, 0x43 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -2153,9 +2133,9 @@ TEST_FUNCTION(event_complete_func_recv_EPOLLRDHUP_and_abandons_the_connection)
|
|||
TEST_FUNCTION(event_complete_func_send_EPOLLRDHUP_and_abandons_the_connection)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42, 0x43 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -2193,9 +2173,9 @@ TEST_FUNCTION(event_complete_func_send_EPOLLRDHUP_and_abandons_the_connection)
|
|||
TEST_FUNCTION(event_complete_func_recv_ABANDONED_and_abandons_the_connection)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42, 0x43 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -2225,9 +2205,9 @@ TEST_FUNCTION(event_complete_func_recv_ABANDONED_and_abandons_the_connection)
|
|||
TEST_FUNCTION(event_complete_func_send_ABANDONED_and_abandons_the_connection)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42, 0x43 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -2265,9 +2245,9 @@ TEST_FUNCTION(event_complete_func_send_ABANDONED_and_abandons_the_connection)
|
|||
TEST_FUNCTION(event_complete_func_send_EPOLLOUT_success)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42, 0x43 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -2305,9 +2285,9 @@ TEST_FUNCTION(event_complete_func_send_EPOLLOUT_success)
|
|||
TEST_FUNCTION(event_complete_func_send_EPOLLOUT_abandoned)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42, 0x43 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -2346,9 +2326,9 @@ TEST_FUNCTION(event_complete_func_send_EPOLLOUT_abandoned)
|
|||
TEST_FUNCTION(event_complete_func_send_EPOLLOUT_error)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42, 0x43 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -2387,9 +2367,9 @@ TEST_FUNCTION(event_complete_func_send_EPOLLOUT_error)
|
|||
TEST_FUNCTION(event_complete_func_EPOLLOUT_multiple_sends_success)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42, 0x43, 0x44, 0x45 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -2431,9 +2411,9 @@ TEST_FUNCTION(event_complete_func_EPOLLOUT_multiple_sends_success)
|
|||
TEST_FUNCTION(event_complete_func_recv_ERROR_and_error_the_connection)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42, 0x43 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -2461,9 +2441,9 @@ TEST_FUNCTION(event_complete_func_recv_ERROR_and_error_the_connection)
|
|||
TEST_FUNCTION(event_complete_func_send_ERROR_and_error_the_connection)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
|
||||
uint8_t payload_bytes[] = { 0x42, 0x43 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -2515,9 +2495,9 @@ TEST_FUNCTION(async_socket_notify_io_async_with_NULL_async_socket_fails)
|
|||
TEST_FUNCTION(async_socket_notify_io_async_with_NULL_on_notify_io_complete)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// act
|
||||
|
@ -2535,9 +2515,9 @@ TEST_FUNCTION(async_socket_notify_io_async_with_NULL_on_notify_io_complete)
|
|||
TEST_FUNCTION(async_socket_notify_io_async_with_invalid_io_type)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// act
|
||||
|
@ -2555,9 +2535,9 @@ TEST_FUNCTION(async_socket_notify_io_async_with_invalid_io_type)
|
|||
TEST_FUNCTION(async_socket_notify_io_async_with_NULL_on_notify_io_complete_context_succeeds)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
setup_async_socket_notify_io_async_mocks(ASYNC_SOCKET_NOTIFY_IO_TYPE_IN);
|
||||
|
@ -2578,7 +2558,7 @@ TEST_FUNCTION(async_socket_notify_io_async_with_NULL_on_notify_io_complete_conte
|
|||
TEST_FUNCTION(async_socket_notify_io_async_fails_when_state_is_not_OPEN)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -2603,9 +2583,9 @@ TEST_FUNCTION(async_socket_notify_io_async_fails_when_state_is_not_OPEN)
|
|||
TEST_FUNCTION(async_socket_notify_io_async_fails_when_alloc_context_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(interlocked_increment(IGNORED_ARG));
|
||||
|
@ -2632,9 +2612,9 @@ TEST_FUNCTION(async_socket_notify_io_async_fails_when_alloc_context_fails)
|
|||
TEST_FUNCTION(async_socket_notify_io_async_succeeds_for_IN)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
setup_async_socket_notify_io_async_mocks(ASYNC_SOCKET_NOTIFY_IO_TYPE_IN);
|
||||
|
@ -2657,9 +2637,9 @@ TEST_FUNCTION(async_socket_notify_io_async_succeeds_for_IN)
|
|||
TEST_FUNCTION(async_socket_notify_io_async_succeeds_for_OUT)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
setup_async_socket_notify_io_async_mocks(ASYNC_SOCKET_NOTIFY_IO_TYPE_OUT);
|
||||
|
@ -2680,9 +2660,9 @@ TEST_FUNCTION(async_socket_notify_io_async_succeeds_for_OUT)
|
|||
TEST_FUNCTION(async_socket_notify_io_async_fails_when_completion_port_add_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASSERT_IS_NOT_NULL(async_socket);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_on_open_complete, test_callback_ctx));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, test_callback_ctx));
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(interlocked_increment(IGNORED_ARG));
|
||||
|
|
|
@ -72,11 +72,11 @@ typedef struct ASYNC_SOCKET_BUFFER_TAG
|
|||
uint32_t length;
|
||||
} ASYNC_SOCKET_BUFFER;
|
||||
|
||||
MOCKABLE_FUNCTION(, ASYNC_SOCKET_HANDLE, async_socket_create, EXECUTION_ENGINE_HANDLE, execution_engine, SOCKET_HANDLE, socket_handle);
|
||||
MOCKABLE_FUNCTION(, ASYNC_SOCKET_HANDLE, async_socket_create_with_transport, EXECUTION_ENGINE_HANDLE, execution_engine, SOCKET_HANDLE, socket_handle, ON_ASYNC_SOCKET_SEND, on_send, void*, on_send_context, ON_ASYNC_SOCKET_RECV, on_recv, void*, on_recv_context);
|
||||
MOCKABLE_FUNCTION(, ASYNC_SOCKET_HANDLE, async_socket_create, EXECUTION_ENGINE_HANDLE, execution_engine);
|
||||
MOCKABLE_FUNCTION(, ASYNC_SOCKET_HANDLE, async_socket_create_with_transport, EXECUTION_ENGINE_HANDLE, execution_engine, ON_ASYNC_SOCKET_SEND, on_send, void*, on_send_context, ON_ASYNC_SOCKET_RECV, on_recv, void*, on_recv_context);
|
||||
MOCKABLE_FUNCTION(, void, async_socket_destroy, ASYNC_SOCKET_HANDLE, async_socket);
|
||||
|
||||
MOCKABLE_FUNCTION(, int, async_socket_open_async, ASYNC_SOCKET_HANDLE, async_socket, ON_ASYNC_SOCKET_OPEN_COMPLETE, on_open_complete, void*, on_open_complete_context);
|
||||
MOCKABLE_FUNCTION(, int, async_socket_open_async, ASYNC_SOCKET_HANDLE, async_socket, SOCKET_HANDLE, socket_handle, ON_ASYNC_SOCKET_OPEN_COMPLETE, on_open_complete, void*, on_open_complete_context);
|
||||
MOCKABLE_FUNCTION(, void, async_socket_close, ASYNC_SOCKET_HANDLE, async_socket);
|
||||
MOCKABLE_FUNCTION(, ASYNC_SOCKET_SEND_SYNC_RESULT, async_socket_send_async, ASYNC_SOCKET_HANDLE, async_socket, const ASYNC_SOCKET_BUFFER*, payload, uint32_t, buffer_count, ON_ASYNC_SOCKET_SEND_COMPLETE, on_send_complete, void*, on_send_complete_context);
|
||||
MOCKABLE_FUNCTION(, int, async_socket_receive_async, ASYNC_SOCKET_HANDLE, async_socket, ASYNC_SOCKET_BUFFER*, payload, uint32_t, buffer_count, ON_ASYNC_SOCKET_RECEIVE_COMPLETE, on_receive_complete, void*, on_receive_complete_context);
|
||||
|
@ -86,7 +86,7 @@ MOCKABLE_FUNCTION(, int, async_socket_notify_io_async, ASYNC_SOCKET_HANDLE, asyn
|
|||
### async_socket_create_with_transport
|
||||
|
||||
```c
|
||||
MOCKABLE_FUNCTION(, ASYNC_SOCKET_HANDLE, async_socket_create_with_transport, EXECUTION_ENGINE_HANDLE, execution_engine, SOCKET_HANDLE, socket_handle, ON_ASYNC_SOCKET_SEND, on_send, void*, on_send_context, ON_ASYNC_SOCKET_RECV, on_recv, void*, on_recv_context);
|
||||
MOCKABLE_FUNCTION(, ASYNC_SOCKET_HANDLE, async_socket_create_with_transport, EXECUTION_ENGINE_HANDLE, execution_engine, ON_ASYNC_SOCKET_SEND, on_send, void*, on_send_context, ON_ASYNC_SOCKET_RECV, on_recv, void*, on_recv_context);
|
||||
```
|
||||
|
||||
`async_socket_create_with_transport` is not implemented on Windows at this time and shall simply fail.
|
||||
|
@ -96,7 +96,7 @@ MOCKABLE_FUNCTION(, ASYNC_SOCKET_HANDLE, async_socket_create_with_transport, EXE
|
|||
### async_socket_create
|
||||
|
||||
```c
|
||||
MOCKABLE_FUNCTION(, ASYNC_SOCKET_HANDLE, async_socket_create, EXECUTION_ENGINE_HANDLE, execution_engine, SOCKET_HANDLE, socket_handle);
|
||||
MOCKABLE_FUNCTION(, ASYNC_SOCKET_HANDLE, async_socket_create, EXECUTION_ENGINE_HANDLE, execution_engine);
|
||||
```
|
||||
|
||||
`async_socket_create` creates an async socket.
|
||||
|
@ -105,8 +105,6 @@ MOCKABLE_FUNCTION(, ASYNC_SOCKET_HANDLE, async_socket_create, EXECUTION_ENGINE_H
|
|||
|
||||
**SRS_ASYNC_SOCKET_WIN32_01_002: [** If `execution_engine` is NULL, `async_socket_create` shall fail and return NULL. **]**
|
||||
|
||||
**SRS_ASYNC_SOCKET_WIN32_01_034: [** If `socket_handle` is `INVALID_SOCKET`, `async_socket_create` shall fail and return NULL. **]**
|
||||
|
||||
**SRS_ASYNC_SOCKET_WIN32_42_004: [** `async_socket_create` shall increment the reference count on `execution_engine`. **]**
|
||||
|
||||
**SRS_ASYNC_SOCKET_WIN32_01_035: [** `async_socket_create` shall obtain the `PTP_POOL` from the execution engine passed to `async_socket_create` by calling `execution_engine_win32_get_threadpool`. **]**
|
||||
|
@ -127,8 +125,6 @@ MOCKABLE_FUNCTION(, void, async_socket_destroy, ASYNC_SOCKET_HANDLE, async_socke
|
|||
|
||||
**SRS_ASYNC_SOCKET_WIN32_01_006: [** `async_socket_destroy` shall perform an implicit close if `async_socket` is `OPEN`. **]**
|
||||
|
||||
**SRS_ASYNC_SOCKET_WIN32_42_007: [** If the socket was not `OPEN` then `async_socket_destroy` shall call `closesocket` on the underlying socket. **]**
|
||||
|
||||
**SRS_ASYNC_SOCKET_WIN32_42_005: [** `async_socket_destroy` shall decrement the reference count on the execution engine. **]**
|
||||
|
||||
**SRS_ASYNC_SOCKET_WIN32_01_005: [** `async_socket_destroy` shall free all resources associated with `async_socket`. **]**
|
||||
|
@ -136,13 +132,15 @@ MOCKABLE_FUNCTION(, void, async_socket_destroy, ASYNC_SOCKET_HANDLE, async_socke
|
|||
### async_socket_open_async
|
||||
|
||||
```c
|
||||
MOCKABLE_FUNCTION(, int, async_socket_open_async, ASYNC_SOCKET_HANDLE, async_socket, ON_ASYNC_SOCKET_OPEN_COMPLETE, on_open_complete, void*, on_open_complete_context);
|
||||
MOCKABLE_FUNCTION(, int, async_socket_open_async, ASYNC_SOCKET_HANDLE, async_socket, SOCKET_HANDLE, socket_handle, ON_ASYNC_SOCKET_OPEN_COMPLETE, on_open_complete, void*, on_open_complete_context);
|
||||
```
|
||||
|
||||
`async_socket_open_async` opens the async socket.
|
||||
|
||||
**SRS_ASYNC_SOCKET_WIN32_01_007: [** If `async_socket` is NULL, `async_socket_open_async` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_ASYNC_SOCKET_WIN32_01_034: [** If `socket_handle` is `INVALID_SOCKET`, `async_socket_open_async` shall fail and return NULL. **]**
|
||||
|
||||
**SRS_ASYNC_SOCKET_WIN32_01_008: [** If `on_open_complete` is NULL, `async_socket_open_async` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_ASYNC_SOCKET_WIN32_01_009: [** `on_open_complete_context` shall be allowed to be NULL. **]**
|
||||
|
@ -153,8 +151,6 @@ MOCKABLE_FUNCTION(, int, async_socket_open_async, ASYNC_SOCKET_HANDLE, async_soc
|
|||
|
||||
**SRS_ASYNC_SOCKET_WIN32_01_015: [** If `async_socket` is already OPEN or OPENING, `async_socket_open_async` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_ASYNC_SOCKET_WIN32_42_008: [** If `async_socket` has already closed the underlying socket handle then `async_socket_open_async` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_ASYNC_SOCKET_WIN32_01_016: [** Otherwise `async_socket_open_async` shall initialize a thread pool environment by calling `InitializeThreadpoolEnvironment`. **]**
|
||||
|
||||
**SRS_ASYNC_SOCKET_WIN32_01_036: [** `async_socket_open_async` shall set the thread pool for the environment to the pool obtained from the execution engine by calling `SetThreadpoolCallbackPool`. **]**
|
||||
|
|
|
@ -95,104 +95,104 @@ static VOID WINAPI on_io_complete(PTP_CALLBACK_INSTANCE instance, PVOID context,
|
|||
ASYNC_SOCKET_IO_CONTEXT* io_context = (ASYNC_SOCKET_IO_CONTEXT*)(((unsigned char*)overlapped) - offsetof(ASYNC_SOCKET_IO_CONTEXT, overlapped));
|
||||
switch (io_context->io_type)
|
||||
{
|
||||
default:
|
||||
LogError("Unknown IO type: %" PRI_MU_ENUM "", MU_ENUM_VALUE(ASYNC_SOCKET_IO_TYPE, io_context->io_type));
|
||||
break;
|
||||
default:
|
||||
LogError("Unknown IO type: %" PRI_MU_ENUM "", MU_ENUM_VALUE(ASYNC_SOCKET_IO_TYPE, io_context->io_type));
|
||||
break;
|
||||
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_065: [ If the context of the IO indicates that a send has completed: ]*/
|
||||
case ASYNC_SOCKET_IO_TYPE_SEND:
|
||||
{
|
||||
ASYNC_SOCKET_SEND_RESULT send_result;
|
||||
|
||||
if (io_result == NO_ERROR)
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_065: [ If the context of the IO indicates that a send has completed: ]*/
|
||||
case ASYNC_SOCKET_IO_TYPE_SEND:
|
||||
{
|
||||
uint32_t bytes_sent = (uint32_t)number_of_bytes_transferred;
|
||||
ASYNC_SOCKET_SEND_RESULT send_result;
|
||||
|
||||
if (io_result == NO_ERROR)
|
||||
{
|
||||
uint32_t bytes_sent = (uint32_t)number_of_bytes_transferred;
|
||||
|
||||
#ifdef ENABLE_SOCKET_LOGGING
|
||||
LogVerbose("Asynchronous send of %" PRIu32 " bytes completed at %lf", bytes_sent, timer_global_get_elapsed_us());
|
||||
LogVerbose("Asynchronous send of %" PRIu32 " bytes completed at %lf", bytes_sent, timer_global_get_elapsed_us());
|
||||
#endif
|
||||
|
||||
if (bytes_sent != io_context->total_buffer_bytes)
|
||||
{
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_102: [ If io_result is NO_ERROR, but the number of bytes send is different than the sum of all buffer sizes passed to async_socket_send_async, the on_send_complete callback passed to async_socket_send_async shall be called with on_send_complete_context as context and ASYNC_SOCKET_SEND_ERROR. ]*/
|
||||
send_result = ASYNC_SOCKET_SEND_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_066: [ If io_result is NO_ERROR, the on_send_complete callback passed to async_socket_send_async shall be called with on_send_complete_context as argument and ASYNC_SOCKET_SEND_OK. ]*/
|
||||
send_result = ASYNC_SOCKET_SEND_OK;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_067: [ If io_result is not NO_ERROR, the on_send_complete callback passed to async_socket_send_async shall be called with on_send_complete_context as argument and ASYNC_SOCKET_SEND_ERROR. ]*/
|
||||
LogError("Send IO completed with error %lu", io_result);
|
||||
send_result = ASYNC_SOCKET_SEND_ERROR;
|
||||
}
|
||||
|
||||
io_context->io.send.on_send_complete(io_context->io.send.on_send_complete_context, send_result);
|
||||
|
||||
break;
|
||||
}
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_071: [ If the context of the IO indicates that a receive has completed: ]*/
|
||||
case ASYNC_SOCKET_IO_TYPE_RECEIVE:
|
||||
{
|
||||
ASYNC_SOCKET_RECEIVE_RESULT receive_result;
|
||||
uint32_t bytes_received;
|
||||
|
||||
switch (io_result)
|
||||
{
|
||||
default:
|
||||
{
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_070: [ If io_result is not NO_ERROR, the on_receive_complete callback passed to async_socket_receive_async shall be called with on_receive_complete_context as context, ASYNC_SOCKET_RECEIVE_ERROR as result and 0 for bytes_received. ]*/
|
||||
LogError("Receive IO completed with error %lu", io_result);
|
||||
receive_result = ASYNC_SOCKET_RECEIVE_ERROR;
|
||||
bytes_received = 0;
|
||||
break;
|
||||
}
|
||||
case ERROR_NETNAME_DELETED:
|
||||
case ERROR_CONNECTION_ABORTED:
|
||||
{
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_42_001: [ If io_result is ERROR_NETNAME_DELETED or ERROR_CONNECTION_ABORTED, the on_receive_complete callback passed to async_socket_receive_async shall be called with on_receive_complete_context as context, ASYNC_SOCKET_RECEIVE_ABANDONED as result and 0 for bytes_received. ]*/
|
||||
LogError("Receive IO completed with error %lu (socket seems to be closed)", io_result);
|
||||
receive_result = ASYNC_SOCKET_RECEIVE_ABANDONED;
|
||||
bytes_received = 0;
|
||||
break;
|
||||
}
|
||||
case NO_ERROR:
|
||||
{
|
||||
bytes_received = (uint32_t)number_of_bytes_transferred;
|
||||
|
||||
#ifdef ENABLE_SOCKET_LOGGING
|
||||
LogVerbose("Asynchronous receive of %" PRIu32 " bytes completed at %lf", bytes_received, timer_global_get_elapsed_us());
|
||||
#endif
|
||||
|
||||
if (bytes_received > io_context->total_buffer_bytes)
|
||||
if (bytes_sent != io_context->total_buffer_bytes)
|
||||
{
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_095: [If io_result is NO_ERROR, but the number of bytes received is greater than the sum of all buffer sizes passed to async_socket_receive_async, the on_receive_complete callback passed to async_socket_receive_async shall be called with on_receive_complete_context as context, ASYNC_SOCKET_RECEIVE_ERROR as result and number_of_bytes_transferred for bytes_received. ]*/
|
||||
LogError("Invalid number of bytes received: %" PRIu32 " expected max: %" PRIu32,
|
||||
bytes_received, io_context->total_buffer_bytes);
|
||||
receive_result = ASYNC_SOCKET_RECEIVE_ERROR;
|
||||
}
|
||||
else if (bytes_received == 0)
|
||||
{
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_42_003: [ If io_result is NO_ERROR, but the number of bytes received is 0, the on_receive_complete callback passed to async_socket_receive_async shall be called with on_receive_complete_context as context, ASYNC_SOCKET_RECEIVE_ABANDONED as result and 0 for bytes_received. ]*/
|
||||
LogError("Socket received 0 bytes, assuming socket is closed");
|
||||
receive_result = ASYNC_SOCKET_RECEIVE_ABANDONED;
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_102: [ If io_result is NO_ERROR, but the number of bytes send is different than the sum of all buffer sizes passed to async_socket_send_async, the on_send_complete callback passed to async_socket_send_async shall be called with on_send_complete_context as context and ASYNC_SOCKET_SEND_ERROR. ]*/
|
||||
send_result = ASYNC_SOCKET_SEND_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_069: [ If io_result is NO_ERROR, the on_receive_complete callback passed to async_socket_receive_async shall be called with on_receive_complete_context as context, ASYNC_SOCKET_RECEIVE_OK as result and number_of_bytes_transferred as bytes_received. ]*/
|
||||
receive_result = ASYNC_SOCKET_RECEIVE_OK;
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_066: [ If io_result is NO_ERROR, the on_send_complete callback passed to async_socket_send_async shall be called with on_send_complete_context as argument and ASYNC_SOCKET_SEND_OK. ]*/
|
||||
send_result = ASYNC_SOCKET_SEND_OK;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_067: [ If io_result is not NO_ERROR, the on_send_complete callback passed to async_socket_send_async shall be called with on_send_complete_context as argument and ASYNC_SOCKET_SEND_ERROR. ]*/
|
||||
LogError("Send IO completed with error %lu", io_result);
|
||||
send_result = ASYNC_SOCKET_SEND_ERROR;
|
||||
}
|
||||
|
||||
io_context->io.send.on_send_complete(io_context->io.send.on_send_complete_context, send_result);
|
||||
|
||||
break;
|
||||
}
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_071: [ If the context of the IO indicates that a receive has completed: ]*/
|
||||
case ASYNC_SOCKET_IO_TYPE_RECEIVE:
|
||||
{
|
||||
ASYNC_SOCKET_RECEIVE_RESULT receive_result;
|
||||
uint32_t bytes_received;
|
||||
|
||||
io_context->io.receive.on_receive_complete(io_context->io.receive.on_receive_complete_context, receive_result, bytes_received);
|
||||
switch (io_result)
|
||||
{
|
||||
default:
|
||||
{
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_070: [ If io_result is not NO_ERROR, the on_receive_complete callback passed to async_socket_receive_async shall be called with on_receive_complete_context as context, ASYNC_SOCKET_RECEIVE_ERROR as result and 0 for bytes_received. ]*/
|
||||
LogError("Receive IO completed with error %lu", io_result);
|
||||
receive_result = ASYNC_SOCKET_RECEIVE_ERROR;
|
||||
bytes_received = 0;
|
||||
break;
|
||||
}
|
||||
case ERROR_NETNAME_DELETED:
|
||||
case ERROR_CONNECTION_ABORTED:
|
||||
{
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_42_001: [ If io_result is ERROR_NETNAME_DELETED or ERROR_CONNECTION_ABORTED, the on_receive_complete callback passed to async_socket_receive_async shall be called with on_receive_complete_context as context, ASYNC_SOCKET_RECEIVE_ABANDONED as result and 0 for bytes_received. ]*/
|
||||
LogError("Receive IO completed with error %lu (socket seems to be closed)", io_result);
|
||||
receive_result = ASYNC_SOCKET_RECEIVE_ABANDONED;
|
||||
bytes_received = 0;
|
||||
break;
|
||||
}
|
||||
case NO_ERROR:
|
||||
{
|
||||
bytes_received = (uint32_t)number_of_bytes_transferred;
|
||||
|
||||
break;
|
||||
}
|
||||
#ifdef ENABLE_SOCKET_LOGGING
|
||||
LogVerbose("Asynchronous receive of %" PRIu32 " bytes completed at %lf", bytes_received, timer_global_get_elapsed_us());
|
||||
#endif
|
||||
|
||||
if (bytes_received > io_context->total_buffer_bytes)
|
||||
{
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_095: [If io_result is NO_ERROR, but the number of bytes received is greater than the sum of all buffer sizes passed to async_socket_receive_async, the on_receive_complete callback passed to async_socket_receive_async shall be called with on_receive_complete_context as context, ASYNC_SOCKET_RECEIVE_ERROR as result and number_of_bytes_transferred for bytes_received. ]*/
|
||||
LogError("Invalid number of bytes received: %" PRIu32 " expected max: %" PRIu32,
|
||||
bytes_received, io_context->total_buffer_bytes);
|
||||
receive_result = ASYNC_SOCKET_RECEIVE_ERROR;
|
||||
}
|
||||
else if (bytes_received == 0)
|
||||
{
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_42_003: [ If io_result is NO_ERROR, but the number of bytes received is 0, the on_receive_complete callback passed to async_socket_receive_async shall be called with on_receive_complete_context as context, ASYNC_SOCKET_RECEIVE_ABANDONED as result and 0 for bytes_received. ]*/
|
||||
LogError("Socket received 0 bytes, assuming socket is closed");
|
||||
receive_result = ASYNC_SOCKET_RECEIVE_ABANDONED;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_069: [ If io_result is NO_ERROR, the on_receive_complete callback passed to async_socket_receive_async shall be called with on_receive_complete_context as context, ASYNC_SOCKET_RECEIVE_OK as result and number_of_bytes_transferred as bytes_received. ]*/
|
||||
receive_result = ASYNC_SOCKET_RECEIVE_OK;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
io_context->io.receive.on_receive_complete(io_context->io.receive.on_receive_complete_context, receive_result, bytes_received);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_068: [ on_io_complete shall close the event handle created in async_socket_send_async/async_socket_receive_async. ]*/
|
||||
|
@ -224,6 +224,7 @@ static void internal_close(ASYNC_SOCKET_HANDLE async_socket)
|
|||
// but before the call to WaitForThreadpoolIoCallbacks
|
||||
|
||||
LogInfo("async socket is closing, closesocket(%p);", async_socket->socket_handle);
|
||||
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_42_006: [ async_socket_close shall call closesocket on the underlying socket. ]*/
|
||||
(void)closesocket((SOCKET)async_socket->socket_handle);
|
||||
async_socket->socket_handle = (SOCKET_HANDLE)INVALID_SOCKET;
|
||||
|
@ -242,10 +243,9 @@ static void internal_close(ASYNC_SOCKET_HANDLE async_socket)
|
|||
WakeByAddressSingle((PVOID)&async_socket->state);
|
||||
}
|
||||
|
||||
ASYNC_SOCKET_HANDLE async_socket_create_with_transport(EXECUTION_ENGINE_HANDLE execution_engine, SOCKET_HANDLE socket_handle, ON_ASYNC_SOCKET_SEND on_send, void* on_send_context, ON_ASYNC_SOCKET_RECV on_recv, void* on_recv_context)
|
||||
ASYNC_SOCKET_HANDLE async_socket_create_with_transport(EXECUTION_ENGINE_HANDLE execution_engine, ON_ASYNC_SOCKET_SEND on_send, void* on_send_context, ON_ASYNC_SOCKET_RECV on_recv, void* on_recv_context)
|
||||
{
|
||||
(void)execution_engine;
|
||||
(void)socket_handle;
|
||||
(void)on_send;
|
||||
(void)on_send_context;
|
||||
(void)on_recv;
|
||||
|
@ -256,19 +256,16 @@ ASYNC_SOCKET_HANDLE async_socket_create_with_transport(EXECUTION_ENGINE_HANDLE e
|
|||
return NULL;
|
||||
}
|
||||
|
||||
ASYNC_SOCKET_HANDLE async_socket_create(EXECUTION_ENGINE_HANDLE execution_engine, SOCKET_HANDLE socket_handle)
|
||||
ASYNC_SOCKET_HANDLE async_socket_create(EXECUTION_ENGINE_HANDLE execution_engine)
|
||||
{
|
||||
ASYNC_SOCKET_HANDLE result;
|
||||
SOCKET win32_socket = (SOCKET)socket_handle;
|
||||
|
||||
if (
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_002: [ If execution_engine is NULL, async_socket_create shall fail and return NULL. ]*/
|
||||
(execution_engine == NULL) ||
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_034: [ If socket_handle is INVALID_SOCKET, async_socket_create shall fail and return NULL. ]*/
|
||||
(win32_socket == INVALID_SOCKET))
|
||||
(execution_engine == NULL)
|
||||
)
|
||||
{
|
||||
LogError("EXECUTION_ENGINE_HANDLE execution_engine=%p, SOCKET_HANDLE socket_handle=%p",
|
||||
execution_engine, (void*)win32_socket);
|
||||
LogError("EXECUTION_ENGINE_HANDLE execution_engine=%p", execution_engine);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -287,7 +284,6 @@ ASYNC_SOCKET_HANDLE async_socket_create(EXECUTION_ENGINE_HANDLE execution_engine
|
|||
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_035: [ async_socket_create shall obtain the PTP_POOL from the execution engine passed to async_socket_create by calling execution_engine_win32_get_threadpool. ]*/
|
||||
result->pool = execution_engine_win32_get_threadpool(execution_engine);
|
||||
result->socket_handle = socket_handle;
|
||||
|
||||
(void)InterlockedExchange(&result->pending_api_calls, 0);
|
||||
(void)InterlockedExchange(&result->state, (LONG)ASYNC_SOCKET_WIN32_STATE_CLOSED);
|
||||
|
@ -324,18 +320,11 @@ void async_socket_destroy(ASYNC_SOCKET_HANDLE async_socket)
|
|||
}
|
||||
else if (current_state == (LONG)ASYNC_SOCKET_WIN32_STATE_CLOSED)
|
||||
{
|
||||
if ((SOCKET)async_socket->socket_handle != INVALID_SOCKET)
|
||||
{
|
||||
LogInfo("async socket destroy, closesocket(%p);", async_socket->socket_handle);
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_42_007: [ If the socket was not OPEN then async_socket_destroy shall call closesocket on the underlying socket. ]*/
|
||||
(void)closesocket((SOCKET)async_socket->socket_handle);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
(void)WaitOnAddress(&async_socket->state, ¤t_state, sizeof(current_state), INFINITE);
|
||||
}
|
||||
while (1);
|
||||
} while (1);
|
||||
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_42_005: [ async_socket_destroy shall decrement the reference count on the execution engine. ]*/
|
||||
execution_engine_dec_ref(async_socket->execution_engine);
|
||||
|
@ -345,7 +334,7 @@ void async_socket_destroy(ASYNC_SOCKET_HANDLE async_socket)
|
|||
}
|
||||
}
|
||||
|
||||
int async_socket_open_async(ASYNC_SOCKET_HANDLE async_socket, ON_ASYNC_SOCKET_OPEN_COMPLETE on_open_complete, void* on_open_complete_context)
|
||||
int async_socket_open_async(ASYNC_SOCKET_HANDLE async_socket, SOCKET_HANDLE socket_handle, ON_ASYNC_SOCKET_OPEN_COMPLETE on_open_complete, void* on_open_complete_context)
|
||||
{
|
||||
int result;
|
||||
|
||||
|
@ -355,7 +344,10 @@ int async_socket_open_async(ASYNC_SOCKET_HANDLE async_socket, ON_ASYNC_SOCKET_OP
|
|||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_007: [ If async_socket is NULL, async_socket_open_async shall fail and return a non-zero value. ]*/
|
||||
(async_socket == NULL) ||
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_008: [ If on_open_complete is NULL, async_socket_open_async shall fail and return a non-zero value. ]*/
|
||||
(on_open_complete == NULL))
|
||||
(on_open_complete == NULL) ||
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_034: [ If socket_handle is INVALID_SOCKET, async_socket_create shall fail and return NULL. ]*/
|
||||
(SOCKET)socket_handle == INVALID_SOCKET
|
||||
)
|
||||
{
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_039: [ If any error occurs, async_socket_open_async shall fail and return a non-zero value. ]*/
|
||||
LogError("ASYNC_SOCKET_HANDLE async_socket=%p, ON_ASYNC_SOCKET_OPEN_COMPLETE on_open_complete=%p, void* on_open_complete_context=%p",
|
||||
|
@ -374,45 +366,41 @@ int async_socket_open_async(ASYNC_SOCKET_HANDLE async_socket, ON_ASYNC_SOCKET_OP
|
|||
}
|
||||
else
|
||||
{
|
||||
if ((SOCKET)async_socket->socket_handle == INVALID_SOCKET)
|
||||
async_socket->socket_handle = socket_handle;
|
||||
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_016: [ Otherwise async_socket_open_async shall initialize a thread pool environment by calling InitializeThreadpoolEnvironment. ]*/
|
||||
InitializeThreadpoolEnvironment(&async_socket->tp_environment);
|
||||
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_036: [ async_socket_open_async shall set the thread pool for the environment to the pool obtained from the execution engine by calling SetThreadpoolCallbackPool. ]*/
|
||||
SetThreadpoolCallbackPool(&async_socket->tp_environment, async_socket->pool);
|
||||
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_058: [ async_socket_open_async shall create a threadpool IO by calling CreateThreadpoolIo and passing socket_handle, the callback environment to it and on_io_complete as callback. ]*/
|
||||
async_socket->tp_io = CreateThreadpoolIo(async_socket->socket_handle, on_io_complete, NULL, &async_socket->tp_environment);
|
||||
if (async_socket->tp_io == NULL)
|
||||
{
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_42_008: [ If async_socket has already closed the underlying socket handle then async_socket_open_async shall fail and return a non-zero value. ]*/
|
||||
LogError("Open called after socket was closed");
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_039: [ If any error occurs, async_socket_open_async shall fail and return a non-zero value. ]*/
|
||||
LogLastError("CreateThreadpoolIo failed");
|
||||
result = MU_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_016: [ Otherwise async_socket_open_async shall initialize a thread pool environment by calling InitializeThreadpoolEnvironment. ]*/
|
||||
InitializeThreadpoolEnvironment(&async_socket->tp_environment);
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_094: [ async_socket_open_async shall set the state to OPEN. ]*/
|
||||
(void)InterlockedExchange(&async_socket->state, (LONG)ASYNC_SOCKET_WIN32_STATE_OPEN);
|
||||
WakeByAddressSingle((PVOID)&async_socket->state);
|
||||
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_036: [ async_socket_open_async shall set the thread pool for the environment to the pool obtained from the execution engine by calling SetThreadpoolCallbackPool. ]*/
|
||||
SetThreadpoolCallbackPool(&async_socket->tp_environment, async_socket->pool);
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_017: [ On success async_socket_open_async shall call on_open_complete_context with ASYNC_SOCKET_OPEN_OK. ]*/
|
||||
on_open_complete(on_open_complete_context, ASYNC_SOCKET_OPEN_OK);
|
||||
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_058: [ async_socket_open_async shall create a threadpool IO by calling CreateThreadpoolIo and passing socket_handle, the callback environment to it and on_io_complete as callback. ]*/
|
||||
async_socket->tp_io = CreateThreadpoolIo(async_socket->socket_handle, on_io_complete, NULL, &async_socket->tp_environment);
|
||||
if (async_socket->tp_io == NULL)
|
||||
{
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_039: [ If any error occurs, async_socket_open_async shall fail and return a non-zero value. ]*/
|
||||
LogLastError("CreateThreadpoolIo failed");
|
||||
result = MU_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_094: [ async_socket_open_async shall set the state to OPEN. ]*/
|
||||
(void)InterlockedExchange(&async_socket->state, (LONG)ASYNC_SOCKET_WIN32_STATE_OPEN);
|
||||
WakeByAddressSingle((PVOID)&async_socket->state);
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_014: [ On success, async_socket_open_async shall return 0. ]*/
|
||||
result = 0;
|
||||
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_017: [ On success async_socket_open_async shall call on_open_complete_context with ASYNC_SOCKET_OPEN_OK. ]*/
|
||||
on_open_complete(on_open_complete_context, ASYNC_SOCKET_OPEN_OK);
|
||||
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_014: [ On success, async_socket_open_async shall return 0. ]*/
|
||||
result = 0;
|
||||
|
||||
goto all_ok;
|
||||
}
|
||||
|
||||
DestroyThreadpoolEnvironment(&async_socket->tp_environment);
|
||||
goto all_ok;
|
||||
}
|
||||
|
||||
async_socket->socket_handle = (SOCKET_HANDLE)INVALID_SOCKET;
|
||||
|
||||
DestroyThreadpoolEnvironment(&async_socket->tp_environment);
|
||||
|
||||
(void)InterlockedExchange(&async_socket->state, (LONG)ASYNC_SOCKET_WIN32_STATE_CLOSED);
|
||||
WakeByAddressSingle((PVOID)&async_socket->state);
|
||||
}
|
||||
|
@ -433,7 +421,7 @@ void async_socket_close(ASYNC_SOCKET_HANDLE async_socket)
|
|||
{
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_019: [ Otherwise, async_socket_close shall switch the state to CLOSING. ]*/
|
||||
ASYNC_SOCKET_WIN32_STATE current_state;
|
||||
if ( (current_state = InterlockedCompareExchange(&async_socket->state, (LONG)ASYNC_SOCKET_WIN32_STATE_CLOSING, (LONG)ASYNC_SOCKET_WIN32_STATE_OPEN)) != (LONG)ASYNC_SOCKET_WIN32_STATE_OPEN)
|
||||
if ((current_state = InterlockedCompareExchange(&async_socket->state, (LONG)ASYNC_SOCKET_WIN32_STATE_CLOSING, (LONG)ASYNC_SOCKET_WIN32_STATE_OPEN)) != (LONG)ASYNC_SOCKET_WIN32_STATE_OPEN)
|
||||
{
|
||||
/* Codes_SRS_ASYNC_SOCKET_WIN32_01_022: [ If async_socket is not OPEN, async_socket_close shall return. ]*/
|
||||
LogWarning("Not open, current_state=%" PRI_MU_ENUM "", MU_ENUM_VALUE(ASYNC_SOCKET_WIN32_STATE, current_state));
|
||||
|
|
|
@ -151,8 +151,8 @@ TEST_FUNCTION(send_and_receive_1_byte_succeeds)
|
|||
setup_sockets(&client_socket, &server_socket, &listen_socket);
|
||||
|
||||
// create the async socket object
|
||||
ASYNC_SOCKET_HANDLE server_async_socket = async_socket_create(execution_engine, (SOCKET_HANDLE)server_socket);
|
||||
ASYNC_SOCKET_HANDLE client_async_socket = async_socket_create(execution_engine, (SOCKET_HANDLE)client_socket);
|
||||
ASYNC_SOCKET_HANDLE server_async_socket = async_socket_create(execution_engine);
|
||||
ASYNC_SOCKET_HANDLE client_async_socket = async_socket_create(execution_engine);
|
||||
|
||||
// open
|
||||
HANDLE server_open_event = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
|
@ -160,8 +160,8 @@ TEST_FUNCTION(send_and_receive_1_byte_succeeds)
|
|||
HANDLE client_open_event = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
ASSERT_IS_NOT_NULL(client_open_event);
|
||||
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(server_async_socket, on_open_complete, &server_open_event));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(client_async_socket, on_open_complete, &client_open_event));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(server_async_socket, (SOCKET_HANDLE)server_socket, on_open_complete, &server_open_event));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(client_async_socket, (SOCKET_HANDLE)client_socket, on_open_complete, &client_open_event));
|
||||
|
||||
// wait for open to complete
|
||||
ASSERT_IS_TRUE(WaitForSingleObject(server_open_event, INFINITE) == WAIT_OBJECT_0);
|
||||
|
@ -218,8 +218,8 @@ TEST_FUNCTION(receive_and_send_2_buffers_succeeds)
|
|||
setup_sockets(&client_socket, &server_socket, &listen_socket);
|
||||
|
||||
// create the async socket object
|
||||
ASYNC_SOCKET_HANDLE server_async_socket = async_socket_create(execution_engine, (SOCKET_HANDLE)server_socket);
|
||||
ASYNC_SOCKET_HANDLE client_async_socket = async_socket_create(execution_engine, (SOCKET_HANDLE)client_socket);
|
||||
ASYNC_SOCKET_HANDLE server_async_socket = async_socket_create(execution_engine);
|
||||
ASYNC_SOCKET_HANDLE client_async_socket = async_socket_create(execution_engine);
|
||||
|
||||
// open
|
||||
HANDLE server_open_event = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
|
@ -227,8 +227,8 @@ TEST_FUNCTION(receive_and_send_2_buffers_succeeds)
|
|||
HANDLE client_open_event = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
ASSERT_IS_NOT_NULL(client_open_event);
|
||||
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(server_async_socket, on_open_complete, &server_open_event));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(client_async_socket, on_open_complete, &client_open_event));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(server_async_socket, (SOCKET_HANDLE)server_socket, on_open_complete, &server_open_event));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(client_async_socket, (SOCKET_HANDLE)client_socket, on_open_complete, &client_open_event));
|
||||
|
||||
// wait for open to complete
|
||||
ASSERT_IS_TRUE(WaitForSingleObject(server_open_event, INFINITE) == WAIT_OBJECT_0);
|
||||
|
@ -291,13 +291,13 @@ TEST_FUNCTION(when_server_socket_is_closed_receive_errors_on_client_side)
|
|||
setup_sockets(&client_socket, &server_socket, &listen_socket);
|
||||
|
||||
// create the async socket object
|
||||
ASYNC_SOCKET_HANDLE client_async_socket = async_socket_create(execution_engine, (SOCKET_HANDLE)client_socket);
|
||||
ASYNC_SOCKET_HANDLE client_async_socket = async_socket_create(execution_engine);
|
||||
|
||||
// open
|
||||
HANDLE client_open_event = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
ASSERT_IS_NOT_NULL(client_open_event);
|
||||
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(client_async_socket, on_open_complete, &client_open_event));
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(client_async_socket, (SOCKET_HANDLE)client_socket, on_open_complete, &client_open_event));
|
||||
|
||||
// wait for open to complete
|
||||
ASSERT_IS_TRUE(WaitForSingleObject(client_open_event, INFINITE) == WAIT_OBJECT_0);
|
||||
|
|
|
@ -181,7 +181,7 @@ TEST_FUNCTION(async_socket_create_with_NULL_execution_engine_fails)
|
|||
ASYNC_SOCKET_HANDLE async_socket;
|
||||
|
||||
// act
|
||||
async_socket = async_socket_create(NULL, test_socket);
|
||||
async_socket = async_socket_create(NULL);
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
|
@ -189,18 +189,7 @@ TEST_FUNCTION(async_socket_create_with_NULL_execution_engine_fails)
|
|||
}
|
||||
|
||||
/* Tests_SRS_ASYNC_SOCKET_WIN32_01_034: [ If socket_handle is INVALID_SOCKET, async_socket_create shall fail and return NULL. ]*/
|
||||
TEST_FUNCTION(async_socket_create_with_INVALID_SOCKET_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket;
|
||||
|
||||
// act
|
||||
async_socket = async_socket_create(test_execution_engine, (SOCKET_HANDLE)INVALID_SOCKET);
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
ASSERT_IS_NULL(async_socket);
|
||||
}
|
||||
|
||||
/* Tests_SRS_ASYNC_SOCKET_WIN32_01_001: [ async_socket_create shall allocate a new async socket and on success shall return a non-NULL handle. ]*/
|
||||
/* Tests_SRS_ASYNC_SOCKET_WIN32_42_004: [ async_socket_create shall increment the reference count on execution_engine. ]*/
|
||||
|
@ -215,7 +204,7 @@ TEST_FUNCTION(async_socket_create_succeeds)
|
|||
STRICT_EXPECTED_CALL(execution_engine_win32_get_threadpool(test_execution_engine));
|
||||
|
||||
// act
|
||||
async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
async_socket = async_socket_create(test_execution_engine);
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
|
@ -232,7 +221,7 @@ TEST_FUNCTION(async_socket_create_with_transport_fails)
|
|||
ASYNC_SOCKET_HANDLE async_socket;
|
||||
|
||||
// act
|
||||
async_socket = async_socket_create_with_transport(test_execution_engine, test_socket, NULL, NULL, NULL, NULL);
|
||||
async_socket = async_socket_create_with_transport(test_execution_engine, NULL, NULL, NULL, NULL);
|
||||
|
||||
// assert
|
||||
ASSERT_IS_NULL(async_socket);
|
||||
|
@ -257,7 +246,7 @@ TEST_FUNCTION(when_underlying_calls_fails_async_socket_create_also_fails)
|
|||
umock_c_negative_tests_fail_call(i);
|
||||
|
||||
// act
|
||||
async_socket = async_socket_create(NULL, test_socket);
|
||||
async_socket = async_socket_create(NULL);
|
||||
|
||||
// assert
|
||||
ASSERT_IS_NULL(async_socket, "On failed call %zu", i);
|
||||
|
@ -279,16 +268,14 @@ TEST_FUNCTION(async_socket_destroy_with_NULL_returns)
|
|||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
}
|
||||
|
||||
/* Tests_SRS_ASYNC_SOCKET_WIN32_42_007: [ If the socket was not OPEN then async_socket_destroy shall call closesocket on the underlying socket. ]*/
|
||||
/* Tests_SRS_ASYNC_SOCKET_WIN32_42_005: [ async_socket_destroy shall decrement the reference count on the execution engine. ]*/
|
||||
/* Tests_SRS_ASYNC_SOCKET_WIN32_01_005: [ async_socket_destroy shall free all resources associated with async_socket. ]*/
|
||||
TEST_FUNCTION(async_socket_destroy_frees_resources)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(mocked_closesocket((SOCKET)test_socket));
|
||||
STRICT_EXPECTED_CALL(execution_engine_dec_ref(test_execution_engine));
|
||||
STRICT_EXPECTED_CALL(free(IGNORED_ARG));
|
||||
|
||||
|
@ -305,7 +292,7 @@ TEST_FUNCTION(async_socket_destroy_frees_resources)
|
|||
TEST_FUNCTION(async_socket_destroy_closes_first_if_open)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
PTP_CALLBACK_ENVIRON cbe;
|
||||
PTP_IO test_ptp_io;
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -314,7 +301,7 @@ TEST_FUNCTION(async_socket_destroy_closes_first_if_open)
|
|||
STRICT_EXPECTED_CALL(mocked_SetThreadpoolCallbackPool(IGNORED_ARG, test_pool));
|
||||
STRICT_EXPECTED_CALL(mocked_CreateThreadpoolIo(test_socket, IGNORED_ARG, IGNORED_ARG, IGNORED_ARG))
|
||||
.CaptureReturn(&test_ptp_io);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242));
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// close first
|
||||
|
@ -342,23 +329,41 @@ TEST_FUNCTION(async_socket_open_async_with_NULL_async_socket_fails)
|
|||
int result;
|
||||
|
||||
// act
|
||||
result = async_socket_open_async(NULL, test_on_open_complete, (void*)0x4242);
|
||||
result = async_socket_open_async(NULL, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
ASSERT_ARE_NOT_EQUAL(int, 0, result);
|
||||
}
|
||||
|
||||
/* Tests_SRS_ASYNC_SOCKET_WIN32_01_008: [ If on_open_complete is NULL, async_socket_open_async shall fail and return a non-zero value. ]*/
|
||||
TEST_FUNCTION(async_socket_open_async_with_NULL_on_open_complete_fails)
|
||||
TEST_FUNCTION(async_socket_open_async_with_INVALID_SOCKET_socket_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
int result;
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// act
|
||||
result = async_socket_open_async(async_socket, NULL, (void*)0x4242);
|
||||
result = async_socket_open_async(async_socket, (SOCKET_HANDLE)INVALID_SOCKET, test_on_open_complete, (void*)0x4242);
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
ASSERT_ARE_NOT_EQUAL(int, 0, result);
|
||||
|
||||
// cleanup
|
||||
async_socket_destroy(async_socket);
|
||||
}
|
||||
|
||||
/* Tests_SRS_ASYNC_SOCKET_WIN32_01_008: [ If on_open_complete is NULL, async_socket_open_async shall fail and return a non-zero value. ]*/
|
||||
TEST_FUNCTION(async_socket_open_async_with_NULL_on_open_complete_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
int result;
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// act
|
||||
result = async_socket_open_async(async_socket, test_socket, NULL, (void*)0x4242);
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
|
@ -377,7 +382,7 @@ TEST_FUNCTION(async_socket_open_async_with_NULL_on_open_complete_fails)
|
|||
TEST_FUNCTION(async_socket_open_async_succeeds)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
int result;
|
||||
PTP_CALLBACK_ENVIRON cbe;
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -391,7 +396,7 @@ TEST_FUNCTION(async_socket_open_async_succeeds)
|
|||
STRICT_EXPECTED_CALL(test_on_open_complete((void*)0x4242, ASYNC_SOCKET_OPEN_OK));
|
||||
|
||||
// act
|
||||
result = async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
result = async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
|
@ -405,7 +410,7 @@ TEST_FUNCTION(async_socket_open_async_succeeds)
|
|||
TEST_FUNCTION(async_socket_open_async_succeeds_with_NULL_context)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
int result;
|
||||
PTP_CALLBACK_ENVIRON cbe;
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -419,7 +424,7 @@ TEST_FUNCTION(async_socket_open_async_succeeds_with_NULL_context)
|
|||
STRICT_EXPECTED_CALL(test_on_open_complete(NULL, ASYNC_SOCKET_OPEN_OK));
|
||||
|
||||
// act
|
||||
result = async_socket_open_async(async_socket, test_on_open_complete, NULL);
|
||||
result = async_socket_open_async(async_socket, test_socket, test_on_open_complete, NULL);
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
|
@ -433,7 +438,7 @@ TEST_FUNCTION(async_socket_open_async_succeeds_with_NULL_context)
|
|||
TEST_FUNCTION(when_underlying_calls_fail_async_socket_open_async_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
int result;
|
||||
size_t i;
|
||||
PTP_CALLBACK_ENVIRON cbe;
|
||||
|
@ -457,7 +462,7 @@ TEST_FUNCTION(when_underlying_calls_fail_async_socket_open_async_fails)
|
|||
umock_c_negative_tests_fail_call(i);
|
||||
|
||||
// act
|
||||
result = async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
result = async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_NOT_EQUAL(int, 0, result, "On failed call %zu", i);
|
||||
|
@ -472,34 +477,13 @@ TEST_FUNCTION(when_underlying_calls_fail_async_socket_open_async_fails)
|
|||
TEST_FUNCTION(async_socket_open_async_after_async_socket_open_async_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
int result;
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// act
|
||||
result = async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
ASSERT_ARE_NOT_EQUAL(int, 0, result);
|
||||
|
||||
// cleanup
|
||||
async_socket_destroy(async_socket);
|
||||
}
|
||||
|
||||
/* Tests_SRS_ASYNC_SOCKET_WIN32_42_008: [ If async_socket has already closed the underlying socket handle then async_socket_open_async shall fail and return a non-zero value. ]*/
|
||||
TEST_FUNCTION(async_socket_open_async_after_close_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
async_socket_close(async_socket);
|
||||
int result;
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// act
|
||||
result = async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
result = async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
|
@ -533,7 +517,7 @@ TEST_FUNCTION(async_socket_close_with_NULL_returns)
|
|||
TEST_FUNCTION(async_socket_close_reverses_the_actions_from_open)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
PTP_CALLBACK_ENVIRON cbe;
|
||||
PTP_IO test_ptp_io;
|
||||
|
||||
|
@ -543,7 +527,7 @@ TEST_FUNCTION(async_socket_close_reverses_the_actions_from_open)
|
|||
STRICT_EXPECTED_CALL(mocked_SetThreadpoolCallbackPool(IGNORED_ARG, test_pool));
|
||||
STRICT_EXPECTED_CALL(mocked_CreateThreadpoolIo(test_socket, IGNORED_ARG, IGNORED_ARG, IGNORED_ARG))
|
||||
.CaptureReturn(&test_ptp_io);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(mocked_closesocket((SOCKET)test_socket));
|
||||
|
@ -565,7 +549,7 @@ TEST_FUNCTION(async_socket_close_reverses_the_actions_from_open)
|
|||
TEST_FUNCTION(async_socket_close_when_not_open_returns)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// act
|
||||
|
@ -582,8 +566,8 @@ TEST_FUNCTION(async_socket_close_when_not_open_returns)
|
|||
TEST_FUNCTION(async_socket_close_after_close_returns)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
async_socket_close(async_socket);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -621,8 +605,8 @@ TEST_FUNCTION(async_socket_send_async_with_NULL_async_socket_fails)
|
|||
TEST_FUNCTION(async_socket_send_async_with_NULL_payload_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -641,8 +625,8 @@ TEST_FUNCTION(async_socket_send_async_with_NULL_payload_fails)
|
|||
TEST_FUNCTION(async_socket_send_async_with_0_payload_count_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -665,8 +649,8 @@ TEST_FUNCTION(async_socket_send_async_with_0_payload_count_fails)
|
|||
TEST_FUNCTION(async_socket_send_async_with_first_out_of_2_buffers_having_buffer_NULL_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[2];
|
||||
|
@ -691,8 +675,8 @@ TEST_FUNCTION(async_socket_send_async_with_first_out_of_2_buffers_having_buffer_
|
|||
TEST_FUNCTION(async_socket_send_async_with_second_out_of_2_buffers_having_buffer_NULL_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[2];
|
||||
|
@ -717,8 +701,8 @@ TEST_FUNCTION(async_socket_send_async_with_second_out_of_2_buffers_having_buffer
|
|||
TEST_FUNCTION(async_socket_send_async_with_first_out_of_2_buffers_having_length_0_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[2];
|
||||
|
@ -743,8 +727,8 @@ TEST_FUNCTION(async_socket_send_async_with_first_out_of_2_buffers_having_length_
|
|||
TEST_FUNCTION(async_socket_send_async_with_second_out_of_2_buffers_having_length_0_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[2];
|
||||
|
@ -769,8 +753,8 @@ TEST_FUNCTION(async_socket_send_async_with_second_out_of_2_buffers_having_length
|
|||
TEST_FUNCTION(async_socket_send_async_with_UINT32_MAX_buffers_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[2];
|
||||
|
@ -796,8 +780,8 @@ TEST_FUNCTION(async_socket_send_async_with_UINT32_MAX_buffers_fails)
|
|||
TEST_FUNCTION(async_socket_send_async_with_on_send_complete_NULL_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -820,7 +804,7 @@ TEST_FUNCTION(async_socket_send_async_with_on_send_complete_NULL_fails)
|
|||
TEST_FUNCTION(async_socket_send_async_when_not_open_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -843,13 +827,13 @@ TEST_FUNCTION(async_socket_send_async_when_not_open_fails)
|
|||
TEST_FUNCTION(async_socket_send_async_after_close_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
payload_buffers[0].buffer = payload_bytes;
|
||||
payload_buffers[0].length = sizeof(payload_bytes);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_close(async_socket);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -874,7 +858,7 @@ TEST_FUNCTION(async_socket_send_async_after_close_fails)
|
|||
TEST_FUNCTION(async_socket_send_async_succeeds)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -891,7 +875,7 @@ TEST_FUNCTION(async_socket_send_async_succeeds)
|
|||
.CaptureReturn(&test_ptp_io)
|
||||
.CaptureArgumentValue_pv(&test_ptp_io_context)
|
||||
.CaptureArgumentValue_pfnio(&test_on_io_complete);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(malloc_flex(IGNORED_ARG, 1, sizeof(WSABUF)));
|
||||
|
@ -916,7 +900,7 @@ TEST_FUNCTION(async_socket_send_async_succeeds)
|
|||
TEST_FUNCTION(async_socket_send_async_with_NULL_on_send_complete_context_succeeds)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -933,7 +917,7 @@ TEST_FUNCTION(async_socket_send_async_with_NULL_on_send_complete_context_succeed
|
|||
.CaptureReturn(&test_ptp_io)
|
||||
.CaptureArgumentValue_pv(&test_ptp_io_context)
|
||||
.CaptureArgumentValue_pfnio(&test_on_io_complete);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(malloc_flex(IGNORED_ARG, 1, sizeof(WSABUF)));
|
||||
|
@ -959,7 +943,7 @@ TEST_FUNCTION(async_socket_send_async_with_NULL_on_send_complete_context_succeed
|
|||
TEST_FUNCTION(when_underlying_calls_fail_async_socket_send_async_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -972,7 +956,7 @@ TEST_FUNCTION(when_underlying_calls_fail_async_socket_send_async_fails)
|
|||
STRICT_EXPECTED_CALL(mocked_SetThreadpoolCallbackPool(IGNORED_ARG, test_pool));
|
||||
STRICT_EXPECTED_CALL(mocked_CreateThreadpoolIo(test_socket, IGNORED_ARG, IGNORED_ARG, IGNORED_ARG))
|
||||
.CaptureReturn(&test_ptp_io);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(malloc_flex(IGNORED_ARG, 1, sizeof(WSABUF)));
|
||||
|
@ -1009,7 +993,7 @@ TEST_FUNCTION(when_underlying_calls_fail_async_socket_send_async_fails)
|
|||
TEST_FUNCTION(when_get_last_error_for_send_returns_WSA_IO_PENDING_it_is_treated_as_successfull)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1027,7 +1011,7 @@ TEST_FUNCTION(when_get_last_error_for_send_returns_WSA_IO_PENDING_it_is_treated_
|
|||
.CaptureReturn(&test_ptp_io)
|
||||
.CaptureArgumentValue_pv(&test_ptp_io_context)
|
||||
.CaptureArgumentValue_pfnio(&test_on_io_complete);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(malloc_flex(IGNORED_ARG, 1, sizeof(WSABUF)));
|
||||
|
@ -1055,7 +1039,7 @@ TEST_FUNCTION(when_get_last_error_for_send_returns_WSA_IO_PENDING_it_is_treated_
|
|||
TEST_FUNCTION(when_get_last_error_for_send_returns_an_error_then_async_socket_send_async_cancels_the_IO)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1074,7 +1058,7 @@ TEST_FUNCTION(when_get_last_error_for_send_returns_an_error_then_async_socket_se
|
|||
.CaptureReturn(&test_ptp_io)
|
||||
.CaptureArgumentValue_pv(&test_ptp_io_context)
|
||||
.CaptureArgumentValue_pfnio(&test_on_io_complete);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(malloc_flex(IGNORED_ARG, 1, sizeof(WSABUF)));
|
||||
|
@ -1106,7 +1090,7 @@ TEST_FUNCTION(when_get_last_error_for_send_returns_an_error_then_async_socket_se
|
|||
TEST_FUNCTION(when_get_last_error_for_send_returns_WSAGetLastError_then_async_socket_send_async_cancels_the_IO_and_returns_ABANDONED)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1125,7 +1109,7 @@ TEST_FUNCTION(when_get_last_error_for_send_returns_WSAGetLastError_then_async_so
|
|||
.CaptureReturn(&test_ptp_io)
|
||||
.CaptureArgumentValue_pv(&test_ptp_io_context)
|
||||
.CaptureArgumentValue_pfnio(&test_on_io_complete);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(malloc_flex(IGNORED_ARG, 1, sizeof(WSABUF)));
|
||||
|
@ -1157,7 +1141,7 @@ TEST_FUNCTION(when_get_last_error_for_send_returns_WSAGetLastError_then_async_so
|
|||
TEST_FUNCTION(when_WSASend_returns_an_error_different_than_SOCKET_ERROR_async_socket_send_async_cancels_the_IO)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1175,7 +1159,7 @@ TEST_FUNCTION(when_WSASend_returns_an_error_different_than_SOCKET_ERROR_async_so
|
|||
.CaptureReturn(&test_ptp_io)
|
||||
.CaptureArgumentValue_pv(&test_ptp_io_context)
|
||||
.CaptureArgumentValue_pfnio(&test_on_io_complete);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(malloc_flex(IGNORED_ARG, 1, sizeof(WSABUF)));
|
||||
|
@ -1205,8 +1189,8 @@ TEST_FUNCTION(when_WSASend_returns_an_error_different_than_SOCKET_ERROR_async_so
|
|||
TEST_FUNCTION(async_socket_send_async_with_sum_of_buffer_lengths_exceeding_UINT32_MAX_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_SEND_SYNC_RESULT result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[2];
|
||||
|
@ -1251,8 +1235,8 @@ TEST_FUNCTION(async_socket_receive_async_with_NULL_async_socket_fails)
|
|||
TEST_FUNCTION(async_socket_receive_async_with_NULL_payload_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
int result;
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -1271,8 +1255,8 @@ TEST_FUNCTION(async_socket_receive_async_with_NULL_payload_fails)
|
|||
TEST_FUNCTION(async_socket_receive_async_with_0_payload_count_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
int result;
|
||||
uint8_t payload_bytes[1];
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1295,8 +1279,8 @@ TEST_FUNCTION(async_socket_receive_async_with_0_payload_count_fails)
|
|||
TEST_FUNCTION(async_socket_receive_async_with_first_out_of_2_buffers_having_buffer_NULL_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
int result;
|
||||
uint8_t payload_bytes_1[1];
|
||||
uint8_t payload_bytes_2[1];
|
||||
|
@ -1322,8 +1306,8 @@ TEST_FUNCTION(async_socket_receive_async_with_first_out_of_2_buffers_having_buff
|
|||
TEST_FUNCTION(async_socket_receive_async_with_second_out_of_2_buffers_having_buffer_NULL_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
int result;
|
||||
uint8_t payload_bytes_1[1];
|
||||
uint8_t payload_bytes_2[1];
|
||||
|
@ -1349,8 +1333,8 @@ TEST_FUNCTION(async_socket_receive_async_with_second_out_of_2_buffers_having_buf
|
|||
TEST_FUNCTION(async_socket_receive_async_with_first_out_of_2_buffers_having_length_0_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
int result;
|
||||
uint8_t payload_bytes_1[1];
|
||||
uint8_t payload_bytes_2[1];
|
||||
|
@ -1376,8 +1360,8 @@ TEST_FUNCTION(async_socket_receive_async_with_first_out_of_2_buffers_having_leng
|
|||
TEST_FUNCTION(async_socket_receive_async_with_second_out_of_2_buffers_having_length_0_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
int result;
|
||||
uint8_t payload_bytes_1[1];
|
||||
uint8_t payload_bytes_2[1];
|
||||
|
@ -1403,8 +1387,8 @@ TEST_FUNCTION(async_socket_receive_async_with_second_out_of_2_buffers_having_len
|
|||
TEST_FUNCTION(async_socket_receive_async_with_sum_of_buffer_lengths_exceeding_UINT32_MAX_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
int result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[2];
|
||||
|
@ -1429,8 +1413,8 @@ TEST_FUNCTION(async_socket_receive_async_with_sum_of_buffer_lengths_exceeding_UI
|
|||
TEST_FUNCTION(async_socket_receive_async_with_on_send_complete_NULL_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
int result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1453,7 +1437,7 @@ TEST_FUNCTION(async_socket_receive_async_with_on_send_complete_NULL_fails)
|
|||
TEST_FUNCTION(async_socket_receive_async_when_not_open_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
int result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1477,14 +1461,14 @@ TEST_FUNCTION(async_socket_receive_async_when_not_open_fails)
|
|||
TEST_FUNCTION(async_socket_receive_async_after_close_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
int result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
||||
payload_buffers[0].buffer = payload_bytes;
|
||||
payload_buffers[0].length = sizeof(payload_bytes);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_close(async_socket);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -1509,7 +1493,7 @@ TEST_FUNCTION(async_socket_receive_async_after_close_fails)
|
|||
TEST_FUNCTION(async_socket_receive_async_succeeds)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
int result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1527,7 +1511,7 @@ TEST_FUNCTION(async_socket_receive_async_succeeds)
|
|||
.CaptureReturn(&test_ptp_io)
|
||||
.CaptureArgumentValue_pv(&test_ptp_io_context)
|
||||
.CaptureArgumentValue_pfnio(&test_on_io_complete);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(malloc_flex(IGNORED_ARG, 1, sizeof(WSABUF)));
|
||||
|
@ -1552,7 +1536,7 @@ TEST_FUNCTION(async_socket_receive_async_succeeds)
|
|||
TEST_FUNCTION(async_socket_receive_async_with_NULL_on_send_complete_context_succeeds)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
int result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1570,7 +1554,7 @@ TEST_FUNCTION(async_socket_receive_async_with_NULL_on_send_complete_context_succ
|
|||
.CaptureReturn(&test_ptp_io)
|
||||
.CaptureArgumentValue_pv(&test_ptp_io_context)
|
||||
.CaptureArgumentValue_pfnio(&test_on_io_complete);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(malloc_flex(IGNORED_ARG, 1, sizeof(WSABUF)));
|
||||
|
@ -1597,7 +1581,7 @@ TEST_FUNCTION(async_socket_receive_async_with_NULL_on_send_complete_context_succ
|
|||
TEST_FUNCTION(when_underlying_calls_fail_async_socket_receive_async_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
int result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1610,7 +1594,7 @@ TEST_FUNCTION(when_underlying_calls_fail_async_socket_receive_async_fails)
|
|||
STRICT_EXPECTED_CALL(mocked_SetThreadpoolCallbackPool(IGNORED_ARG, test_pool));
|
||||
STRICT_EXPECTED_CALL(mocked_CreateThreadpoolIo(test_socket, IGNORED_ARG, IGNORED_ARG, IGNORED_ARG))
|
||||
.CaptureReturn(&test_ptp_io);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(malloc_flex(IGNORED_ARG, 1, sizeof(WSABUF)));
|
||||
|
@ -1647,7 +1631,7 @@ TEST_FUNCTION(when_underlying_calls_fail_async_socket_receive_async_fails)
|
|||
TEST_FUNCTION(when_get_last_error_for_receive_returns_WSA_IO_PENDING_it_is_treated_as_successfull)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
int result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1665,7 +1649,7 @@ TEST_FUNCTION(when_get_last_error_for_receive_returns_WSA_IO_PENDING_it_is_treat
|
|||
.CaptureReturn(&test_ptp_io)
|
||||
.CaptureArgumentValue_pv(&test_ptp_io_context)
|
||||
.CaptureArgumentValue_pfnio(&test_on_io_complete);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(malloc_flex(IGNORED_ARG, 1, sizeof(WSABUF)));
|
||||
|
@ -1694,7 +1678,7 @@ TEST_FUNCTION(when_get_last_error_for_receive_returns_WSA_IO_PENDING_it_is_treat
|
|||
TEST_FUNCTION(when_WSARecv_returns_an_error_different_than_SOCKET_ERROR_async_socket_receive_async_cancels_the_IO)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
int result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1713,7 +1697,7 @@ TEST_FUNCTION(when_WSARecv_returns_an_error_different_than_SOCKET_ERROR_async_so
|
|||
.CaptureReturn(&test_ptp_io)
|
||||
.CaptureArgumentValue_pv(&test_ptp_io_context)
|
||||
.CaptureArgumentValue_pfnio(&test_on_io_complete);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(malloc_flex(IGNORED_ARG, 1, sizeof(WSABUF)));
|
||||
|
@ -1744,7 +1728,7 @@ TEST_FUNCTION(when_WSARecv_returns_an_error_different_than_SOCKET_ERROR_async_so
|
|||
TEST_FUNCTION(when_get_last_error_for_receive_returns_an_error_then_async_socket_receive_async_cancels_the_IO)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
int result;
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
|
@ -1763,7 +1747,7 @@ TEST_FUNCTION(when_get_last_error_for_receive_returns_an_error_then_async_socket
|
|||
.CaptureReturn(&test_ptp_io)
|
||||
.CaptureArgumentValue_pv(&test_ptp_io_context)
|
||||
.CaptureArgumentValue_pfnio(&test_on_io_complete);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(malloc_flex(IGNORED_ARG, 1, sizeof(WSABUF)));
|
||||
|
@ -1798,7 +1782,7 @@ TEST_FUNCTION(when_get_last_error_for_receive_returns_an_error_then_async_socket
|
|||
TEST_FUNCTION(on_io_complete_with_NULL_overlapped_for_send_returns)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
PTP_IO test_ptp_io;
|
||||
|
@ -1814,7 +1798,7 @@ TEST_FUNCTION(on_io_complete_with_NULL_overlapped_for_send_returns)
|
|||
.CaptureReturn(&test_ptp_io)
|
||||
.CaptureArgumentValue_pv(&test_ptp_io_context)
|
||||
.CaptureArgumentValue_pfnio(&test_on_io_complete);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
umock_c_reset_all_calls();
|
||||
STRICT_EXPECTED_CALL(malloc_flex(IGNORED_ARG, 1, sizeof(WSABUF)));
|
||||
STRICT_EXPECTED_CALL(mocked_CreateEventA(NULL, FALSE, FALSE, NULL));
|
||||
|
@ -1844,7 +1828,7 @@ TEST_FUNCTION(on_io_complete_with_NULL_overlapped_for_send_returns)
|
|||
TEST_FUNCTION(on_io_complete_with_NO_ERROR_indicates_the_send_as_complete_with_OK)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
PTP_IO test_ptp_io;
|
||||
|
@ -1860,7 +1844,7 @@ TEST_FUNCTION(on_io_complete_with_NO_ERROR_indicates_the_send_as_complete_with_O
|
|||
.CaptureReturn(&test_ptp_io)
|
||||
.CaptureArgumentValue_pv(&test_ptp_io_context)
|
||||
.CaptureArgumentValue_pfnio(&test_on_io_complete);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(malloc_flex(IGNORED_ARG, 1, sizeof(WSABUF)));
|
||||
|
@ -1896,7 +1880,7 @@ TEST_FUNCTION(on_io_complete_with_NO_ERROR_indicates_the_send_as_complete_with_O
|
|||
TEST_FUNCTION(on_io_complete_with_error_indicates_the_send_as_complete_with_ERROR)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
uint8_t payload_bytes[] = { 0x42 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
PTP_IO test_ptp_io;
|
||||
|
@ -1912,7 +1896,7 @@ TEST_FUNCTION(on_io_complete_with_error_indicates_the_send_as_complete_with_ERRO
|
|||
.CaptureReturn(&test_ptp_io)
|
||||
.CaptureArgumentValue_pv(&test_ptp_io_context)
|
||||
.CaptureArgumentValue_pfnio(&test_on_io_complete);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(malloc_flex(IGNORED_ARG, 1, sizeof(WSABUF)));
|
||||
|
@ -1944,7 +1928,7 @@ TEST_FUNCTION(on_io_complete_with_error_indicates_the_send_as_complete_with_ERRO
|
|||
TEST_FUNCTION(on_io_complete_with_NO_ERROR_and_number_of_bytes_sent_less_than_expected_indicates_error)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
uint8_t payload_bytes[3] = { 0x42, 0x43, 0x44 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
PTP_IO test_ptp_io;
|
||||
|
@ -1960,7 +1944,7 @@ TEST_FUNCTION(on_io_complete_with_NO_ERROR_and_number_of_bytes_sent_less_than_ex
|
|||
.CaptureReturn(&test_ptp_io)
|
||||
.CaptureArgumentValue_pv(&test_ptp_io_context)
|
||||
.CaptureArgumentValue_pfnio(&test_on_io_complete);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(malloc_flex(IGNORED_ARG, 1, sizeof(WSABUF)));
|
||||
|
@ -1992,7 +1976,7 @@ TEST_FUNCTION(on_io_complete_with_NO_ERROR_and_number_of_bytes_sent_less_than_ex
|
|||
TEST_FUNCTION(on_io_complete_with_NO_ERROR_and_number_of_bytes_sent_more_than_expected_indicates_error)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
uint8_t payload_bytes[3] = { 0x42, 0x43, 0x44 };
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
PTP_IO test_ptp_io;
|
||||
|
@ -2008,7 +1992,7 @@ TEST_FUNCTION(on_io_complete_with_NO_ERROR_and_number_of_bytes_sent_more_than_ex
|
|||
.CaptureReturn(&test_ptp_io)
|
||||
.CaptureArgumentValue_pv(&test_ptp_io_context)
|
||||
.CaptureArgumentValue_pfnio(&test_on_io_complete);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(malloc_flex(IGNORED_ARG,1, sizeof(WSABUF)));
|
||||
|
@ -2040,7 +2024,7 @@ TEST_FUNCTION(on_io_complete_with_NO_ERROR_and_number_of_bytes_sent_more_than_ex
|
|||
TEST_FUNCTION(on_io_complete_with_NULL_overlapped_for_receive_returns)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
uint8_t payload_bytes[1];
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
PTP_IO test_ptp_io;
|
||||
|
@ -2056,7 +2040,7 @@ TEST_FUNCTION(on_io_complete_with_NULL_overlapped_for_receive_returns)
|
|||
.CaptureReturn(&test_ptp_io)
|
||||
.CaptureArgumentValue_pv(&test_ptp_io_context)
|
||||
.CaptureArgumentValue_pfnio(&test_on_io_complete);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
umock_c_reset_all_calls();
|
||||
STRICT_EXPECTED_CALL(malloc_flex(IGNORED_ARG,1, sizeof(WSABUF)));
|
||||
STRICT_EXPECTED_CALL(mocked_CreateEventA(NULL, FALSE, FALSE, NULL));
|
||||
|
@ -2085,7 +2069,7 @@ TEST_FUNCTION(on_io_complete_with_NULL_overlapped_for_receive_returns)
|
|||
TEST_FUNCTION(on_io_complete_with_NO_ERROR_indicates_the_receive_as_complete_with_OK)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
uint8_t payload_bytes[1];
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
PTP_IO test_ptp_io;
|
||||
|
@ -2101,7 +2085,7 @@ TEST_FUNCTION(on_io_complete_with_NO_ERROR_indicates_the_receive_as_complete_wit
|
|||
.CaptureReturn(&test_ptp_io)
|
||||
.CaptureArgumentValue_pv(&test_ptp_io_context)
|
||||
.CaptureArgumentValue_pfnio(&test_on_io_complete);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(malloc_flex(IGNORED_ARG, 1, sizeof(WSABUF)));
|
||||
|
@ -2137,7 +2121,7 @@ TEST_FUNCTION(on_io_complete_with_NO_ERROR_indicates_the_receive_as_complete_wit
|
|||
TEST_FUNCTION(on_io_complete_with_NO_ERROR_indicates_the_receive_as_complete_with_OK_with_2_bytes_received)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
uint8_t payload_bytes[2];
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
PTP_IO test_ptp_io;
|
||||
|
@ -2153,7 +2137,7 @@ TEST_FUNCTION(on_io_complete_with_NO_ERROR_indicates_the_receive_as_complete_wit
|
|||
.CaptureReturn(&test_ptp_io)
|
||||
.CaptureArgumentValue_pv(&test_ptp_io_context)
|
||||
.CaptureArgumentValue_pfnio(&test_on_io_complete);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(malloc_flex(IGNORED_ARG,1,sizeof(WSABUF)));
|
||||
|
@ -2185,7 +2169,7 @@ TEST_FUNCTION(on_io_complete_with_NO_ERROR_indicates_the_receive_as_complete_wit
|
|||
TEST_FUNCTION(on_io_complete_with_NO_ERROR_indicates_the_receive_as_complete_with_OK_with_2_bytes_received_when_buffers_had_only_1_byte)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
uint8_t payload_bytes[1];
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
PTP_IO test_ptp_io;
|
||||
|
@ -2201,7 +2185,7 @@ TEST_FUNCTION(on_io_complete_with_NO_ERROR_indicates_the_receive_as_complete_wit
|
|||
.CaptureReturn(&test_ptp_io)
|
||||
.CaptureArgumentValue_pv(&test_ptp_io_context)
|
||||
.CaptureArgumentValue_pfnio(&test_on_io_complete);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(malloc_flex(IGNORED_ARG,1,sizeof(WSABUF)));
|
||||
|
@ -2237,7 +2221,7 @@ TEST_FUNCTION(on_io_complete_with_NO_ERROR_indicates_the_receive_as_complete_wit
|
|||
TEST_FUNCTION(on_io_complete_with_error_indicates_the_receive_as_complete_with_ERROR)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
uint8_t payload_bytes[1];
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
PTP_IO test_ptp_io;
|
||||
|
@ -2253,7 +2237,7 @@ TEST_FUNCTION(on_io_complete_with_error_indicates_the_receive_as_complete_with_E
|
|||
.CaptureReturn(&test_ptp_io)
|
||||
.CaptureArgumentValue_pv(&test_ptp_io_context)
|
||||
.CaptureArgumentValue_pfnio(&test_on_io_complete);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(malloc_flex(IGNORED_ARG, 1, sizeof(WSABUF)));
|
||||
|
@ -2285,7 +2269,7 @@ TEST_FUNCTION(on_io_complete_with_error_indicates_the_receive_as_complete_with_E
|
|||
TEST_FUNCTION(on_io_complete_with_NO_ERROR_indicates_the_receive_as_complete_with_ABANDONED_with_0_bytes_received)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
uint8_t payload_bytes[1];
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
PTP_IO test_ptp_io;
|
||||
|
@ -2301,7 +2285,7 @@ TEST_FUNCTION(on_io_complete_with_NO_ERROR_indicates_the_receive_as_complete_wit
|
|||
.CaptureReturn(&test_ptp_io)
|
||||
.CaptureArgumentValue_pv(&test_ptp_io_context)
|
||||
.CaptureArgumentValue_pfnio(&test_on_io_complete);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(malloc_flex(IGNORED_ARG, 1, sizeof(WSABUF)));
|
||||
|
@ -2332,7 +2316,7 @@ TEST_FUNCTION(on_io_complete_with_NO_ERROR_indicates_the_receive_as_complete_wit
|
|||
static void on_io_complete_with_error_indicates_the_receive_as_complete_with_ABANDONED(ULONG error_code)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
uint8_t payload_bytes[1];
|
||||
ASYNC_SOCKET_BUFFER payload_buffers[1];
|
||||
PTP_IO test_ptp_io;
|
||||
|
@ -2348,7 +2332,7 @@ static void on_io_complete_with_error_indicates_the_receive_as_complete_with_ABA
|
|||
.CaptureReturn(&test_ptp_io)
|
||||
.CaptureArgumentValue_pv(&test_ptp_io_context)
|
||||
.CaptureArgumentValue_pfnio(&test_on_io_complete);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASSERT_ARE_EQUAL(int, 0, async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242));
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(malloc_flex(IGNORED_ARG, IGNORED_ARG, IGNORED_ARG));
|
||||
|
@ -2402,8 +2386,8 @@ TEST_FUNCTION(on_io_complete_with_ERROR_CONNECTION_ABORTED_indicates_the_receive
|
|||
TEST_FUNCTION(async_socket_notify_io_async_fails)
|
||||
{
|
||||
// arrange
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine, test_socket);
|
||||
(void)async_socket_open_async(async_socket, test_on_open_complete, (void*)0x4242);
|
||||
ASYNC_SOCKET_HANDLE async_socket = async_socket_create(test_execution_engine);
|
||||
(void)async_socket_open_async(async_socket, test_socket, test_on_open_complete, (void*)0x4242);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// act
|
||||
|
|
Загрузка…
Ссылка в новой задаче