| 1 |
// Copyright (c) Microsoft. All rights reserved. |
| 2 |
// Licensed under the MIT license. See LICENSE file in the project root for full license information. |
| 3 |
|
| 4 |
// This file is made an integral part of socket_async_ut.c with a #include. It |
| 5 |
// is broken out for readability. |
| 6 |
|
| 7 |
|
| 8 |
// These definitions provide parameters and pass / fail values for unit testing |
| 9 |
static int test_socket = (int)0x1; |
| 10 |
static uint16_t test_port = 0x5566; |
| 11 |
static uint32_t test_ipv4 = 0x11223344; |
| 12 |
|
| 13 |
char test_msg[] = "Send this"; |
| 14 |
|
| 15 |
#define BAD_BUFFER_COUNT 10000 |
| 16 |
#define RECV_FAIL_RETURN -1 |
| 17 |
#define RECV_ZERO_FLAGS 0 |
| 18 |
#define SEND_FAIL_RETURN -1 |
| 19 |
#define SEND_ZERO_FLAGS 0 |
| 20 |
#define SELECT_FAIL_RETURN -1 |
| 21 |
#define SOCKET_FAIL_RETURN -1 |
| 22 |
#define SETSOCKOPT_FAIL_RETURN -1 |
| 23 |
#define BIND_FAIL_RETURN -1 |
| 24 |
#define EXTENDED_ERROR_FAIL EACCES |
| 25 |
#define EXTENDED_ERROR_WAITING EAGAIN |
| 26 |
#define EXTENDED_ERROR_CONNECT_WAITING EINPROGRESS |
| 27 |
static size_t sizeof_int = sizeof(test_socket); |
| 28 |
|
| 29 |
typedef struct |
| 30 |
{ |
| 31 |
char * buffer; |
| 32 |
size_t size; |
| 33 |
size_t *returned_count; |
| 34 |
const char* fail_msg; |
| 35 |
|
| 36 |
} send_receive_parameters_t; |
| 37 |
|
| 38 |
void populate_s_r_parameters(send_receive_parameters_t* p, char* buffer, size_t size, size_t* returned_count, const char* fail_msg) |
| 39 |
{ |
| 40 |
p->buffer = buffer; |
| 41 |
p->size = size; |
| 42 |
p->returned_count = returned_count; |
| 43 |
p->fail_msg = fail_msg; |
| 44 |
} |