Debian Codegraph @

tests/isc/proxyudp_test.c

raw
1 /*
2 * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
3 *
4 * SPDX-License-Identifier: MPL-2.0
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, you can obtain one at https://mozilla.org/MPL/2.0/.
9 *
10 * See the COPYRIGHT file distributed with this work for additional
11 * information regarding copyright ownership.
12 */
13
14 #include <inttypes.h>
15 #include <sched.h> /* IWYU pragma: keep */
16 #include <setjmp.h>
17 #include <signal.h>
18 #include <stdarg.h>
19 #include <stdlib.h>
20 #include <unistd.h>
21
22 /*
23 * As a workaround, include an OpenSSL header file before including cmocka.h,
24 * because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a
25 * redefined malloc in cmocka.h.
26 */
27 #include <openssl/err.h>
28
29 #define UNIT_TESTING
30 #include <cmocka.h>
31
32 #include <isc/async.h>
33 #include <isc/job.h>
34 #include <isc/nonce.h>
35 #include <isc/os.h>
36 #include <isc/quota.h>
37 #include <isc/refcount.h>
38 #include <isc/sockaddr.h>
39 #include <isc/thread.h>
40 #include <isc/util.h>
41
42 #include "uv_wrap.h"
43 #define KEEP_BEFORE
44
45 #include "netmgr/socket.c"
46 #include "netmgr/udp.c"
47 #include "netmgr_common.h"
48 #include "uv.c"
49
50 #include <tests/isc.h>
51
52 static isc_nm_proxyheader_info_t custom_info;
53
54 char complete_proxy_data[] = { 0x0d, 0x0a, 0x0d, 0x0a, 0x00, 0x0d, 0x0a,
55 0x51, 0x55, 0x49, 0x54, 0x0a, 0x21, 0x12,
56 0x00, 0x0c, 0x01, 0x02, 0x03, 0x04, 0x04,
57 0x03, 0x02, 0x01, 0x14, 0xe9, 0x14, 0xe9 };
58
59 ISC_LOOP_TEST_IMPL(proxyudp_noop) { udp_noop(arg); }
60
61 ISC_LOOP_TEST_IMPL(proxyudp_noresponse) { udp_noresponse(arg); }
62
63 ISC_LOOP_TEST_IMPL(proxyudp_timeout_recovery) { udp_timeout_recovery(arg); }
64
65 ISC_LOOP_TEST_IMPL(proxyudp_shutdown_connect) { udp_shutdown_connect(arg); }
66
67 ISC_LOOP_TEST_IMPL(proxyudp_shutdown_read) { udp_shutdown_read(arg); }
68
69 ISC_LOOP_TEST_IMPL(proxyudp_cancel_read) { udp_cancel_read(arg); }
70
71 ISC_LOOP_TEST_IMPL(proxyudp_recv_one) { udp_recv_one(arg); }
72
73 ISC_LOOP_TEST_IMPL(proxyudp_recv_one_prerendered) {
74 isc_region_t header = { 0 };
75 header.base = (unsigned char *)complete_proxy_data;
76 header.length = sizeof(complete_proxy_data);
77
78 isc_nm_proxyheader_info_init_complete(&custom_info, &header);
79
80 set_proxyheader_info(&custom_info);
81
82 udp_recv_one(arg);
83 }
84
85 ISC_LOOP_TEST_IMPL(proxyudp_recv_two) { udp_recv_two(arg); }
86
87 ISC_LOOP_TEST_IMPL(proxyudp_recv_send) { udp_recv_send(arg); }
88
89 ISC_LOOP_TEST_IMPL(proxyudp_double_read) { udp_double_read(arg); }
90
91 ISC_TEST_LIST_START
92
93 ISC_TEST_ENTRY_CUSTOM(proxyudp_noop, proxyudp_noop_setup,
94 proxyudp_noop_teardown)
95 ISC_TEST_ENTRY_CUSTOM(proxyudp_noresponse, proxyudp_noresponse_setup,
96 proxyudp_noresponse_teardown)
97 ISC_TEST_ENTRY_CUSTOM(proxyudp_timeout_recovery,
98 proxyudp_timeout_recovery_setup,
99 proxyudp_timeout_recovery_teardown)
100 ISC_TEST_ENTRY_CUSTOM(proxyudp_shutdown_read, proxyudp_shutdown_read_setup,
101 proxyudp_shutdown_read_teardown)
102 ISC_TEST_ENTRY_CUSTOM(proxyudp_cancel_read, proxyudp_cancel_read_setup,
103 proxyudp_cancel_read_teardown)
104 ISC_TEST_ENTRY_CUSTOM(proxyudp_shutdown_connect,
105 proxyudp_shutdown_connect_setup,
106 proxyudp_shutdown_connect_teardown)
107 ISC_TEST_ENTRY_CUSTOM(proxyudp_double_read, proxyudp_double_read_setup,
108 proxyudp_double_read_teardown)
109 ISC_TEST_ENTRY_CUSTOM(proxyudp_recv_one, proxyudp_recv_one_setup,
110 proxyudp_recv_one_teardown)
111 ISC_TEST_ENTRY_CUSTOM(proxyudp_recv_one_prerendered, proxyudp_recv_one_setup,
112 proxyudp_recv_one_teardown)
113 ISC_TEST_ENTRY_CUSTOM(proxyudp_recv_two, proxyudp_recv_two_setup,
114 proxyudp_recv_two_teardown)
115 ISC_TEST_ENTRY_CUSTOM(proxyudp_recv_send, proxyudp_recv_send_setup,
116 proxyudp_recv_send_teardown)
117
118 ISC_TEST_LIST_END
119
120 ISC_TEST_MAIN