Add multicast address cleanup for test failures
This change ensures cleanup to release multicast addresses allocated during the test when a test failure occurs.
Without this cleanup, failed tests could potentially causing issues in subsequent test runs.
Test: atest CtsConnectivityMultiDevicesTestCases
Change-Id: Idf8349c8c075cec8007f5041b1ed8812a006f7f4
diff --git a/tests/cts/multidevices/apfv6_test.py b/tests/cts/multidevices/apfv6_test.py
index 2404966..9b2e309 100644
--- a/tests/cts/multidevices/apfv6_test.py
+++ b/tests/cts/multidevices/apfv6_test.py
@@ -190,15 +190,18 @@
igmp = IGMPv3mr(records=mcast_records)
expected_igmpv3_report = bytes(ether/ip/igmpv3_hdr/igmp).hex()
- self.send_packet_and_expect_reply_received(
- igmpv3_general_query, "DROPPED_IGMP_V3_GENERAL_QUERY_REPLIED", expected_igmpv3_report
- )
-
- for addr in mcast_addrs:
- adb_utils.adb_shell(
- self.clientDevice,
- f'ip addr del {addr}/32 dev {self.client_iface_name}'
+ try:
+ self.send_packet_and_expect_reply_received(
+ igmpv3_general_query,
+ "DROPPED_IGMP_V3_GENERAL_QUERY_REPLIED",
+ expected_igmpv3_report
)
+ finally:
+ for addr in mcast_addrs:
+ adb_utils.adb_shell(
+ self.clientDevice,
+ f'ip addr del {addr}/32 dev {self.client_iface_name}'
+ )
@apf_utils.at_least_B()
@apf_utils.apf_ram_at_least(3000)