Use non-tentative IPv6 addresses in multi-device test

This update ensures multi-device offload tests retrieve only non-tentative IPv6 addresses,
preventing test caused by tentative addresses undergoing duplicate address detection.

Test: atest NetworkStaticLibHostPythonTests
Change-Id: Id2f61a34eda01a6e8e0457647229fe438a85c232
This commit is contained in:
Jimi Chen 2025-03-17 03:31:29 +00:00
commit 2bfe2654d1
3 changed files with 7 additions and 7 deletions

View file

@ -26,7 +26,7 @@ from net_tests_utils.host.python.apf_utils import (
get_apf_counter,
get_apf_counters_from_dumpsys,
get_ipv4_addresses,
get_ipv6_addresses,
get_non_tentative_ipv6_addresses,
get_hardware_address,
is_send_raw_packet_downstream_supported,
is_packet_capture_supported,

View file

@ -60,10 +60,10 @@ class ApfTestBase(multi_devices_test_base.MultiDevicesTestBase):
self.client_ipv4_addresses = apf_utils.get_ipv4_addresses(
self.clientDevice, self.client_iface_name
)
self.server_ipv6_addresses = apf_utils.get_ipv6_addresses(
self.server_ipv6_addresses = apf_utils.get_non_tentative_ipv6_addresses(
self.serverDevice, self.server_iface_name
)
self.client_ipv6_addresses = apf_utils.get_ipv6_addresses(
self.client_ipv6_addresses = apf_utils.get_non_tentative_ipv6_addresses(
self.clientDevice, self.client_iface_name
)

View file

@ -116,12 +116,12 @@ def get_ipv4_addresses(
else:
return []
def get_ipv6_addresses(
def get_non_tentative_ipv6_addresses(
ad: android_device.AndroidDevice, iface_name: str
) -> list[str]:
"""Retrieves the IPv6 addresses of a given interface on an Android device.
"""Retrieves the non-tentative IPv6 addresses of a given interface on an Android device.
This function executes an ADB shell command (`ip -6 address show`) to get the
This function executes an ADB shell command (`ip -6 address show -tentative`) to get the
network interface information and extracts the IPv6 address from the output.
If devices have no IPv6 address, raise PatternNotFoundException.
@ -139,7 +139,7 @@ def get_ipv6_addresses(
# valid_lft forever preferred_lft forever
# inet6 fe80::1233:aadb:3d32:1234/64 scope link
# valid_lft forever preferred_lft forever
output = adb_utils.adb_shell(ad, f"ip -6 address show {iface_name}")
output = adb_utils.adb_shell(ad, f"ip -6 address show -tentative {iface_name}")
pattern = r"inet6\s+([0-9a-fA-F:]+)\/\d+"
matches = re.findall(pattern, output)