Fix flaky XfrmControllerTest.
Several tests were comparing partially uninitialized structs.
Bug: 65495297
Test: runtest -x system/netd/server/netd_unit_test.cpp
Change-Id: Ia093b470e1119c1275615b569820d7ddf44fb8dd
diff --git a/server/XfrmControllerTest.cpp b/server/XfrmControllerTest.cpp
index 07db844..dea1584 100644
--- a/server/XfrmControllerTest.cpp
+++ b/server/XfrmControllerTest.cpp
@@ -157,11 +157,11 @@
EXPECT_EQ(AF_INET, userspi.info.sel.family);
- xfrm_address_t saddr;
+ xfrm_address_t saddr{};
inet_pton(AF_INET, "127.0.0.1", reinterpret_cast<void*>(&saddr));
EXPECT_EQ(0, memcmp(&saddr, &userspi.info.saddr, sizeof(xfrm_address_t)));
- xfrm_address_t daddr;
+ xfrm_address_t daddr{};
inet_pton(AF_INET, "8.8.8.8", reinterpret_cast<void*>(&daddr));
EXPECT_EQ(0, memcmp(&daddr, &userspi.info.id.daddr, sizeof(xfrm_address_t)));
@@ -206,11 +206,11 @@
EXPECT_EQ(AF_INET6, userspi.info.sel.family);
- xfrm_address_t saddr;
+ xfrm_address_t saddr{};
inet_pton(AF_INET6, "::1", reinterpret_cast<void*>(&saddr));
EXPECT_EQ(0, memcmp(&saddr, &userspi.info.saddr, sizeof(xfrm_address_t)));
- xfrm_address_t daddr;
+ xfrm_address_t daddr{};
inet_pton(AF_INET6, "2001:4860:4860::8888", reinterpret_cast<void*>(&daddr));
EXPECT_EQ(0, memcmp(&daddr, &userspi.info.id.daddr, sizeof(xfrm_address_t)));
@@ -378,7 +378,7 @@
netdutils::extract(nlMsgSlice, said);
EXPECT_EQ(htonl(DROID_SPI), said.spi);
- xfrm_address_t daddr;
+ xfrm_address_t daddr{};
inet_pton(AF_INET, "8.8.8.8", reinterpret_cast<void*>(&daddr));
EXPECT_EQ(0, memcmp(&daddr, &said.daddr, sizeof(xfrm_address_t)));