ClatUtils: add test GenerateIpv6AddressFailWithUlaSocketAddress
Used for increasing the test coverage of generateIpv6Address. For now, generateIpv6Address test coverage: 0% (0/27 lines) https://blackbox.googleplex.com/testsuite?branch=git_tm-mainline-prod-daily-release&target=mainline_modules_x86_coverage_r_released&testsuite=coverage%2Fmts_tethering_native_t_on_t&type=coverage This is not a realistic test. The generateIpv6Address functionality is not real verified. See also test MakeChecksumNeutral. TODO: remove this test once EthernetTetheringTest can test on mainline test coverage branch. Test: atest ClatUtils Change-Id: I8e4fbc5af2cd0dd0a1bb181388ea0d4b200baed3
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <linux/if_packet.h>
|
||||
#include <linux/if_tun.h>
|
||||
#include <netinet/in.h>
|
||||
#include "tun_interface.h"
|
||||
|
||||
extern "C" {
|
||||
@@ -182,6 +183,31 @@ TEST_F(ClatUtils, ConfigurePacketSocket) {
|
||||
v6Iface.destroy();
|
||||
}
|
||||
|
||||
// This is not a realistic test because we can't test generateIPv6Address here since it requires
|
||||
// manipulating routing, which we can't do without talking to the real netd on the system.
|
||||
// See test MakeChecksumNeutral.
|
||||
// TODO: remove this test once EthernetTetheringTest can test on mainline test coverage branch.
|
||||
TEST_F(ClatUtils, GenerateIpv6AddressFailWithUlaSocketAddress) {
|
||||
// Create an interface for generateIpv6Address to connect to.
|
||||
TunInterface tun;
|
||||
ASSERT_EQ(0, tun.init());
|
||||
|
||||
// Unused because v6 address is ULA and makeChecksumNeutral has never called.
|
||||
in_addr v4 = {inet_addr(kIPv4LocalAddr)};
|
||||
// Not a NAT64 prefix because test can't connect to in generateIpv6Address.
|
||||
// Used to be a fake address from the tun interface for generating an IPv6 socket address.
|
||||
// nat64Prefix won't be used in MakeChecksumNeutral because MakeChecksumNeutral has never
|
||||
// be called.
|
||||
in6_addr nat64Prefix = tun.dstAddr(); // not realistic
|
||||
in6_addr v6;
|
||||
EXPECT_EQ(1, inet_pton(AF_INET6, "::", &v6)); // initialize as zero
|
||||
|
||||
EXPECT_EQ(-ENETUNREACH, generateIpv6Address(tun.name().c_str(), v4, nat64Prefix, &v6));
|
||||
EXPECT_TRUE(IN6_IS_ADDR_ULA(&v6));
|
||||
|
||||
tun.destroy();
|
||||
}
|
||||
|
||||
} // namespace clat
|
||||
} // namespace net
|
||||
} // namespace android
|
||||
|
||||
Reference in New Issue
Block a user