Netsock2 Unit Tests.
More...
Go to the source code of this file.
|
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Netsock2 test module" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, } |
|
static const struct ast_module_info * | ast_module_info = &__mod_info |
|
Netsock2 Unit Tests.
- Author
- Terry Wilson twils.nosp@m.on@d.nosp@m.igium.nosp@m..com
Definition in file test_netsock2.c.
◆ TEST_SPLIT_HOSTPORT
#define TEST_SPLIT_HOSTPORT |
( |
|
str, |
|
|
|
flags, |
|
|
|
expected_host, |
|
|
|
expected_port, |
|
|
|
expected_result |
|
) |
| |
◆ __reg_module()
static void __reg_module |
( |
void |
| ) |
|
|
static |
◆ __unreg_module()
static void __unreg_module |
( |
void |
| ) |
|
|
static |
◆ AST_MODULE_SELF_SYM()
◆ AST_TEST_DEFINE() [1/2]
Definition at line 44 of file test_netsock2.c.
References ARRAY_LEN, ast_copy_string(), ast_sockaddr_cmp_addr(), ast_sockaddr_parse(), ast_sockaddr_stringify(), AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, buf, parse_test::expected_result, sip_to_pjsip::info(), TEST_EXECUTE, TEST_INIT, and tmp().
49 {
"10.255.255.254", 1 },
56 {
"1.2.3.4:5060", 1 },
57 {
"::ffff:5.6.7.8", 1 },
58 {
"fdf8:f53b:82e4::53", 1 },
59 {
"fe80::200:5aee:feaa:20a2", 1 },
61 {
"2001:0000:4136:e378:8000:63bf:3fff:fdd2", 1 },
62 {
"2001:0002:6c::430", 1 },
63 {
"2001:10:240:ab::a", 1 },
64 {
"2002:cb0a:3cdd:1::1", 1 },
65 {
"2001:db8:8:4::2", 1 },
66 {
"ff01:0:0:0:0:0:0:2", 1 },
67 {
"[fdf8:f53b:82e4::53]", 1 },
68 {
"[fe80::200:5aee:feaa:20a2]", 1 },
70 {
"[2001:0000:4136:e378:8000:63bf:3fff:fdd2]:5060", 1 },
71 {
"2001:0000:4136:e378:8000:63bf:3fff:fdd2:5060", 0 },
72 {
"fe80::200::abcd", 0 },
81 info->name =
"parsing";
82 info->category =
"/main/netsock2/";
83 info->summary =
"netsock2 parsing unit test";
85 "Test parsing of IPv4 and IPv6 network addresses";
91 for (x = 0; x <
ARRAY_LEN(test_vals); x++) {
92 memset(&addr, 0,
sizeof(addr));
94 ast_test_status_update(
test,
"On '%s' expected %d but got %d\n", test_vals[x].address, test_vals[x].expected_result, parse_result);
102 memset(&tmp_addr, 0,
sizeof(tmp_addr));
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)
Parse an IPv4 or IPv6 address string.
Socket address structure.
int ast_sockaddr_cmp_addr(const struct ast_sockaddr *a, const struct ast_sockaddr *b)
Compares the addresses of two ast_sockaddr structures.
#define ast_test_status_update(a, b, c...)
static char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
◆ AST_TEST_DEFINE() [2/2]
AST_TEST_DEFINE |
( |
split_hostport |
| ) |
|
Definition at line 116 of file test_netsock2.c.
References AST_TEST_NOT_RUN, AST_TEST_PASS, buf, host, sip_to_pjsip::info(), PARSE_PORT_FORBID, PARSE_PORT_IGNORE, PARSE_PORT_REQUIRE, TEST_EXECUTE, TEST_INIT, and TEST_SPLIT_HOSTPORT.
123 info->name =
"split_hostport";
124 info->category =
"/main/netsock2/";
125 info->summary =
"netsock2 ast_sockaddr_split_hostport() unit test";
127 "Test splitting of IPv4 and IPv6 host:port strings";
134 #define TEST_SPLIT_HOSTPORT(str, flags, expected_host, expected_port, expected_result) { \ 136 ast_copy_string(buf, str, sizeof(buf)); \ 137 if ((__res = ast_sockaddr_split_hostport(buf, &host, &port, flags)) != expected_result || ( \ 138 expected_result && ( \ 139 strcmp(host, expected_host) || ( \ 140 ast_strlen_zero(expected_port) ? !ast_strlen_zero(port) : (!ast_strlen_zero(port) && strcmp(port, expected_port)) \ 145 res = AST_TEST_FAIL; \ 146 if (__res != expected_result) { \ 147 ast_test_status_update(test, "Expected %d, got %d\n", expected_result, __res); \ 149 ast_test_status_update(test, "Failed parsing '%s' into expected host '%s' (got '%s') and port '%s' (got '%s')\n", \ 150 str, S_OR(expected_host, ""), host, expected_port, S_OR(port, "")); \ 163 TEST_SPLIT_HOSTPORT(
"[fe80::200:5aee:feaa:20a2]:5060", 0,
"fe80::200:5aee:feaa:20a2",
"5060", 1);
#define TEST_SPLIT_HOSTPORT(str, flags, expected_host, expected_port, expected_result)
◆ load_module()
static int load_module |
( |
void |
| ) |
|
|
static |
◆ unload_module()
static int unload_module |
( |
void |
| ) |
|
|
static |
◆ __mod_info
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Netsock2 test module" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, } |
|
static |
◆ ast_module_info