From 2bfe2654d19df77fb19ffe1e096daff3e0406cbe Mon Sep 17 00:00:00 2001 From: Jimi Chen Date: Mon, 17 Mar 2025 03:31:29 +0000 Subject: [PATCH] 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 --- staticlibs/tests/unit/host/python/apf_utils_test.py | 2 +- staticlibs/testutils/host/python/apf_test_base.py | 4 ++-- staticlibs/testutils/host/python/apf_utils.py | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/staticlibs/tests/unit/host/python/apf_utils_test.py b/staticlibs/tests/unit/host/python/apf_utils_test.py index 348df3bf83..8059e225de 100644 --- a/staticlibs/tests/unit/host/python/apf_utils_test.py +++ b/staticlibs/tests/unit/host/python/apf_utils_test.py @@ -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, diff --git a/staticlibs/testutils/host/python/apf_test_base.py b/staticlibs/testutils/host/python/apf_test_base.py index 2552aa39af..33b383841c 100644 --- a/staticlibs/testutils/host/python/apf_test_base.py +++ b/staticlibs/testutils/host/python/apf_test_base.py @@ -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 ) diff --git a/staticlibs/testutils/host/python/apf_utils.py b/staticlibs/testutils/host/python/apf_utils.py index c2ad18ef35..1648d36002 100644 --- a/staticlibs/testutils/host/python/apf_utils.py +++ b/staticlibs/testutils/host/python/apf_utils.py @@ -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)