| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#include <aws/testing/io_testing_channel.h> |
| 6 |
|
| 7 |
static int s_test_io_testing_channel(struct aws_allocator *allocator, void *ctx) { |
| 8 |
(void)ctx; |
| 9 |
|
| 10 |
struct aws_testing_channel_options test_channel_options = {.clock_fn = aws_high_res_clock_get_ticks}; |
| 11 |
|
| 12 |
struct testing_channel testing_channel; |
| 13 |
ASSERT_SUCCESS(testing_channel_init(&testing_channel, allocator, &test_channel_options)); |
| 14 |
|
| 15 |
|
| 16 |
ASSERT_SUCCESS(testing_channel_install_downstream_handler(&testing_channel, 16 * 1024)); |
| 17 |
|
| 18 |
|
| 19 |
struct aws_io_message *read_msg = |
| 20 |
aws_channel_acquire_message_from_pool(testing_channel.channel, AWS_IO_MESSAGE_APPLICATION_DATA, 64); |
| 21 |
ASSERT_NOT_NULL(read_msg); |
| 22 |
ASSERT_SUCCESS(testing_channel_push_read_message(&testing_channel, read_msg)); |
| 23 |
|
| 24 |
struct aws_linked_list *read_queue = testing_channel_get_read_message_queue(&testing_channel); |
| 25 |
ASSERT_NOT_NULL(read_queue); |
| 26 |
ASSERT_FALSE(aws_linked_list_empty(read_queue)); |
| 27 |
ASSERT_PTR_EQUALS(&read_msg->queueing_handle, aws_linked_list_front(read_queue)); |
| 28 |
|
| 29 |
|
| 30 |
struct aws_io_message *write_msg = |
| 31 |
aws_channel_acquire_message_from_pool(testing_channel.channel, AWS_IO_MESSAGE_APPLICATION_DATA, 64); |
| 32 |
ASSERT_NOT_NULL(write_msg); |
| 33 |
ASSERT_SUCCESS(testing_channel_push_write_message(&testing_channel, write_msg)); |
| 34 |
|
| 35 |
struct aws_linked_list *write_queue = testing_channel_get_written_message_queue(&testing_channel); |
| 36 |
ASSERT_NOT_NULL(write_queue); |
| 37 |
ASSERT_FALSE(aws_linked_list_empty(write_queue)); |
| 38 |
ASSERT_PTR_EQUALS(&write_msg->queueing_handle, aws_linked_list_front(write_queue)); |
| 39 |
|
| 40 |
testing_channel_drain_queued_tasks(&testing_channel); |
| 41 |
|
| 42 |
ASSERT_SUCCESS(testing_channel_increment_read_window(&testing_channel, 12345)); |
| 43 |
testing_channel_drain_queued_tasks(&testing_channel); |
| 44 |
ASSERT_UINT_EQUALS(12345, testing_channel_last_window_update(&testing_channel)); |
| 45 |
|
| 46 |
|
| 47 |
ASSERT_SUCCESS(testing_channel_clean_up(&testing_channel)); |
| 48 |
return AWS_OP_SUCCESS; |
| 49 |
} |
| 50 |
|
| 51 |
AWS_TEST_CASE(io_testing_channel, s_test_io_testing_channel) |