| # Copyright (c) 2014 The Chromium OS Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| from autotest_lib.client.common_lib.cros.network import xmlrpc_datatypes |
| from autotest_lib.server.cros.network import hostap_config |
| from autotest_lib.server.cros.network import wifi_cell_test_base |
| |
| |
| class network_WiFi_ScanPerformance(wifi_cell_test_base.WiFiCellTestBase): |
| """Performance test for scanning operation in various setup""" |
| version = 1 |
| |
| def _write_scan_time(self, label, scan_time): |
| """Writes a scan time perf value. |
| |
| @param label: A string describing the scan_time. |
| @param scan_time: Scan time in seconds. |
| """ |
| self.output_perf_value(label, scan_time, units='seconds', |
| higher_is_better=False) |
| |
| def run_once(self): |
| """Sets up a router, scan for APs """ |
| |
| # Default router configuration |
| mode_n = hostap_config.HostapConfig.MODE_11N_PURE |
| router_conf = hostap_config.HostapConfig(channel=36, mode=mode_n); |
| freq = hostap_config.HostapConfig.get_frequency_for_channel(36) |
| self.context.configure(router_conf) |
| ssids = [self.context.router.get_ssid()] |
| |
| # Single channel scan |
| scan_time = self.context.client.timed_scan(frequencies=[freq], |
| ssids=ssids, scan_timeout_seconds=10) |
| self._write_scan_time('scan_time_single_channel_scan', scan_time) |
| |
| # Foreground full scan |
| scan_time = self.context.client.timed_scan(frequencies=[], ssids=ssids, |
| scan_timeout_seconds=10) |
| self._write_scan_time('scan_time_foreground_full_scan', scan_time) |
| |
| |
| # Background full scan |
| client_conf = xmlrpc_datatypes.AssociationParameters( |
| ssid=self.context.router.get_ssid()) |
| self.context.assert_connect_wifi(client_conf) |
| scan_time = self.context.client.timed_scan(frequencies=[], ssids=ssids, |
| scan_timeout_seconds=15) |
| self._write_scan_time('scan_time_background_full_scan', scan_time) |
| |
| # Deconfigure router |
| self.context.router.deconfig() |