Add BSS scan before connect for core associations
BSS scan and selection was moved to the policy layer, meaning for
core connections, the tests need to scan for and select a BSS
to pass to the connect call.
Small edits to WlanScanTest, which was written before the wlan_device
abstract device was created, and PolicyScanTest, which was using
the old core connect call.
Bug: None
Test: Ran affected tests.
Change-Id: I972806b4f80254998b31726c982071709a18f75b
diff --git a/acts/framework/acts/controllers/fuchsia_lib/wlan_lib.py b/acts/framework/acts/controllers/fuchsia_lib/wlan_lib.py
index 76b032c..8247041 100644
--- a/acts/framework/acts/controllers/fuchsia_lib/wlan_lib.py
+++ b/acts/framework/acts/controllers/fuchsia_lib/wlan_lib.py
@@ -17,6 +17,7 @@
from acts.controllers.fuchsia_lib.base_lib import BaseLib
COMMAND_SCAN = "wlan.scan"
+COMMAND_SCAN_FOR_BSS_INFO = "wlan.scan_for_bss_info"
COMMAND_CONNECT = "wlan.connect"
COMMAND_DISCONNECT = "wlan.disconnect"
COMMAND_STATUS = "wlan.status"
@@ -46,7 +47,23 @@
return self.send_command(test_id, test_cmd, {})
- def wlanConnectToNetwork(self, target_ssid, target_pwd=None):
+ def wlanScanForBSSInfo(self):
+ """ Scans and returns BSS info
+
+ Returns:
+ A dict mapping each seen SSID to a list of BSS Description IE
+ blocks, one for each BSS observed in the network
+ """
+ test_cmd = COMMAND_SCAN_FOR_BSS_INFO
+ test_id = self.build_id(self.test_counter)
+ self.test_counter += 1
+
+ return self.send_command(test_id, test_cmd, {})
+
+ def wlanConnectToNetwork(self,
+ target_ssid,
+ target_bss_desc,
+ target_pwd=None):
""" Triggers a network connection
Args:
target_ssid: the network to attempt a connection to
@@ -56,7 +73,11 @@
boolean indicating if the connection was successful
"""
test_cmd = COMMAND_CONNECT
- test_args = {"target_ssid": target_ssid, "target_pwd": target_pwd}
+ test_args = {
+ "target_ssid": target_ssid,
+ "target_pwd": target_pwd,
+ "target_bss_desc": target_bss_desc
+ }
test_id = self.build_id(self.test_counter)
self.test_counter += 1
diff --git a/acts_tests/acts_contrib/test_utils/abstract_devices/wlan_device.py b/acts_tests/acts_contrib/test_utils/abstract_devices/wlan_device.py
index 094f125..e213438 100644
--- a/acts_tests/acts_contrib/test_utils/abstract_devices/wlan_device.py
+++ b/acts_tests/acts_contrib/test_utils/abstract_devices/wlan_device.py
@@ -336,8 +336,22 @@
True if successfully connected to WLAN, False if not.
"""
if self.device.association_mechanism == 'drivers':
+ bss_scan_response = self.device.wlan_lib.wlanScanForBSSInfo()
+ if bss_scan_response.get('error'):
+ self.log.error('Scan for BSS info failed. Err: %s' %
+ bss_scan_response['error'])
+ return False
+
+ bss_descs_for_ssid = bss_scan_response['result'].get(
+ target_ssid, None)
+ if not bss_descs_for_ssid or len(bss_descs_for_ssid) < 1:
+ self.log.error(
+ 'Scan failed to find a BSS description for target_ssid %s'
+ % target_ssid)
+ return False
+
connection_response = self.device.wlan_lib.wlanConnectToNetwork(
- target_ssid, target_pwd=target_pwd)
+ target_ssid, bss_descs_for_ssid[0], target_pwd=target_pwd)
return self.device.check_connect_response(connection_response)
else:
return self.device.wlan_policy_controller.save_and_connect(
diff --git a/acts_tests/tests/google/fuchsia/wlan/functional/WlanScanTest.py b/acts_tests/tests/google/fuchsia/wlan/functional/WlanScanTest.py
index e9f085f..dda04a5 100644
--- a/acts_tests/tests/google/fuchsia/wlan/functional/WlanScanTest.py
+++ b/acts_tests/tests/google/fuchsia/wlan/functional/WlanScanTest.py
@@ -48,7 +48,7 @@
self.start_access_point = False
for fd in self.fuchsia_devices:
- fd.configure_wlan()
+ fd.configure_wlan(association_mechanism='drivers')
if "AccessPoint" in self.user_params:
# This section sets up the config that could be sent to the AP if
# the AP is needed. The reasoning is since ACTS already connects
@@ -189,8 +189,11 @@
if 'password' in wlan_network_params:
target_pwd = wlan_network_params['password']
+ bss_scan_response = fd.wlan_lib.wlanScanForBSSInfo().get('result')
connection_response = fd.wlan_lib.wlanConnectToNetwork(
- target_ssid, target_pwd)
+ target_ssid,
+ bss_scan_response[target_ssid][0],
+ target_pwd=target_pwd)
self.check_connect_response(connection_response)
self.basic_scan_request(fd)
diff --git a/acts_tests/tests/google/fuchsia/wlan_policy/PolicyScanTest.py b/acts_tests/tests/google/fuchsia/wlan_policy/PolicyScanTest.py
index f1a0d05..c174bc7 100644
--- a/acts_tests/tests/google/fuchsia/wlan_policy/PolicyScanTest.py
+++ b/acts_tests/tests/google/fuchsia/wlan_policy/PolicyScanTest.py
@@ -92,7 +92,8 @@
def setup_test(self):
for fd in self.fuchsia_devices:
# stub for setting up all the fuchsia devices in the testbed.
- pass
+ return fd.wlan_policy_controller.remove_all_networks_and_wait_for_no_connections(
+ )
def teardown_test(self):
for fd in self.fuchsia_devices:
@@ -163,24 +164,14 @@
"""
target_ssid = wlan_network_params["SSID"]
target_pwd = wlan_network_params.get("password")
+ target_security = wlan_network_params.get("security")
+
# TODO(mnck): use the Policy version of this call, when it is available.
- connection_response = fd.wlan_lib.wlanConnectToNetwork(
- target_ssid, target_pwd)
- if connection_response.get("error") is None:
- # the command did not get an error response - go ahead and
- # check the result
- connection_result = connection_response.get("result")
- if connection_result:
- self.log.info("connection to network successful")
- else:
- # ideally, we would have the actual error... but logging
- # here to cover that error case
- raise signals.TestFailure("Connect call failed, aborting test")
- else:
- # the response indicates an error - log and raise failure
- raise signals.TestFailure("Aborting test - Connect call failed "
- "with error: %s" %
- connection_response.get("error"))
+ connection_response = fd.wlan_policy_controller.save_and_connect(
+ target_ssid, target_security, password=target_pwd)
+ if not connection_response:
+ raise signals.TestFailure("Aborting test - Connect call failed")
+ self.log.info("Network connection successful.")
def assert_network_is_in_results(self, scan_results, *, ssid):
""" Verified scan results contain a specified network