]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/test_ipaddr: always set ifa_flags
authorKefu Chai <kchai@redhat.com>
Mon, 19 Jul 2021 03:22:18 +0000 (11:22 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 19 Jul 2021 03:29:35 +0000 (11:29 +0800)
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 <kchai@redhat.com>
src/test/test_ipaddr.cc

index f98560f817d7e3445f170da14a1face44dd5bf1f..537441264758a0f148f8b62da2bd4208e6c45d86 100644 (file)
@@ -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;