mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-05 09:17:44 +03:00
test: fix failing test-socket-util when running with ipv6.disable=1 kernel param
The ability to use inet_pton(AF_INET6, ...) doesn't depend on kernel ipv6 support (inet_pton is a pure libc function), so make ipv6 address parsing tests unconditional.
This commit is contained in:
parent
3116c225d2
commit
4ebc62ec87
@ -41,28 +41,25 @@ static void test_socket_address_parse(void) {
|
||||
|
||||
assert_se(socket_address_parse(&a, "65535") >= 0);
|
||||
|
||||
if (socket_ipv6_is_supported()) {
|
||||
assert_se(socket_address_parse(&a, "[::1]") < 0);
|
||||
assert_se(socket_address_parse(&a, "[::1]8888") < 0);
|
||||
assert_se(socket_address_parse(&a, "::1") < 0);
|
||||
assert_se(socket_address_parse(&a, "[::1]:0") < 0);
|
||||
assert_se(socket_address_parse(&a, "[::1]:65536") < 0);
|
||||
assert_se(socket_address_parse(&a, "[a:b:1]:8888") < 0);
|
||||
/* The checks below will pass even if ipv6 is disabled in
|
||||
* kernel. The underlying glibc's inet_pton() is just a string
|
||||
* parser and doesn't make any syscalls. */
|
||||
|
||||
assert_se(socket_address_parse(&a, "8888") >= 0);
|
||||
assert_se(a.sockaddr.sa.sa_family == AF_INET6);
|
||||
assert_se(socket_address_parse(&a, "[::1]") < 0);
|
||||
assert_se(socket_address_parse(&a, "[::1]8888") < 0);
|
||||
assert_se(socket_address_parse(&a, "::1") < 0);
|
||||
assert_se(socket_address_parse(&a, "[::1]:0") < 0);
|
||||
assert_se(socket_address_parse(&a, "[::1]:65536") < 0);
|
||||
assert_se(socket_address_parse(&a, "[a:b:1]:8888") < 0);
|
||||
|
||||
assert_se(socket_address_parse(&a, "[2001:0db8:0000:85a3:0000:0000:ac1f:8001]:8888") >= 0);
|
||||
assert_se(a.sockaddr.sa.sa_family == AF_INET6);
|
||||
assert_se(socket_address_parse(&a, "8888") >= 0);
|
||||
assert_se(a.sockaddr.sa.sa_family == (socket_ipv6_is_supported() ? AF_INET6 : AF_INET));
|
||||
|
||||
assert_se(socket_address_parse(&a, "[::1]:8888") >= 0);
|
||||
assert_se(a.sockaddr.sa.sa_family == AF_INET6);
|
||||
} else {
|
||||
assert_se(socket_address_parse(&a, "[::1]:8888") < 0);
|
||||
assert_se(socket_address_parse(&a, "[2001:0db8:0000:85a3:0000:0000:ac1f:8001]:8888") >= 0);
|
||||
assert_se(a.sockaddr.sa.sa_family == AF_INET6);
|
||||
|
||||
assert_se(socket_address_parse(&a, "8888") >= 0);
|
||||
assert_se(a.sockaddr.sa.sa_family == AF_INET);
|
||||
}
|
||||
assert_se(socket_address_parse(&a, "[::1]:8888") >= 0);
|
||||
assert_se(a.sockaddr.sa.sa_family == AF_INET6);
|
||||
|
||||
assert_se(socket_address_parse(&a, "192.168.1.254:8888") >= 0);
|
||||
assert_se(a.sockaddr.sa.sa_family == AF_INET);
|
||||
|
Loading…
Reference in New Issue
Block a user