mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-10 01:17:44 +03:00
test: add support for in_addr_is_multicast tests
This commit is contained in:
parent
85257f48be
commit
1703b20374
@ -456,6 +456,23 @@ static void test_sockaddr_un_len(void) {
|
||||
assert_se(SOCKADDR_UN_LEN(abstract) == offsetof(struct sockaddr_un, sun_path) + 1 + strlen(abstract.sun_path + 1));
|
||||
}
|
||||
|
||||
static void test_in_addr_is_multicast(void) {
|
||||
union in_addr_union a, b;
|
||||
int f;
|
||||
|
||||
assert_se(in_addr_from_string_auto("192.168.3.11", &f, &a) >= 0);
|
||||
assert_se(in_addr_is_multicast(f, &a) == 0);
|
||||
|
||||
assert_se(in_addr_from_string_auto("224.0.0.1", &f, &a) >= 0);
|
||||
assert_se(in_addr_is_multicast(f, &a) == 1);
|
||||
|
||||
assert_se(in_addr_from_string_auto("FF01:0:0:0:0:0:0:1", &f, &b) >= 0);
|
||||
assert_se(in_addr_is_multicast(f, &b) == 1);
|
||||
|
||||
assert_se(in_addr_from_string_auto("2001:db8::c:69b:aeff:fe53:743e", &f, &b) >= 0);
|
||||
assert_se(in_addr_is_multicast(f, &b) == 0);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
log_set_max_level(LOG_DEBUG);
|
||||
@ -482,5 +499,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
test_sockaddr_un_len();
|
||||
|
||||
test_in_addr_is_multicast();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user