[PATCH 2/2] tests: extend GAS tests to support dedicated P2P device
Andrei Otcheretianski
andrei.otcheretianski at intel.com
Mon Aug 21 09:37:12 PDT 2017
When a dedicated P2P device is used, MGMT_TX/RX should be done
explicitly on the P2P device interface.
Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski at intel.com>
---
tests/hwsim/test_gas.py | 29 ++++++++++++++---------------
tests/hwsim/wpasupplicant.py | 11 +++++++++--
2 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/tests/hwsim/test_gas.py b/tests/hwsim/test_gas.py
index db0ca6a..1d31df1 100644
--- a/tests/hwsim/test_gas.py
+++ b/tests/hwsim/test_gas.py
@@ -995,7 +995,7 @@ def test_gas_max_pending(dev, apdev):
raise Exception("Failed to set listen channel")
if "OK" not in wpas.p2p_listen():
raise Exception("Failed to start listen state")
- if "FAIL" in wpas.request("SET ext_mgmt_frame_handling 1"):
+ if "FAIL" in wpas.global_request("SET ext_mgmt_frame_handling 1"):
raise Exception("Failed to enable external management frame handling")
anqp_query = struct.pack('<HHHHHHHHHH', 256, 16, 257, 258, 260, 261, 262, 263, 264, 268)
@@ -1005,9 +1005,9 @@ def test_gas_max_pending(dev, apdev):
msg = struct.pack('<BBB', ACTION_CATEG_PUBLIC, GAS_INITIAL_REQUEST,
dialog_token) + anqp_adv_proto() + gas
req = "MGMT_TX {} {} freq=2412 wait_time=10 action={}".format(bssid, bssid, binascii.hexlify(msg))
- if "OK" not in wpas.request(req):
+ if "OK" not in wpas.p2pdev_request(req):
raise Exception("Could not send management frame")
- resp = wpas.mgmt_rx()
+ resp = wpas.mgmt_rx(p2p_dev=True)
if resp is None:
raise Exception("MGMT-RX timeout")
if 'payload' not in resp:
@@ -1032,14 +1032,14 @@ def test_gas_no_pending(dev, apdev):
raise Exception("Failed to set listen channel")
if "OK" not in wpas.p2p_listen():
raise Exception("Failed to start listen state")
- if "FAIL" in wpas.request("SET ext_mgmt_frame_handling 1"):
+ if "FAIL" in wpas.global_request("SET ext_mgmt_frame_handling 1"):
raise Exception("Failed to enable external management frame handling")
msg = struct.pack('<BBB', ACTION_CATEG_PUBLIC, GAS_COMEBACK_REQUEST, 1)
req = "MGMT_TX {} {} freq=2412 wait_time=10 action={}".format(bssid, bssid, binascii.hexlify(msg))
- if "OK" not in wpas.request(req):
+ if "OK" not in wpas.p2pdev_request(req):
raise Exception("Could not send management frame")
- resp = wpas.mgmt_rx()
+ resp = wpas.mgmt_rx(p2p_dev=True)
if resp is None:
raise Exception("MGMT-RX timeout")
if 'payload' not in resp:
@@ -1743,9 +1743,8 @@ def test_gas_server_oom(dev, apdev):
req = "MGMT_TX {} {} freq=2412 wait_time=10 action={}".format(bssid, bssid, binascii.hexlify(msg))
with alloc_fail(hapd, 1,
"gas_anqp_build_comeback_resp_buf;gas_serv_rx_gas_comeback_req"):
- if "OK" not in wpas.request(req):
+ if "OK" not in wpas.p2pdev_request(req):
raise Exception("Could not send management frame")
- wait_fail_trigger(hapd, "GET_ALLOC_FAIL")
def test_gas_anqp_overrides(dev, apdev):
"""GAS and ANQP overrides"""
@@ -1787,7 +1786,7 @@ def test_gas_no_dialog_token_match(dev, apdev):
raise Exception("Failed to set listen channel")
if "OK" not in wpas.p2p_listen():
raise Exception("Failed to start listen state")
- if "FAIL" in wpas.request("SET ext_mgmt_frame_handling 1"):
+ if "FAIL" in wpas.global_request("SET ext_mgmt_frame_handling 1"):
raise Exception("Failed to enable external management frame handling")
anqp_query = struct.pack('<HHHHHHHHHH', 256, 16, 257, 258, 260, 261, 262, 263, 264, 268)
@@ -1797,9 +1796,9 @@ def test_gas_no_dialog_token_match(dev, apdev):
msg = struct.pack('<BBB', ACTION_CATEG_PUBLIC, GAS_INITIAL_REQUEST,
dialog_token) + anqp_adv_proto() + gas
req = "MGMT_TX {} {} freq=2412 wait_time=10 action={}".format(bssid, bssid, binascii.hexlify(msg))
- if "OK" not in wpas.request(req):
+ if "OK" not in wpas.p2pdev_request(req):
raise Exception("Could not send management frame")
- resp = wpas.mgmt_rx()
+ resp = wpas.mgmt_rx(p2p_dev=True)
if resp is None:
raise Exception("MGMT-RX timeout")
if 'payload' not in resp:
@@ -1814,9 +1813,9 @@ def test_gas_no_dialog_token_match(dev, apdev):
msg = struct.pack('<BBB', ACTION_CATEG_PUBLIC, GAS_COMEBACK_REQUEST,
dialog_token + 1)
req = "MGMT_TX {} {} freq=2412 wait_time=10 action={}".format(bssid, bssid, binascii.hexlify(msg))
- if "OK" not in wpas.request(req):
+ if "OK" not in wpas.p2pdev_request(req):
raise Exception("Could not send management frame")
- resp = wpas.mgmt_rx()
+ resp = wpas.mgmt_rx(p2p_dev=True)
if resp is None:
raise Exception("MGMT-RX timeout")
if 'payload' not in resp:
@@ -1899,8 +1898,8 @@ def test_gas_vendor_spec_errors(dev, apdev):
tests = [ msg, msg2, msg3, msg4, msg5, msg6 ]
for t in tests:
req = "MGMT_TX {} {} freq=2412 wait_time=10 action={}".format(bssid, bssid, binascii.hexlify(t))
- if "OK" not in wpas.request(req):
+ if "OK" not in wpas.p2pdev_request(req):
raise Exception("Could not send management frame")
- ev = wpas.wait_event(["MGMT-TX-STATUS"], timeout=5)
+ ev = wpas.wait_global_event(["MGMT-TX-STATUS"], timeout=5)
if ev is None:
raise Exception("No ACK frame seen")
diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py
index 6ca45ab..fe8865c 100644
--- a/tests/hwsim/wpasupplicant.py
+++ b/tests/hwsim/wpasupplicant.py
@@ -1225,12 +1225,19 @@ class WpaSupplicant:
vals[name] = value
return vals
- def mgmt_rx(self, timeout=5):
- ev = self.wait_event(["MGMT-RX"], timeout=timeout)
+ def mgmt_rx(self, timeout=5, p2p_dev=False):
+ if p2p_dev:
+ ev = self.wait_global_event(["MGMT-RX"], timeout=timeout)
+ else:
+ ev = self.wait_event(["MGMT-RX"], timeout=timeout)
if ev is None:
return None
msg = {}
items = ev.split(' ')
+ if p2p_dev:
+ #strip out the IFNAME=<ifname>
+ items.pop(0)
+
field,val = items[1].split('=')
if field != "freq":
raise Exception("Unexpected MGMT-RX event format: " + ev)
--
2.7.4
More information about the Hostap
mailing list