зеркало из https://github.com/Azure/c-pal.git
Socket transport sr (#347)
* unit tests for socket_transport_ * fixed memory leaks and reviews * fixed int test and binding socket errors * making socket_transport_create seperate APIs * fix for linux test * fixes to spec
This commit is contained in:
Родитель
c8450e7e4e
Коммит
ab33a95545
|
@ -8,7 +8,8 @@ The `SOCKET_TYPE` determines which API are applicable for this instance of socke
|
|||
|
||||
| API | Allowable Socket Type
|
||||
|----------------------------------------|----------------------
|
||||
| socket_transport_create | BOTH
|
||||
| socket_transport_create_client | SOCKET_CLIENT
|
||||
| socket_transport_create_server | SOCKET_BINDING
|
||||
| socket_transport_destroy | BOTH
|
||||
| socket_transport_connect | SOCKET_CLIENT
|
||||
| socket_transport_listen | SOCKET_BINDING
|
||||
|
@ -50,7 +51,8 @@ typedef struct SOCKET_BUFFER_TAG
|
|||
void* buffer;
|
||||
} SOCKET_BUFFER;
|
||||
|
||||
MOCKABLE_FUNCTION(, SOCKET_TRANSPORT_HANDLE, socket_transport_create, SOCKET_TYPE, type);
|
||||
MOCKABLE_FUNCTION(, SOCKET_TRANSPORT_HANDLE, socket_transport_create_client);
|
||||
MOCKABLE_FUNCTION(, SOCKET_TRANSPORT_HANDLE, socket_transport_create_server);
|
||||
MOCKABLE_FUNCTION(, void, socket_transport_destroy, SOCKET_TRANSPORT_HANDLE, socket_transport);
|
||||
|
||||
MOCKABLE_FUNCTION(, int, socket_transport_connect, SOCKET_TRANSPORT_HANDLE, socket_transport, const char*, hostname, uint16_t, port, uint32_t, connection_timeout_ms);
|
||||
|
@ -65,13 +67,21 @@ MOCKABLE_FUNCTION(, SOCKET_RECEIVE_RESULT, socket_transport_receive, SOCKET_TRAN
|
|||
MOCKABLE_FUNCTION(, SOCKET_HANDLE, socket_transport_get_underlying_socket, SOCKET_TRANSPORT_HANDLE, socket_transport);
|
||||
```
|
||||
|
||||
### socket_transport_create
|
||||
### socket_transport_create_client
|
||||
|
||||
```c
|
||||
MOCKABLE_FUNCTION(, SOCKET_TRANSPORT_HANDLE, socket_transport_create, SOCKET_TYPE, type);
|
||||
MOCKABLE_FUNCTION(, SOCKET_TRANSPORT_HANDLE, socket_transport_create_client);
|
||||
```
|
||||
|
||||
`socket_transport_create` creates a socket transport.
|
||||
`socket_transport_create_client` creates a client socket transport.
|
||||
|
||||
### socket_transport_create_server
|
||||
|
||||
```c
|
||||
MOCKABLE_FUNCTION(, SOCKET_TRANSPORT_HANDLE, socket_transport_create_server);
|
||||
```
|
||||
|
||||
`socket_transport_create_server` creates a binding socket transport.
|
||||
|
||||
### socket_transport_destroy
|
||||
|
||||
|
|
|
@ -48,7 +48,8 @@ typedef struct SOCKET_BUFFER_TAG
|
|||
unsigned char* buffer;
|
||||
} SOCKET_BUFFER;
|
||||
|
||||
MOCKABLE_FUNCTION(, SOCKET_TRANSPORT_HANDLE, socket_transport_create, SOCKET_TYPE, type);
|
||||
MOCKABLE_FUNCTION(, SOCKET_TRANSPORT_HANDLE, socket_transport_create_client);
|
||||
MOCKABLE_FUNCTION(, SOCKET_TRANSPORT_HANDLE, socket_transport_create_server);
|
||||
MOCKABLE_FUNCTION(, void, socket_transport_destroy, SOCKET_TRANSPORT_HANDLE, socket_transport);
|
||||
|
||||
MOCKABLE_FUNCTION(, int, socket_transport_connect, SOCKET_TRANSPORT_HANDLE, socket_transport, const char*, hostname, uint16_t, port, uint32_t, connection_timeout_ms);
|
||||
|
|
|
@ -36,7 +36,7 @@ TEST_SUITE_INITIALIZE(suite_init)
|
|||
|
||||
// Need to see what port we can use because on linux there are 3 iteration of this
|
||||
// test: normal, valgrind, and helgrind, so we need to incrment the port number
|
||||
SOCKET_TRANSPORT_HANDLE test_socket = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE test_socket = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(test_socket);
|
||||
|
||||
for (size_t index = 0; index < 10; index++)
|
||||
|
@ -71,13 +71,13 @@ TEST_FUNCTION_CLEANUP(method_cleanup)
|
|||
TEST_FUNCTION(send_and_receive_2_buffer_of_2_byte_succeeds)
|
||||
{
|
||||
// assert
|
||||
SOCKET_TRANSPORT_HANDLE listen_socket = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE listen_socket = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(listen_socket);
|
||||
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_listen(listen_socket, g_port_num));
|
||||
|
||||
// create the async socket object
|
||||
SOCKET_TRANSPORT_HANDLE client_socket = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE client_socket = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(client_socket);
|
||||
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(client_socket, "localhost", g_port_num, 10000));
|
||||
|
@ -177,13 +177,13 @@ static uint32_t make_send_recv_buffer(uint8_t item_count, uint32_t data_size, SO
|
|||
TEST_FUNCTION(send_and_receive_random_buffer_of_random_byte_succeeds)
|
||||
{
|
||||
// assert
|
||||
SOCKET_TRANSPORT_HANDLE listen_socket = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE listen_socket = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(listen_socket);
|
||||
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_listen(listen_socket, g_port_num));
|
||||
|
||||
// create the async socket object
|
||||
SOCKET_TRANSPORT_HANDLE client_socket = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE client_socket = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(client_socket);
|
||||
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(client_socket, "localhost", g_port_num, 10000));
|
||||
|
|
|
@ -43,7 +43,8 @@ typedef struct SOCKET_BUFFER_TAG
|
|||
void* buffer;
|
||||
} SOCKET_BUFFER;
|
||||
|
||||
MOCKABLE_FUNCTION(, SOCKET_TRANSPORT_HANDLE, socket_transport_create, SOCKET_TYPE, type);
|
||||
MOCKABLE_FUNCTION(, SOCKET_TRANSPORT_HANDLE, socket_transport_create_client);
|
||||
MOCKABLE_FUNCTION(, SOCKET_TRANSPORT_HANDLE, socket_transport_create_server);
|
||||
MOCKABLE_FUNCTION(, void, socket_transport_destroy, SOCKET_TRANSPORT_HANDLE, socket_transport);
|
||||
|
||||
MOCKABLE_FUNCTION(, int, socket_transport_connect, SOCKET_TRANSPORT_HANDLE, socket_transport, const char*, hostname, uint16_t, port, uint32_t, connection_timeout_ms);
|
||||
|
@ -58,23 +59,37 @@ MOCKABLE_FUNCTION(, SOCKET_RECEIVE_RESULT, socket_transport_receive, SOCKET_TRAN
|
|||
MOCKABLE_FUNCTION(, SOCKET_HANDLE, socket_transport_get_underlying_socket, SOCKET_TRANSPORT_HANDLE, socket_transport);
|
||||
```
|
||||
|
||||
### socket_transport_create
|
||||
### socket_transport_create_client
|
||||
|
||||
```c
|
||||
MOCKABLE_FUNCTION(, SOCKET_TRANSPORT_HANDLE, socket_transport_create, SOCKET_TYPE, type);
|
||||
MOCKABLE_FUNCTION(, SOCKET_TRANSPORT_HANDLE, socket_transport_create_client);
|
||||
```
|
||||
|
||||
`socket_transport_create` creates a socket transport.
|
||||
`socket_transport_create_client` creates a client socket transport.
|
||||
|
||||
**SOCKET_TRANSPORT_LINUX_11_001: [** If `type` is not `SOCKET_CLIENT`, or `SOCKET_BINDING`, `socket_transport_create` shall fail and return `NULL`. **]**
|
||||
**SOCKET_TRANSPORT_LINUX_11_002: [** `socket_transport_create_client` shall allocate a new `SOCKET_TRANSPORT` object. **]**
|
||||
|
||||
**SOCKET_TRANSPORT_LINUX_11_002: [** `socket_transport_create` shall allocate a new `SOCKET_TRANSPORT` object. **]**
|
||||
**SOCKET_TRANSPORT_LINUX_11_003: [** `socket_transport_create_client` shall call `sm_create` to create a sm object with the type set to SOCKET_CLIENT. **]**
|
||||
|
||||
**SOCKET_TRANSPORT_LINUX_11_003: [** `socket_transport_create` shall call `sm_create` to create a sm object. **]**
|
||||
**SOCKET_TRANSPORT_LINUX_11_004: [** On any failure `socket_transport_create_client` shall return `NULL`. **]**
|
||||
|
||||
**SOCKET_TRANSPORT_LINUX_11_004: [** On any failure `socket_transport_create` shall return `NULL`. **]**
|
||||
**SOCKET_TRANSPORT_LINUX_11_005: [** On success `socket_transport_create_client` shall return `SOCKET_TRANSPORT_HANDLE`. **]**
|
||||
|
||||
**SOCKET_TRANSPORT_LINUX_11_005: [** On success `socket_transport_create` shall return `SOCKET_TRANSPORT_HANDLE`. **]**
|
||||
### socket_transport_create_server
|
||||
|
||||
```c
|
||||
MOCKABLE_FUNCTION(, SOCKET_TRANSPORT_HANDLE, socket_transport_create_server);
|
||||
```
|
||||
|
||||
`socket_transport_create_server` creates a server socket transport.
|
||||
|
||||
**SOCKET_TRANSPORT_LINUX_11_079: [** `socket_transport_create_server` shall allocate a new `SOCKET_TRANSPORT` object. **]**
|
||||
|
||||
**SOCKET_TRANSPORT_LINUX_11_080: [** `socket_transport_create_server` shall call `sm_create` to create a sm object with the type set to SOCKET_BINDING. **]**
|
||||
|
||||
**SOCKET_TRANSPORT_LINUX_11_081: [** On any failure `socket_transport_create_server` shall return `NULL`. **]**
|
||||
|
||||
**SOCKET_TRANSPORT_LINUX_11_082: [** On success `socket_transport_create_server` shall return `SOCKET_TRANSPORT_HANDLE`. **]**
|
||||
|
||||
### socket_transport_destroy
|
||||
|
||||
|
|
|
@ -127,45 +127,67 @@ all_ok:
|
|||
return client_socket;
|
||||
}
|
||||
|
||||
SOCKET_TRANSPORT_HANDLE socket_transport_create(SOCKET_TYPE type)
|
||||
SOCKET_TRANSPORT_HANDLE socket_transport_create_client(void)
|
||||
{
|
||||
SOCKET_TRANSPORT* result;
|
||||
|
||||
// Codes_SOCKET_TRANSPORT_LINUX_11_001: [ If type is not SOCKET_CLIENT, or SOCKET_BINDING, socket_transport_create shall fail and return NULL. ]
|
||||
if (type != SOCKET_CLIENT && type != SOCKET_BINDING)
|
||||
// Codes_SOCKET_TRANSPORT_WIN32_11_002: [ socket_transport_create_client shall allocate a new SOCKET_TRANSPORT object. ]
|
||||
result = malloc(sizeof(SOCKET_TRANSPORT));
|
||||
if (result == NULL)
|
||||
{
|
||||
// Codes_SOCKET_TRANSPORT_LINUX_11_004: [ On any failure socket_transport_create shall return NULL. ]
|
||||
LogError("Invalid socket type specified: %" PRI_MU_ENUM "", MU_ENUM_VALUE(SOCKET_TYPE, type) );
|
||||
result = NULL;
|
||||
LogError("failure allocating SOCKET_TRANSPORT: %zu", sizeof(SOCKET_TRANSPORT));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Codes_SOCKET_TRANSPORT_LINUX_11_002: [ socket_transport_create shall allocate a new SOCKET_TRANSPORT object. ]
|
||||
result = malloc(sizeof(SOCKET_TRANSPORT));
|
||||
if (result == NULL)
|
||||
// Codes_SOCKET_TRANSPORT_LINUX_11_003: [ socket_transport_create_client shall call sm_create to create a sm object with the type set to SOCKET_CLIENT. ]
|
||||
result->sm = sm_create("Socket_transport_win32");
|
||||
if (result->sm == NULL)
|
||||
{
|
||||
// Codes_SOCKET_TRANSPORT_LINUX_11_004: [ On any failure socket_transport_create shall return NULL. ]
|
||||
LogError("failure allocating SOCKET_TRANSPORT: %zu", sizeof(SOCKET_TRANSPORT));
|
||||
LogError("sm_create failed.");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Codes_SOCKET_TRANSPORT_LINUX_11_003: [ socket_transport_create shall call sm_create to create a sm object. ]
|
||||
result->sm = sm_create("socket_transport_win32");
|
||||
if (result->sm == NULL)
|
||||
{
|
||||
// Codes_SOCKET_TRANSPORT_LINUX_11_004: [ On any failure socket_transport_create shall return NULL. ]
|
||||
LogError("sm_create failed.");
|
||||
}
|
||||
else
|
||||
{
|
||||
result->type = type;
|
||||
goto all_ok;
|
||||
}
|
||||
free(result);
|
||||
result = NULL;
|
||||
result->type = SOCKET_CLIENT;
|
||||
goto all_ok;
|
||||
}
|
||||
free(result);
|
||||
// Codes_SOCKET_TRANSPORT_WIN32_11_004: [ On any failure socket_transport_create_client shall return NULL. ]
|
||||
result = NULL;
|
||||
}
|
||||
all_ok:
|
||||
// Codes_SOCKET_TRANSPORT_WIN32_11_005: [ On success socket_transport_create_client shall return SOCKET_TRANSPORT_HANDLE. ]
|
||||
return result;
|
||||
}
|
||||
|
||||
SOCKET_TRANSPORT_HANDLE socket_transport_create_server(void)
|
||||
{
|
||||
SOCKET_TRANSPORT* result;
|
||||
|
||||
// Codes_SOCKET_TRANSPORT_LINUX_11_079: [ socket_transport_create shall allocate a new SOCKET_TRANSPORT object. ]
|
||||
result = malloc(sizeof(SOCKET_TRANSPORT));
|
||||
if (result == NULL)
|
||||
{
|
||||
LogError("failure allocating SOCKET_TRANSPORT: %zu", sizeof(SOCKET_TRANSPORT));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Codes_SOCKET_TRANSPORT_LINUX_11_080: [ socket_transport_create_server shall call sm_create to create a sm object with the type set to SOCKET_BINDING. ]
|
||||
result->sm = sm_create("Socket_transport_win32");
|
||||
if (result->sm == NULL)
|
||||
{
|
||||
LogError("sm_create failed.");
|
||||
}
|
||||
else
|
||||
{
|
||||
result->type = SOCKET_BINDING;
|
||||
goto all_ok;
|
||||
}
|
||||
free(result);
|
||||
// Codes_SOCKET_TRANSPORT_WIN32_11_081: [ On any failure socket_transport_create shall return NULL. ]
|
||||
result = NULL;
|
||||
}
|
||||
all_ok:
|
||||
// Codes_SOCKET_TRANSPORT_WIN32_11_082: [ On success socket_transport_create shall return SOCKET_TRANSPORT_HANDLE. ]
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -200,33 +200,17 @@ TEST_FUNCTION_CLEANUP(cleanup)
|
|||
umock_c_negative_tests_deinit();
|
||||
}
|
||||
|
||||
// Tests_SOCKET_TRANSPORT_LINUX_11_001: [ If type is not SOCKET_CLIENT, or SOCKET_BINDING, socket_transport_create shall fail and return NULL. ]
|
||||
TEST_FUNCTION(socket_transport_create_invalid_type_fail)
|
||||
{
|
||||
//arrange
|
||||
|
||||
//act
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create((SOCKET_TYPE)555);
|
||||
|
||||
//assert
|
||||
ASSERT_IS_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
|
||||
//cleanup
|
||||
socket_transport_destroy(socket_handle);
|
||||
}
|
||||
|
||||
// Tests_SOCKET_TRANSPORT_LINUX_11_002: [ socket_transport_create shall allocate a new SOCKET_TRANSPORT object. ]
|
||||
// Tests_SOCKET_TRANSPORT_LINUX_11_003: [ socket_transport_create shall call sm_create to create a sm object. ]
|
||||
// Tests_SOCKET_TRANSPORT_LINUX_11_005: [ On success socket_transport_create shall return SOCKET_TRANSPORT_HANDLE. ]
|
||||
TEST_FUNCTION(socket_transport_create_succeed)
|
||||
// Tests_SOCKET_TRANSPORT_LINUX_11_002: [ socket_transport_create_client shall allocate a new SOCKET_TRANSPORT object. ]
|
||||
// Tests_SOCKET_TRANSPORT_LINUX_11_003: [ socket_transport_create_client shall call sm_create to create a sm object with the type set to SOCKET_CLIENT. ]
|
||||
// Tests_SOCKET_TRANSPORT_LINUX_11_005: [ On success socket_transport_create_client shall return SOCKET_TRANSPORT_HANDLE. ]
|
||||
TEST_FUNCTION(socket_transport_create_client_succeed)
|
||||
{
|
||||
//arrange
|
||||
STRICT_EXPECTED_CALL(malloc(IGNORED_ARG));
|
||||
STRICT_EXPECTED_CALL(sm_create(IGNORED_ARG));
|
||||
|
||||
//act
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
|
||||
//assert
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
|
@ -236,8 +220,8 @@ TEST_FUNCTION(socket_transport_create_succeed)
|
|||
socket_transport_destroy(socket_handle);
|
||||
}
|
||||
|
||||
// Tests_SOCKET_TRANSPORT_LINUX_11_004: [ On any failure socket_transport_create shall return NULL. ]
|
||||
TEST_FUNCTION(socket_transport_create_fail)
|
||||
// Tests_SOCKET_TRANSPORT_LINUX_11_004: [ On any failure socket_transport_create_client shall return NULL. ]
|
||||
TEST_FUNCTION(socket_transport_create_client_fail)
|
||||
{
|
||||
//arrange
|
||||
STRICT_EXPECTED_CALL(malloc(IGNORED_ARG));
|
||||
|
@ -252,7 +236,53 @@ TEST_FUNCTION(socket_transport_create_fail)
|
|||
umock_c_negative_tests_fail_call(index);
|
||||
|
||||
//act
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
|
||||
//assert
|
||||
ASSERT_IS_NULL(socket_handle);
|
||||
}
|
||||
}
|
||||
|
||||
//cleanup
|
||||
}
|
||||
|
||||
// Tests_SOCKET_TRANSPORT_LINUX_11_079: [ socket_transport_create_server shall allocate a new SOCKET_TRANSPORT object. ]
|
||||
// Tests_SOCKET_TRANSPORT_LINUX_11_080: [ socket_transport_create_server shall call sm_create to create a sm object to create a sm object with the type set to SOCKET_BINDING. ]
|
||||
// Tests_SOCKET_TRANSPORT_LINUX_11_082: [ On success socket_transport_create_server shall return SOCKET_TRANSPORT_HANDLE. ]
|
||||
TEST_FUNCTION(socket_transport_create_server_succeed)
|
||||
{
|
||||
//arrange
|
||||
STRICT_EXPECTED_CALL(malloc(IGNORED_ARG));
|
||||
STRICT_EXPECTED_CALL(sm_create(IGNORED_ARG));
|
||||
|
||||
//act
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
|
||||
//assert
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
|
||||
//cleanup
|
||||
socket_transport_destroy(socket_handle);
|
||||
}
|
||||
|
||||
// Tests_SOCKET_TRANSPORT_LINUX_11_081: [ On any failure socket_transport_create_server shall return NULL. ]
|
||||
TEST_FUNCTION(socket_transport_create_server_fail)
|
||||
{
|
||||
//arrange
|
||||
STRICT_EXPECTED_CALL(malloc(IGNORED_ARG));
|
||||
STRICT_EXPECTED_CALL(sm_create(IGNORED_ARG));
|
||||
umock_c_negative_tests_snapshot();
|
||||
|
||||
for (size_t index = 0; index < umock_c_negative_tests_call_count(); index++)
|
||||
{
|
||||
if (umock_c_negative_tests_can_call_fail(index))
|
||||
{
|
||||
umock_c_negative_tests_reset();
|
||||
umock_c_negative_tests_fail_call(index);
|
||||
|
||||
//act
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
|
||||
//assert
|
||||
ASSERT_IS_NULL(socket_handle);
|
||||
|
@ -281,7 +311,7 @@ TEST_FUNCTION(socket_transport_destroy_socket_NULL_fail)
|
|||
TEST_FUNCTION(socket_transport_destroy_succeed)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -301,7 +331,7 @@ TEST_FUNCTION(socket_transport_destroy_succeed)
|
|||
TEST_FUNCTION(socket_transport_connect_socket_transport_NULL_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -320,7 +350,7 @@ TEST_FUNCTION(socket_transport_connect_socket_transport_NULL_fail)
|
|||
TEST_FUNCTION(socket_transport_connect_hostname_NULL_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -339,7 +369,7 @@ TEST_FUNCTION(socket_transport_connect_hostname_NULL_fail)
|
|||
TEST_FUNCTION(socket_transport_connect_port_0_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -358,7 +388,7 @@ TEST_FUNCTION(socket_transport_connect_port_0_fail)
|
|||
TEST_FUNCTION(socket_transport_connect_invalid_client_type_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -380,7 +410,7 @@ TEST_FUNCTION(socket_transport_connect_invalid_client_type_fail)
|
|||
TEST_FUNCTION(socket_transport_connect_succeed)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -408,7 +438,7 @@ TEST_FUNCTION(socket_transport_connect_succeed)
|
|||
TEST_FUNCTION(socket_transport_connect_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -460,7 +490,7 @@ TEST_FUNCTION(socket_transport_disconnect_socket_transport_NULL_fail)
|
|||
TEST_FUNCTION(socket_transport_disconnect_succeed)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -484,7 +514,7 @@ TEST_FUNCTION(socket_transport_disconnect_succeed)
|
|||
TEST_FUNCTION(socket_transport_disconnect_close_fail_succeed)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -507,7 +537,7 @@ TEST_FUNCTION(socket_transport_disconnect_close_fail_succeed)
|
|||
TEST_FUNCTION(socket_transport_disconnect_shutdown_fail_succeed)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -559,7 +589,7 @@ TEST_FUNCTION(socket_transport_send_socket_transport_NULL_fail)
|
|||
TEST_FUNCTION(socket_transport_send_payload_NULL_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -582,7 +612,7 @@ TEST_FUNCTION(socket_transport_send_payload_NULL_fail)
|
|||
TEST_FUNCTION(socket_transport_send_count_0_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -609,7 +639,7 @@ TEST_FUNCTION(socket_transport_send_count_0_fail)
|
|||
TEST_FUNCTION(socket_transport_send_succeed)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -640,7 +670,7 @@ TEST_FUNCTION(socket_transport_send_succeed)
|
|||
TEST_FUNCTION(socket_transport_send_multiple_sends_succeed)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -674,7 +704,7 @@ TEST_FUNCTION(socket_transport_send_multiple_sends_succeed)
|
|||
TEST_FUNCTION(socket_transport_send_not_connected_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -700,7 +730,7 @@ TEST_FUNCTION(socket_transport_send_not_connected_fail)
|
|||
TEST_FUNCTION(socket_transport_send_shutsdown_succeed)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -733,7 +763,7 @@ TEST_FUNCTION(socket_transport_send_shutsdown_succeed)
|
|||
TEST_FUNCTION(socket_transport_send_fails)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -783,7 +813,7 @@ TEST_FUNCTION(socket_transport_receive_socket_transport_NULL_fail)
|
|||
TEST_FUNCTION(socket_transport_receive_payload_NULL_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -806,7 +836,7 @@ TEST_FUNCTION(socket_transport_receive_payload_NULL_fail)
|
|||
TEST_FUNCTION(socket_transport_receive_buffer_count_0_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -836,7 +866,7 @@ TEST_FUNCTION(socket_transport_receive_buffer_count_0_fail)
|
|||
TEST_FUNCTION(socket_transport_receive_succeed)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -869,7 +899,7 @@ TEST_FUNCTION(socket_transport_receive_succeed)
|
|||
TEST_FUNCTION(socket_transport_receive_overflow_succeed)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -905,7 +935,7 @@ TEST_FUNCTION(socket_transport_receive_overflow_succeed)
|
|||
TEST_FUNCTION(socket_transport_receive_multiple_recv_succeed)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -943,7 +973,7 @@ TEST_FUNCTION(socket_transport_receive_multiple_recv_succeed)
|
|||
TEST_FUNCTION(socket_transport_receive_not_connected_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -972,7 +1002,7 @@ TEST_FUNCTION(socket_transport_receive_not_connected_fail)
|
|||
TEST_FUNCTION(socket_transport_receive_recv_returns_WOULDBLOCK_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -1007,7 +1037,7 @@ TEST_FUNCTION(socket_transport_receive_recv_returns_WOULDBLOCK_fail)
|
|||
TEST_FUNCTION(socket_transport_receive_recv_returns_EAGAIN_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -1041,7 +1071,7 @@ TEST_FUNCTION(socket_transport_receive_recv_returns_EAGAIN_fail)
|
|||
TEST_FUNCTION(socket_transport_receive_recv_returns_ECONNRESET_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -1075,7 +1105,7 @@ TEST_FUNCTION(socket_transport_receive_recv_returns_ECONNRESET_fail)
|
|||
TEST_FUNCTION(socket_transport_receive_recv_returns_other_error_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -1109,7 +1139,7 @@ TEST_FUNCTION(socket_transport_receive_recv_returns_other_error_fail)
|
|||
TEST_FUNCTION(socket_transport_receive_recv_returns_0_shutsdowns)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -1160,7 +1190,7 @@ TEST_FUNCTION(socket_transport_listen_socket_transport_NULL_fail)
|
|||
TEST_FUNCTION(socket_transport_listen_port_0_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -1179,7 +1209,7 @@ TEST_FUNCTION(socket_transport_listen_port_0_fail)
|
|||
TEST_FUNCTION(socket_transport_listen_invalid_socket_type_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -1202,7 +1232,7 @@ TEST_FUNCTION(socket_transport_listen_invalid_socket_type_fail)
|
|||
TEST_FUNCTION(socket_transport_listen_succeed)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -1229,7 +1259,7 @@ TEST_FUNCTION(socket_transport_listen_succeed)
|
|||
TEST_FUNCTION(socket_transport_listen_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -1262,7 +1292,7 @@ TEST_FUNCTION(socket_transport_listen_fail)
|
|||
TEST_FUNCTION(socket_transport_listen_sm_open_not_granted_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -1301,7 +1331,7 @@ TEST_FUNCTION(socket_transport_accept_socket_transport_NULL_fail)
|
|||
TEST_FUNCTION(socket_transport_accept_invalid_type_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -1321,7 +1351,7 @@ TEST_FUNCTION(socket_transport_accept_invalid_type_fail)
|
|||
TEST_FUNCTION(socket_transport_accept_not_listening_succeed)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -1347,7 +1377,7 @@ TEST_FUNCTION(socket_transport_accept_not_listening_succeed)
|
|||
TEST_FUNCTION(socket_transport_accept_succeed)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_listen(socket_handle, TEST_PORT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -1379,7 +1409,7 @@ TEST_FUNCTION(socket_transport_accept_succeed)
|
|||
TEST_FUNCTION(socket_transport_accept_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_listen(socket_handle, TEST_PORT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -1438,7 +1468,7 @@ TEST_FUNCTION(socket_transport_get_underlying_socket_socket_transport_NULL_fail)
|
|||
TEST_FUNCTION(socket_transport_get_underlying_socket_succeed)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_listen(socket_handle, TEST_PORT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -1462,7 +1492,7 @@ TEST_FUNCTION(socket_transport_get_underlying_socket_succeed)
|
|||
TEST_FUNCTION(socket_transport_get_underlying_socket_not_open_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
|
|
@ -42,7 +42,8 @@ typedef struct SOCKET_BUFFER_TAG
|
|||
void* buffer;
|
||||
} SOCKET_BUFFER;
|
||||
|
||||
MOCKABLE_FUNCTION(, SOCKET_TRANSPORT_HANDLE, socket_transport_create, SOCKET_TYPE, type);
|
||||
MOCKABLE_FUNCTION(, SOCKET_TRANSPORT_HANDLE, socket_transport_create_client);
|
||||
MOCKABLE_FUNCTION(, SOCKET_TRANSPORT_HANDLE, socket_transport_create_server);
|
||||
MOCKABLE_FUNCTION(, void, socket_transport_destroy, SOCKET_TRANSPORT_HANDLE, socket_transport);
|
||||
|
||||
MOCKABLE_FUNCTION(, int, socket_transport_connect, SOCKET_TRANSPORT_HANDLE, socket_transport, const char*, hostname, uint16_t, port, uint32_t, connection_timeout_ms);
|
||||
|
@ -57,23 +58,38 @@ MOCKABLE_FUNCTION(, SOCKET_RECEIVE_RESULT, socket_transport_receive, SOCKET_TRAN
|
|||
MOCKABLE_FUNCTION(, SOCKET_HANDLE, socket_transport_get_underlying_socket, SOCKET_TRANSPORT_HANDLE, socket_transport);
|
||||
```
|
||||
|
||||
### socket_transport_create
|
||||
### socket_transport_create_client
|
||||
|
||||
```c
|
||||
MOCKABLE_FUNCTION(, SOCKET_TRANSPORT_HANDLE, socket_transport_create, SOCKET_TYPE, type);
|
||||
MOCKABLE_FUNCTION(, SOCKET_TRANSPORT_HANDLE, socket_transport_create_client);
|
||||
```
|
||||
|
||||
`socket_transport_create` creates a socket transport.
|
||||
`socket_transport_create_client` creates a client socket transport.
|
||||
|
||||
**SOCKET_TRANSPORT_WIN32_09_001: [** `socket_transport_create` shall ensure `type` is either `SOCKET_CLIENT`, or `SOCKET_BINDING`. **]**
|
||||
**SOCKET_TRANSPORT_WIN32_09_002: [** `socket_transport_create_client` shall allocate a new `SOCKET_TRANSPORT` object. **]**
|
||||
|
||||
**SOCKET_TRANSPORT_WIN32_09_002: [** `socket_transport_create` shall allocate a new `SOCKET_TRANSPORT` object. **]**
|
||||
**SOCKET_TRANSPORT_WIN32_09_003: [** `socket_transport_create_client` shall call `sm_create` to create a sm object with the type set to SOCKET_CLIENT. **]**
|
||||
|
||||
**SOCKET_TRANSPORT_WIN32_09_003: [** `socket_transport_create` shall call `sm_create` to create a sm object. **]**
|
||||
**SOCKET_TRANSPORT_WIN32_09_004: [** On any failure `socket_transport_create_client` shall return `NULL`. **]**
|
||||
|
||||
**SOCKET_TRANSPORT_WIN32_09_004: [** On any failure `socket_transport_create` shall return `NULL`. **]**
|
||||
**SOCKET_TRANSPORT_WIN32_09_005: [** On success `socket_transport_create_client` shall return `SOCKET_TRANSPORT_HANDLE`. **]**
|
||||
|
||||
### socket_transport_create_server
|
||||
|
||||
```c
|
||||
MOCKABLE_FUNCTION(, SOCKET_TRANSPORT_HANDLE, socket_transport_create_server);
|
||||
```
|
||||
|
||||
`socket_transport_create_server` creates a server socket transport.
|
||||
|
||||
**SOCKET_TRANSPORT_WIN32_09_087: [** `socket_transport_create_server` shall allocate a new `SOCKET_TRANSPORT` object. **]**
|
||||
|
||||
**SOCKET_TRANSPORT_WIN32_09_088: [** `socket_transport_create_server` shall call `sm_create` to create a sm object with the type set to SOCKET_BINDING. **]**
|
||||
|
||||
**SOCKET_TRANSPORT_WIN32_09_089: [** On any failure `socket_transport_create_server` shall return `NULL`. **]**
|
||||
|
||||
**SOCKET_TRANSPORT_WIN32_09_090: [** On success `socket_transport_create_server` shall return `SOCKET_TRANSPORT_HANDLE`. **]**
|
||||
|
||||
**SOCKET_TRANSPORT_WIN32_09_005: [** On success `socket_transport_create` shall return `SOCKET_TRANSPORT_HANDLE`. **]**
|
||||
|
||||
### socket_transport_destroy
|
||||
|
||||
|
|
|
@ -172,48 +172,70 @@ all_ok:
|
|||
return result;
|
||||
}
|
||||
|
||||
SOCKET_TRANSPORT_HANDLE socket_transport_create(SOCKET_TYPE type)
|
||||
SOCKET_TRANSPORT_HANDLE socket_transport_create_client()
|
||||
{
|
||||
SOCKET_TRANSPORT* result;
|
||||
|
||||
// Codes_SOCKET_TRANSPORT_WIN32_09_001: [ socket_transport_create shall ensure type is either SOCKET_CLIENT, or SOCKET_BINDING. ]
|
||||
if (type != SOCKET_CLIENT && type != SOCKET_BINDING)
|
||||
// Codes_SOCKET_TRANSPORT_WIN32_09_002: [ socket_transport_create_client shall allocate a new SOCKET_TRANSPORT object. ]
|
||||
result = malloc(sizeof(SOCKET_TRANSPORT));
|
||||
if (result == NULL)
|
||||
{
|
||||
LogError("Invalid socket type specified: %" PRI_MU_ENUM "", MU_ENUM_VALUE(SOCKET_TYPE, type));
|
||||
result = NULL;
|
||||
LogError("failure allocating SOCKET_TRANSPORT: %zu", sizeof(SOCKET_TRANSPORT));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// Codes_SOCKET_TRANSPORT_WIN32_09_002: [ socket_transport_create shall allocate a new SOCKET_TRANSPORT object. ]
|
||||
result = malloc(sizeof(SOCKET_TRANSPORT));
|
||||
if (result == NULL)
|
||||
// Codes_SOCKET_TRANSPORT_WIN32_09_003: [ socket_transport_create_client shall call sm_create to create a sm object with the type set to SOCKET_CLIENT. ]
|
||||
result->sm = sm_create("Socket_transport_win32");
|
||||
if (result->sm == NULL)
|
||||
{
|
||||
LogError("failure allocating SOCKET_TRANSPORT: %zu", sizeof(SOCKET_TRANSPORT));
|
||||
LogError("sm_create failed.");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Codes_SOCKET_TRANSPORT_WIN32_09_003: [ socket_transport_create shall call sm_create to create a sm object. ]
|
||||
result->sm = sm_create("Socket_transport_win32");
|
||||
if (result->sm == NULL)
|
||||
{
|
||||
LogError("sm_create failed.");
|
||||
}
|
||||
else
|
||||
{
|
||||
result->type = type;
|
||||
goto all_ok;
|
||||
}
|
||||
free(result);
|
||||
// Codes_SOCKET_TRANSPORT_WIN32_09_004: [ On any failure socket_transport_create shall return NULL. ]
|
||||
result = NULL;
|
||||
result->type = SOCKET_CLIENT;
|
||||
goto all_ok;
|
||||
}
|
||||
free(result);
|
||||
// Codes_SOCKET_TRANSPORT_WIN32_09_004: [ On any failure socket_transport_create shall return NULL. ]
|
||||
result = NULL;
|
||||
}
|
||||
all_ok:
|
||||
// Codes_SOCKET_TRANSPORT_WIN32_09_005: [ On success socket_transport_create shall return SOCKET_TRANSPORT_HANDLE. ]
|
||||
return result;
|
||||
}
|
||||
|
||||
SOCKET_TRANSPORT_HANDLE socket_transport_create_server()
|
||||
{
|
||||
SOCKET_TRANSPORT* result;
|
||||
|
||||
// Codes_SOCKET_TRANSPORT_WIN32_09_087: [ socket_transport_create_server shall allocate a new SOCKET_TRANSPORT object. ]
|
||||
result = malloc(sizeof(SOCKET_TRANSPORT));
|
||||
if (result == NULL)
|
||||
{
|
||||
LogError("failure allocating SOCKET_TRANSPORT: %zu", sizeof(SOCKET_TRANSPORT));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Codes_SOCKET_TRANSPORT_WIN32_09_088: [ socket_transport_create_server shall call sm_create to create a sm object with the type set to SOCKET_BINDING. ]
|
||||
result->sm = sm_create("Socket_transport_win32");
|
||||
if (result->sm == NULL)
|
||||
{
|
||||
LogError("sm_create failed.");
|
||||
}
|
||||
else
|
||||
{
|
||||
result->type = SOCKET_BINDING;
|
||||
goto all_ok;
|
||||
}
|
||||
free(result);
|
||||
// Codes_SOCKET_TRANSPORT_WIN32_09_089: [ On any failure socket_transport_create_server shall return NULL. ]
|
||||
result = NULL;
|
||||
}
|
||||
all_ok:
|
||||
// Codes_SOCKET_TRANSPORT_WIN32_09_090: [ On success socket_transport_create_server shall return SOCKET_TRANSPORT_HANDLE. ]
|
||||
return result;
|
||||
}
|
||||
|
||||
void socket_transport_destroy(SOCKET_TRANSPORT_HANDLE socket_transport)
|
||||
{
|
||||
// Codes_SOCKET_TRANSPORT_WIN32_09_006: [ If socket_transport is NULL socket_transport_destroy shall return. ]
|
||||
|
|
|
@ -197,8 +197,8 @@ TEST_FUNCTION_CLEANUP(cleanup)
|
|||
|
||||
}
|
||||
|
||||
// Tests_SOCKET_TRANSPORT_WIN32_09_004: [ On any failure socket_transport_create shall return NULL. ]
|
||||
TEST_FUNCTION(socket_transport_create_fail)
|
||||
// Tests_SOCKET_TRANSPORT_WIN32_09_004: [ On any failure socket_transport_create_client shall return NULL. ]
|
||||
TEST_FUNCTION(socket_transport_create_client_fail)
|
||||
{
|
||||
//arrange
|
||||
STRICT_EXPECTED_CALL(malloc(IGNORED_ARG));
|
||||
|
@ -213,7 +213,7 @@ TEST_FUNCTION(socket_transport_create_fail)
|
|||
umock_c_negative_tests_fail_call(index);
|
||||
|
||||
//act
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
|
||||
//assert
|
||||
ASSERT_IS_NULL(socket_handle);
|
||||
|
@ -223,31 +223,59 @@ TEST_FUNCTION(socket_transport_create_fail)
|
|||
//cleanup
|
||||
}
|
||||
|
||||
// Tests_SOCKET_TRANSPORT_LINUX_09_001: [ socket_transport_create shall ensure type is either SOCKET_CLIENT, or SOCKET_BINDING. ]
|
||||
TEST_FUNCTION(socket_transport_create_invalid_type_fail)
|
||||
{
|
||||
//arrange
|
||||
|
||||
//act
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create((SOCKET_TYPE)555);
|
||||
|
||||
//assert
|
||||
ASSERT_IS_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
|
||||
//cleanup
|
||||
socket_transport_destroy(socket_handle);
|
||||
}
|
||||
|
||||
// Tests_SOCKET_TRANSPORT_WIN32_09_005: [ On success socket_transport_create shall return SOCKET_TRANSPORT_HANDLE. ]
|
||||
TEST_FUNCTION(socket_transport_create_succeed)
|
||||
// Tests_SOCKET_TRANSPORT_WIN32_09_005: [ On success socket_transport_create_client shall return SOCKET_TRANSPORT_HANDLE. ]
|
||||
TEST_FUNCTION(socket_transport_create_client_succeed)
|
||||
{
|
||||
//arrange
|
||||
STRICT_EXPECTED_CALL(malloc(IGNORED_ARG));
|
||||
STRICT_EXPECTED_CALL(sm_create(IGNORED_ARG));
|
||||
|
||||
//act
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
|
||||
//assert
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
|
||||
//cleanup
|
||||
socket_transport_destroy(socket_handle);
|
||||
}
|
||||
|
||||
// Tests_SOCKET_TRANSPORT_WIN32_09_089: [ On any failure socket_transport_create_server shall return NULL. ]
|
||||
TEST_FUNCTION(socket_transport_create_server_fail)
|
||||
{
|
||||
//arrange
|
||||
STRICT_EXPECTED_CALL(malloc(IGNORED_ARG));
|
||||
STRICT_EXPECTED_CALL(sm_create(IGNORED_ARG));
|
||||
umock_c_negative_tests_snapshot();
|
||||
|
||||
for (size_t index = 0; index < umock_c_negative_tests_call_count(); index++)
|
||||
{
|
||||
if (umock_c_negative_tests_can_call_fail(index))
|
||||
{
|
||||
umock_c_negative_tests_reset();
|
||||
umock_c_negative_tests_fail_call(index);
|
||||
|
||||
//act
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
|
||||
//assert
|
||||
ASSERT_IS_NULL(socket_handle);
|
||||
}
|
||||
}
|
||||
|
||||
//cleanup
|
||||
}
|
||||
|
||||
// Tests_SOCKET_TRANSPORT_WIN32_09_090: [ On success socket_transport_create_server shall return SOCKET_TRANSPORT_HANDLE. ]
|
||||
TEST_FUNCTION(socket_transport_create_server_succeeds)
|
||||
{
|
||||
//arrange
|
||||
STRICT_EXPECTED_CALL(malloc(IGNORED_ARG));
|
||||
STRICT_EXPECTED_CALL(sm_create(IGNORED_ARG));
|
||||
|
||||
//act
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
|
||||
//assert
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
|
@ -276,7 +304,7 @@ TEST_FUNCTION(socket_transport_destroy_socket_NULL_fail)
|
|||
TEST_FUNCTION(socket_transport_destroy_succeed)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -298,7 +326,7 @@ TEST_FUNCTION(socket_transport_destroy_succeed)
|
|||
TEST_FUNCTION(socket_transport_connect_winsock_connect_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -331,7 +359,7 @@ TEST_FUNCTION(socket_transport_connect_winsock_connect_fail)
|
|||
TEST_FUNCTION(socket_transport_connect_connecting_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -367,7 +395,7 @@ TEST_FUNCTION(socket_transport_connect_connecting_fail)
|
|||
TEST_FUNCTION(socket_transport_connect_timeout_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -402,7 +430,7 @@ TEST_FUNCTION(socket_transport_connect_timeout_fail)
|
|||
TEST_FUNCTION(socket_transport_connect_fd_isset_fails)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -440,7 +468,7 @@ TEST_FUNCTION(socket_transport_connect_fd_isset_fails)
|
|||
TEST_FUNCTION(socket_transport_connect_socket_transport_NULL_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -464,7 +492,7 @@ TEST_FUNCTION(socket_transport_connect_invalid_arguments_hostname)
|
|||
umock_c_negative_tests_snapshot();
|
||||
|
||||
//act
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
int result = socket_transport_connect(socket_handle, NULL, TEST_PORT, TEST_CONNECTION_TIMEOUT);
|
||||
|
||||
//assert
|
||||
|
@ -485,7 +513,7 @@ TEST_FUNCTION(socket_transport_connect_invalid_arguments_fail_port)
|
|||
umock_c_negative_tests_snapshot();
|
||||
|
||||
//act
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
int result = socket_transport_connect(socket_handle, TEST_HOSTNAME, 0, TEST_CONNECTION_TIMEOUT);
|
||||
|
||||
//assert
|
||||
|
@ -503,7 +531,7 @@ TEST_FUNCTION(socket_transport_connect_fail_sockettransporttype)
|
|||
//arrange
|
||||
STRICT_EXPECTED_CALL(malloc(IGNORED_ARG));
|
||||
STRICT_EXPECTED_CALL(sm_create(IGNORED_ARG));
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
umock_c_negative_tests_snapshot();
|
||||
|
||||
//act
|
||||
|
@ -524,7 +552,7 @@ TEST_FUNCTION(socket_transport_connect_sm_open_begin_fail)
|
|||
//arrange
|
||||
STRICT_EXPECTED_CALL(malloc(IGNORED_ARG));
|
||||
STRICT_EXPECTED_CALL(sm_create(IGNORED_ARG));
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
STRICT_EXPECTED_CALL(sm_open_begin(IGNORED_ARG))
|
||||
.SetReturn(SM_EXEC_REFUSED);
|
||||
umock_c_negative_tests_snapshot();
|
||||
|
@ -544,7 +572,7 @@ TEST_FUNCTION(socket_transport_connect_sm_open_begin_fail)
|
|||
TEST_FUNCTION(socket_transport_connect_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -580,7 +608,7 @@ TEST_FUNCTION(socket_transport_connect_fail)
|
|||
TEST_FUNCTION(socket_transport_connect_fd_isset_succeeds)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -616,7 +644,7 @@ TEST_FUNCTION(socket_transport_connect_fd_isset_succeeds)
|
|||
TEST_FUNCTION(socket_transport_connect_succeed)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -661,7 +689,7 @@ TEST_FUNCTION(socket_transport_disconnect_invalid_arguments)
|
|||
TEST_FUNCTION(socket_transport_disconnect_shutdown_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -691,7 +719,7 @@ TEST_FUNCTION(socket_transport_disconnect_shutdown_fail)
|
|||
TEST_FUNCTION(socket_transport_disconnect_failure_closesocket)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -723,7 +751,7 @@ TEST_FUNCTION(socket_transport_disconnect_failure_closesocket)
|
|||
TEST_FUNCTION(socket_transport_disconnect_binding_socket_closesocket)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -754,7 +782,7 @@ TEST_FUNCTION(socket_transport_disconnect_binding_socket_closesocket)
|
|||
TEST_FUNCTION(socket_transport_disconnect_sm_close_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -779,7 +807,7 @@ TEST_FUNCTION(socket_transport_disconnect_sm_close_fail)
|
|||
TEST_FUNCTION(socket_transport_disconnect_succeed)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -827,7 +855,7 @@ TEST_FUNCTION(socket_transport_send_fail_socket_transport_NULL)
|
|||
TEST_FUNCTION(socket_transport_send_fail_payload_NULL)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -855,7 +883,7 @@ TEST_FUNCTION(socket_transport_send_fail_payload_NULL)
|
|||
TEST_FUNCTION(socket_transport_send_fail_buffercount_zero)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -883,7 +911,7 @@ TEST_FUNCTION(socket_transport_send_fail_buffercount_zero)
|
|||
TEST_FUNCTION(socket_transport_send_fail_sm_exec_begin)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -913,7 +941,7 @@ TEST_FUNCTION(socket_transport_send_fail_sm_exec_begin)
|
|||
TEST_FUNCTION(socket_transport_send_fail_WSASend)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -948,7 +976,7 @@ TEST_FUNCTION(socket_transport_send_fail_WSASend)
|
|||
TEST_FUNCTION(socket_transport_send_succeed)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -997,7 +1025,7 @@ TEST_FUNCTION(socket_transport_receive_socket_transport_NULL_fail)
|
|||
TEST_FUNCTION(socket_transport_receive_payload_NULL_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -1020,7 +1048,7 @@ TEST_FUNCTION(socket_transport_receive_payload_NULL_fail)
|
|||
TEST_FUNCTION(socket_transport_receive_buffer_count_0_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -1045,7 +1073,7 @@ TEST_FUNCTION(socket_transport_receive_buffer_count_0_fail)
|
|||
TEST_FUNCTION(socket_transport_receive_sm_exec_begin_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -1075,7 +1103,7 @@ TEST_FUNCTION(socket_transport_receive_sm_exec_begin_fail)
|
|||
TEST_FUNCTION(socket_transport_receive_socket_receive_would_block)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -1108,7 +1136,7 @@ TEST_FUNCTION(socket_transport_receive_socket_receive_would_block)
|
|||
TEST_FUNCTION(socket_transport_receive_socket_receive_error)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -1145,7 +1173,7 @@ TEST_FUNCTION(socket_transport_receive_socket_receive_error)
|
|||
TEST_FUNCTION(socket_transport_receive_succeed)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_connect(socket_handle, TEST_HOSTNAME, TEST_PORT, TEST_CONNECTION_TIMEOUT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -1182,7 +1210,7 @@ TEST_FUNCTION(socket_transport_receive_succeed)
|
|||
TEST_FUNCTION(socket_transport_listen_succeed)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -1225,7 +1253,7 @@ TEST_FUNCTION(socket_transport_listen_socket_transport_NULL_fail)
|
|||
TEST_FUNCTION(socket_transport_listen_port_0_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -1244,7 +1272,7 @@ TEST_FUNCTION(socket_transport_listen_port_0_fail)
|
|||
TEST_FUNCTION(socket_transport_listen_invalid_socket_type_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -1263,7 +1291,7 @@ TEST_FUNCTION(socket_transport_listen_invalid_socket_type_fail)
|
|||
TEST_FUNCTION(socket_transport_listen_sm_open_not_granted_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -1285,7 +1313,7 @@ TEST_FUNCTION(socket_transport_listen_sm_open_not_granted_fail)
|
|||
TEST_FUNCTION(socket_transport_listen_socket_create_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -1308,7 +1336,7 @@ TEST_FUNCTION(socket_transport_listen_socket_create_fail)
|
|||
TEST_FUNCTION(socket_transport_listen_socket_bind_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -1335,7 +1363,7 @@ TEST_FUNCTION(socket_transport_listen_socket_bind_fail)
|
|||
TEST_FUNCTION(socket_transport_listen_socket_ioctlsocket_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -1363,7 +1391,7 @@ TEST_FUNCTION(socket_transport_listen_socket_ioctlsocket_fail)
|
|||
TEST_FUNCTION(socket_transport_listen_socket_listen_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -1392,7 +1420,7 @@ TEST_FUNCTION(socket_transport_listen_socket_listen_fail)
|
|||
TEST_FUNCTION(socket_transport_listen_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -1431,7 +1459,7 @@ TEST_FUNCTION(socket_transport_listen_fail)
|
|||
TEST_FUNCTION(socket_transport_accept_succeed)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_listen(socket_handle, TEST_PORT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -1479,7 +1507,7 @@ TEST_FUNCTION(socket_transport_accept_null_input_fail)
|
|||
TEST_FUNCTION(socket_transport_accept_sockettransport_type_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_CLIENT);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_client();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
umock_c_negative_tests_snapshot();
|
||||
|
@ -1499,7 +1527,7 @@ TEST_FUNCTION(socket_transport_accept_sockettransport_type_fail)
|
|||
TEST_FUNCTION(socket_transport_accept_smexecbegin_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
umock_c_reset_all_calls();
|
||||
umock_c_negative_tests_snapshot();
|
||||
|
@ -1522,7 +1550,7 @@ TEST_FUNCTION(socket_transport_accept_smexecbegin_fail)
|
|||
TEST_FUNCTION(socket_transport_accept_select_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_listen(socket_handle, TEST_PORT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -1549,7 +1577,7 @@ TEST_FUNCTION(socket_transport_accept_select_fail)
|
|||
TEST_FUNCTION(socket_transport_accept_accept_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_listen(socket_handle, TEST_PORT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -1579,7 +1607,7 @@ TEST_FUNCTION(socket_transport_accept_accept_fail)
|
|||
TEST_FUNCTION(socket_transport_accept_malloc_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_listen(socket_handle, TEST_PORT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -1612,7 +1640,7 @@ TEST_FUNCTION(socket_transport_accept_malloc_fail)
|
|||
TEST_FUNCTION(socket_transport_accept_sm_create_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_listen(socket_handle, TEST_PORT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -1644,7 +1672,7 @@ TEST_FUNCTION(socket_transport_accept_sm_create_fail)
|
|||
TEST_FUNCTION(socket_transport_accept_sm_open_begin_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_listen(socket_handle, TEST_PORT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -1678,7 +1706,7 @@ TEST_FUNCTION(socket_transport_accept_sm_open_begin_fail)
|
|||
TEST_FUNCTION(socket_transport_accept_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_listen(socket_handle, TEST_PORT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -1708,7 +1736,7 @@ TEST_FUNCTION(socket_transport_accept_fail)
|
|||
TEST_FUNCTION(socket_transport_get_underlying_socket_succeed)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_listen(socket_handle, TEST_PORT));
|
||||
umock_c_reset_all_calls();
|
||||
|
@ -1732,7 +1760,7 @@ TEST_FUNCTION(socket_transport_get_underlying_socket_succeed)
|
|||
TEST_FUNCTION(socket_transport_get_underlying_socket_smexecbegin_fail)
|
||||
{
|
||||
//arrange
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create(SOCKET_BINDING);
|
||||
SOCKET_TRANSPORT_HANDLE socket_handle = socket_transport_create_server();
|
||||
ASSERT_IS_NOT_NULL(socket_handle);
|
||||
ASSERT_ARE_EQUAL(int, 0, socket_transport_listen(socket_handle, TEST_PORT));
|
||||
umock_c_reset_all_calls();
|
||||
|
|
Загрузка…
Ссылка в новой задаче