File: proxyudp_test.c

package info (click to toggle)
bind9 1%3A9.20.20-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 43,788 kB
  • sloc: ansic: 316,296; sh: 49,693; python: 25,039; perl: 3,218; makefile: 2,247
file content (120 lines) | stat: -rw-r--r-- 3,764 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
 * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
 *
 * SPDX-License-Identifier: MPL-2.0
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, you can obtain one at https://mozilla.org/MPL/2.0/.
 *
 * See the COPYRIGHT file distributed with this work for additional
 * information regarding copyright ownership.
 */

#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <signal.h>
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>

/*
 * As a workaround, include an OpenSSL header file before including cmocka.h,
 * because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a
 * redefined malloc in cmocka.h.
 */
#include <openssl/err.h>

#define UNIT_TESTING
#include <cmocka.h>

#include <isc/async.h>
#include <isc/job.h>
#include <isc/nonce.h>
#include <isc/os.h>
#include <isc/quota.h>
#include <isc/refcount.h>
#include <isc/sockaddr.h>
#include <isc/thread.h>
#include <isc/util.h>

#include "uv_wrap.h"
#define KEEP_BEFORE

#include "netmgr/socket.c"
#include "netmgr/udp.c"
#include "netmgr_common.h"
#include "uv.c"

#include <tests/isc.h>

static isc_nm_proxyheader_info_t custom_info;

char complete_proxy_data[] = { 0x0d, 0x0a, 0x0d, 0x0a, 0x00, 0x0d, 0x0a,
			       0x51, 0x55, 0x49, 0x54, 0x0a, 0x21, 0x12,
			       0x00, 0x0c, 0x01, 0x02, 0x03, 0x04, 0x04,
			       0x03, 0x02, 0x01, 0x14, 0xe9, 0x14, 0xe9 };

ISC_LOOP_TEST_IMPL(proxyudp_noop) { udp_noop(arg); }

ISC_LOOP_TEST_IMPL(proxyudp_noresponse) { udp_noresponse(arg); }

ISC_LOOP_TEST_IMPL(proxyudp_timeout_recovery) { udp_timeout_recovery(arg); }

ISC_LOOP_TEST_IMPL(proxyudp_shutdown_connect) { udp_shutdown_connect(arg); }

ISC_LOOP_TEST_IMPL(proxyudp_shutdown_read) { udp_shutdown_read(arg); }

ISC_LOOP_TEST_IMPL(proxyudp_cancel_read) { udp_cancel_read(arg); }

ISC_LOOP_TEST_IMPL(proxyudp_recv_one) { udp_recv_one(arg); }

ISC_LOOP_TEST_IMPL(proxyudp_recv_one_prerendered) {
	isc_region_t header = { 0 };
	header.base = (unsigned char *)complete_proxy_data;
	header.length = sizeof(complete_proxy_data);

	isc_nm_proxyheader_info_init_complete(&custom_info, &header);

	set_proxyheader_info(&custom_info);

	udp_recv_one(arg);
}

ISC_LOOP_TEST_IMPL(proxyudp_recv_two) { udp_recv_two(arg); }

ISC_LOOP_TEST_IMPL(proxyudp_recv_send) { udp_recv_send(arg); }

ISC_LOOP_TEST_IMPL(proxyudp_double_read) { udp_double_read(arg); }

ISC_TEST_LIST_START

ISC_TEST_ENTRY_CUSTOM(proxyudp_noop, proxyudp_noop_setup,
		      proxyudp_noop_teardown)
ISC_TEST_ENTRY_CUSTOM(proxyudp_noresponse, proxyudp_noresponse_setup,
		      proxyudp_noresponse_teardown)
ISC_TEST_ENTRY_CUSTOM(proxyudp_timeout_recovery,
		      proxyudp_timeout_recovery_setup,
		      proxyudp_timeout_recovery_teardown)
ISC_TEST_ENTRY_CUSTOM(proxyudp_shutdown_read, proxyudp_shutdown_read_setup,
		      proxyudp_shutdown_read_teardown)
ISC_TEST_ENTRY_CUSTOM(proxyudp_cancel_read, proxyudp_cancel_read_setup,
		      proxyudp_cancel_read_teardown)
ISC_TEST_ENTRY_CUSTOM(proxyudp_shutdown_connect,
		      proxyudp_shutdown_connect_setup,
		      proxyudp_shutdown_connect_teardown)
ISC_TEST_ENTRY_CUSTOM(proxyudp_double_read, proxyudp_double_read_setup,
		      proxyudp_double_read_teardown)
ISC_TEST_ENTRY_CUSTOM(proxyudp_recv_one, proxyudp_recv_one_setup,
		      proxyudp_recv_one_teardown)
ISC_TEST_ENTRY_CUSTOM(proxyudp_recv_one_prerendered, proxyudp_recv_one_setup,
		      proxyudp_recv_one_teardown)
ISC_TEST_ENTRY_CUSTOM(proxyudp_recv_two, proxyudp_recv_two_setup,
		      proxyudp_recv_two_teardown)
ISC_TEST_ENTRY_CUSTOM(proxyudp_recv_send, proxyudp_recv_send_setup,
		      proxyudp_recv_send_teardown)

ISC_TEST_LIST_END

ISC_TEST_MAIN