From: Kefu Chai Date: Mon, 19 Jul 2021 03:22:18 +0000 (+0800) Subject: test/test_ipaddr: always set ifa_flags X-Git-Tag: v17.1.0~1365^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1701023d16b78f176ed8adb353446c78bdc5889f;p=ceph.git test/test_ipaddr: always set ifa_flags do not rely on the uninitialized bits on stack for testing, otherwise there is chance that we have following test failure: 64: ../src/test/test_ipaddr.cc:226: Failure 64: Expected equality of these values: 64: two.ifa_addr 64: Which is: 127.0.0.1:57677 64: result 64: Which is: 127.0.0.1:57677 the root cause is just that the "result" is actually `one.ifa_addr`, which is marked UP as that's what the uninitialized bits on stack indicate. Signed-off-by: Kefu Chai --- diff --git a/src/test/test_ipaddr.cc b/src/test/test_ipaddr.cc index f98560f817d..53744126475 100644 --- a/src/test/test_ipaddr.cc +++ b/src/test/test_ipaddr.cc @@ -191,6 +191,7 @@ TEST(CommonIPAddr, TestV4_SkipLoopback) struct sockaddr_in a_three; one.ifa_next = &two; + one.ifa_flags &= ~IFF_UP; one.ifa_addr = (struct sockaddr*)&a_one; one.ifa_name = lo; @@ -322,6 +323,7 @@ TEST(CommonIPAddr, TestV6_SkipLoopback) struct sockaddr_in6 a_three; one.ifa_next = &two; + one.ifa_flags &= ~IFF_UP; ipv6(&a_one, "::1"); one.ifa_addr = (struct sockaddr*)&a_one; one.ifa_name = lo;