summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorSusant Sahani <susant@redhat.com>2017-02-23 23:29:31 +0530
committerSusant Sahani <susant@redhat.com>2017-02-24 15:42:59 +0530
commit1703b2037410e324abe3c2b05a2667e864a6fd06 (patch)
treeb9a23f3f3f67adf373fdd7daca3529e0027637c8 /src/test
parent85257f48bedfec3c0fa6907c87caceee18ed1c94 (diff)
test: add support for in_addr_is_multicast tests
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-socket-util.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/test/test-socket-util.c b/src/test/test-socket-util.c
index d80613dc84..8ac1d7989f 100644
--- a/src/test/test-socket-util.c
+++ b/src/test/test-socket-util.c
@@ -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;
}