diff mbox series

[2/3] tests: Insert sleep after DATA_TEST_FRAME where needed

Message ID 20240927093622.883806-2-benjamin@sipsolutions.net
State Accepted
Headers show
Series [1/3] tests: Fix race condition in test_fst_setup_mbie_diff | expand

Commit Message

Benjamin Berg Sept. 27, 2024, 9:36 a.m. UTC
From: Benjamin Berg <benjamin.berg@intel.com>

If the frame is not fully processed the neighbor entries of the bridge
will not yet be updated. Add a sleep to ensure that the tests are not
racy.

Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
---
 tests/hwsim/test_ap_hs20.py     | 13 +++++++++++--
 tests/hwsim/test_hs20_filter.py |  6 ++++++
 2 files changed, 17 insertions(+), 2 deletions(-)

Comments

Jouni Malinen Dec. 19, 2024, 11:35 p.m. UTC | #1
On Fri, Sep 27, 2024 at 11:36:21AM +0200, Benjamin Berg wrote:
> If the frame is not fully processed the neighbor entries of the bridge
> will not yet be updated. Add a sleep to ensure that the tests are not
> racy.

Thanks, I applied all three patches, but dropping this reordering of the
validation steps since it is not really related to this commit message
and does not seem to make any real difference in the end:

> -    if len(matches) != 3:
> -        raise Exception("Unexpected number of neighbor entries after connect")
>      if 'aaaa:bbbb:cccc::2 dev ap-br0 lladdr 02:00:00:00:00:00 PERMANENT' not in matches:
>          raise Exception("dev0 addr missing")
>      if 'aaaa:bbbb:dddd::2 dev ap-br0 lladdr 02:00:00:00:01:00 PERMANENT' not in matches:
>          raise Exception("dev1 addr(1) missing")
>      if 'aaaa:bbbb:eeee::2 dev ap-br0 lladdr 02:00:00:00:01:00 PERMANENT' not in matches:
>          raise Exception("dev1 addr(2) missing")
> +    if len(matches) != 3:
diff mbox series

Patch

diff --git a/tests/hwsim/test_ap_hs20.py b/tests/hwsim/test_ap_hs20.py
index 35cb0b8fe9..8b6359113e 100644
--- a/tests/hwsim/test_ap_hs20.py
+++ b/tests/hwsim/test_ap_hs20.py
@@ -4357,16 +4357,19 @@  def _test_ap_hs20_proxyarp(dev, apdev):
     if "OK" not in dev[1].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
         raise Exception("DATA_TEST_FRAME failed")
 
+    # Wait for frames to be processed
+    time.sleep(0.1)
+
     matches = get_permanent_neighbors("ap-br0")
     logger.info("After connect: " + str(matches))
-    if len(matches) != 3:
-        raise Exception("Unexpected number of neighbor entries after connect")
     if 'aaaa:bbbb:cccc::2 dev ap-br0 lladdr 02:00:00:00:00:00 PERMANENT' not in matches:
         raise Exception("dev0 addr missing")
     if 'aaaa:bbbb:dddd::2 dev ap-br0 lladdr 02:00:00:00:01:00 PERMANENT' not in matches:
         raise Exception("dev1 addr(1) missing")
     if 'aaaa:bbbb:eeee::2 dev ap-br0 lladdr 02:00:00:00:01:00 PERMANENT' not in matches:
         raise Exception("dev1 addr(2) missing")
+    if len(matches) != 3:
+        raise Exception("Unexpected number of neighbor entries after connect")
     dev[0].request("DISCONNECT")
     dev[1].request("DISCONNECT")
     time.sleep(0.5)
@@ -4489,6 +4492,9 @@  def _test_ap_hs20_proxyarp_dgaf(dev, apdev, disabled):
     if "OK" not in hapd.request("DATA_TEST_FRAME ifname=ap-br0 " + binascii.hexlify(pkt).decode()):
         raise Exception("DATA_TEST_FRAME failed")
 
+    # Wait for frames to be processed
+    time.sleep(0.1)
+
     matches = get_permanent_neighbors("ap-br0")
     logger.info("After connect: " + str(matches))
     if len(matches) != 2:
@@ -4949,6 +4955,9 @@  def _test_proxyarp_open(dev, apdev, params, ebtables=False):
     if "OK" not in hapd.request("DATA_TEST_FRAME ifname=ap-br0 " + binascii.hexlify(pkt).decode()):
         raise Exception("DATA_TEST_FRAME failed")
 
+    # Wait for frames to be processed
+    time.sleep(0.1)
+
     macs = get_bridge_macs("ap-br0")
     logger.info("After connect (showmacs): " + str(macs))
 
diff --git a/tests/hwsim/test_hs20_filter.py b/tests/hwsim/test_hs20_filter.py
index 11cf347563..b916da567e 100644
--- a/tests/hwsim/test_hs20_filter.py
+++ b/tests/hwsim/test_hs20_filter.py
@@ -172,6 +172,9 @@  def test_ip4_drop_gratuitous_arp(devs, apdevs, params):
             if "OK" not in hapd.request('DATA_TEST_FRAME ' + pkt):
                 raise Exception("DATA_TEST_FRAME failed")
 
+            # Wait for frames to be processed
+            time.sleep(0.1)
+
             if hapd.own_addr() in subprocess.check_output(['ip', 'neigh', 'show']).decode():
                 raise Exception("gratuitous ARP frame updated erroneously")
         finally:
@@ -199,6 +202,9 @@  def test_ip6_drop_unsolicited_na(devs, apdevs, params):
             if "OK" not in hapd.request('DATA_TEST_FRAME ' + pkt):
                 raise Exception("DATA_TEST_FRAME failed")
 
+            # Wait for frames to be processed
+            time.sleep(0.1)
+
             if hapd.own_addr() in subprocess.check_output(['ip', 'neigh', 'show']).decode():
                 raise Exception("unsolicited NA frame updated erroneously")
         finally: