From c4fcf028701cf82f67d08c3239eb67e3601e77de Mon Sep 17 00:00:00 2001 From: Jimi Chen Date: Thu, 24 Jul 2025 11:53:09 +0000 Subject: [PATCH] Make APF packet count assertion more robust Improve the APF test by changing the packet count assertion from `== 1` to `> matched_pkt_count_before_test`. This handles scenarios where the packet counter might already have a non-zero value or increment due to other traffic, making the test more reliable. The test now asserts that the specific test packet caused the counter to increase. Flag: EXEMPT test only Bug: 419427388 Test: atest CtsConnectivityMultiDevicesTestCases:ApfV6Test Change-Id: Id3c0de786e674214948e7030519fe25383c9958c --- staticlibs/testutils/host/python/apf_test_base.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/staticlibs/testutils/host/python/apf_test_base.py b/staticlibs/testutils/host/python/apf_test_base.py index 43ebaab81d..a2cb6249a8 100644 --- a/staticlibs/testutils/host/python/apf_test_base.py +++ b/staticlibs/testutils/host/python/apf_test_base.py @@ -140,6 +140,10 @@ class ApfTestBase(multi_devices_test_base.MultiDevicesTestBase): counter_name, ) + matched_pkt_count_before_test = apf_utils.get_matched_packet_counts( + self.serverDevice, self.server_iface_name, receive_packet + ) + # send 3 packets to prevent flaky test result for _ in range(3): apf_utils.send_raw_packet_downstream( @@ -150,7 +154,7 @@ class ApfTestBase(multi_devices_test_base.MultiDevicesTestBase): lambda: apf_utils.get_matched_packet_counts( self.serverDevice, self.server_iface_name, receive_packet ) - == 1, + > matched_pkt_count_before_test, # ensure the server device capturing the offload packet on the handler thread retry_interval_sec=3, )