Debian Codegraph @

crt/aws-c-io/tests/io_lib_test.c

raw symbols SCIP
1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5
6 #include <aws/testing/aws_test_harness.h>
7
8 #include <aws/io/io.h>
9
10 /* Initialize this library and its dependencies.
11 * This will fail if:
12 * - the error info list is out of sync with the error enums.
13 * - there is a memory leak */
14 static int s_test_io_library_init(struct aws_allocator *allocator, void *ctx) {
15 (void)allocator;
16 (void)ctx;
17
18 aws_io_library_init(allocator);
19 aws_io_library_clean_up();
20 return AWS_OP_SUCCESS;
21 }
22 AWS_TEST_CASE(io_library_init, s_test_io_library_init)
23
24 /* Ensure the library can go through the init/cleanup cycle multiple times */
25 static int s_test_io_library_init_cleanup_init_cleanup(struct aws_allocator *allocator, void *ctx) {
26 (void)allocator;
27 (void)ctx;
28
29 aws_io_library_init(allocator);
30 aws_io_library_clean_up();
31
32 aws_io_library_init(allocator);
33 aws_io_library_clean_up();
34
35 return AWS_OP_SUCCESS;
36 }
37 AWS_TEST_CASE(io_library_init_cleanup_init_cleanup, s_test_io_library_init_cleanup_init_cleanup)
38
39 /* Make sure that new error codes are being added to the end instead of in the middle. */
40 static int s_test_io_library_error_order(struct aws_allocator *allocator, void *ctx) {
41 (void)allocator;
42 (void)ctx;
43
44 aws_io_library_init(allocator);
45 // Checking against expected int values of the error codes.
46 // The checked error codes are the first, somewhere in the middle, and last as of this commit.
47 int error_code_initial = 1024;
48 int error_code_mid = 1067;
49 int error_code_end = 1194;
50
51 ASSERT_TRUE(error_code_initial == AWS_IO_CHANNEL_ERROR_ERROR_CANT_ACCEPT_INPUT);
52 ASSERT_TRUE(error_code_mid == AWS_IO_TLS_NEGOTIATION_TIMEOUT);
53 ASSERT_TRUE(error_code_end == AWS_IO_TLS_HOST_NAME_MISMATCH);
54 aws_io_library_clean_up();
55 return AWS_OP_SUCCESS;
56 }
57
58 AWS_TEST_CASE(io_library_error_order, s_test_io_library_error_order)