mirror of
https://github.com/samba-team/samba.git
synced 2025-01-31 01:48:16 +03:00
ctdb-tests: Add some testing for IPv4-mapped IPv6 address parsing
ctdb_sock_addr values are hashed in some contexts. This means that all of the memory used for the ctdb_sock_addr should be consistent regardless of how parsing is done. The first 2 cases are just sanity checks but the 3rd case involving an IPv4-mapped IPv6 address is the real target of this test addition. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13839 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@samba.org> (cherry picked from commit d9286701cd9253bf3b42cac3d850ae8c23743e6d)
This commit is contained in:
parent
02da215c10
commit
96a229b028
@ -52,6 +52,20 @@ static void test_sock_addr_from_string_bad(const char *ip, bool with_port)
|
||||
assert(ret == EINVAL);
|
||||
}
|
||||
|
||||
static void test_sock_addr_from_string_memcmp(const char *ip1,
|
||||
const char* ip2)
|
||||
{
|
||||
ctdb_sock_addr sa1, sa2;
|
||||
int ret;
|
||||
|
||||
ret = ctdb_sock_addr_from_string(ip1, &sa1, false);
|
||||
assert(ret == 0);
|
||||
ret = ctdb_sock_addr_from_string(ip2, &sa2, false);
|
||||
assert(ret == 0);
|
||||
ret = memcmp(&sa1, &sa2, sizeof(ctdb_sock_addr));
|
||||
assert(ret == 0);
|
||||
}
|
||||
|
||||
static void test_sock_addr_cmp(const char *ip1, const char *ip2,
|
||||
bool with_port, int res)
|
||||
{
|
||||
@ -299,6 +313,11 @@ int main(int argc, char *argv[])
|
||||
test_sock_addr_from_string_bad("junk", false);
|
||||
test_sock_addr_from_string_bad("0.0.0.0:0 trailing junk", true);
|
||||
|
||||
test_sock_addr_from_string_memcmp("127.0.0.1", "127.0.0.1");
|
||||
test_sock_addr_from_string_memcmp("fe80::6af7:28ff:fefa:d136",
|
||||
"fe80::6af7:28ff:fefa:d136");
|
||||
test_sock_addr_from_string_memcmp("::ffff:192.0.2.128", "192.0.2.128");
|
||||
|
||||
test_sock_addr_cmp("127.0.0.1", "127.0.0.1" , false, 0);
|
||||
test_sock_addr_cmp("127.0.0.1", "127.0.0.2" , false, -1);
|
||||
test_sock_addr_cmp("127.0.0.2", "127.0.0.1" , false, 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user