1# Copyright (c) 2013 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import logging 6 7from autotest_lib.server.cros.network import wifi_cell_test_base 8 9class network_WiFi_SimpleConnect(wifi_cell_test_base.WiFiCellTestBase): 10 """Test that we can connect to router configured in various ways.""" 11 version = 1 12 13 def parse_additional_arguments(self, commandline_args, additional_params): 14 """Hook into super class to take control files parameters. 15 16 @param commandline_args dict of parsed parameters from the autotest. 17 @param additional_params list of tuple(HostapConfig, 18 AssociationParameters). 19 20 """ 21 self._configurations = additional_params 22 23 24 def run_once(self): 25 """Sets up a router, connects to it, pings it, and repeats.""" 26 client_mac = self.context.client.wifi_mac 27 for router_conf, client_conf in self._configurations: 28 self.context.configure(router_conf) 29 self.context.capture_host.start_capture(router_conf.frequency, 30 width_type=router_conf.packet_capture_mode) 31 client_conf.ssid = self.context.router.get_ssid() 32 assoc_result = self.context.assert_connect_wifi(client_conf) 33 if client_conf.expect_failure: 34 logging.info('Skipping ping because we expected this ' 35 'attempt to fail.') 36 else: 37 with self.context.client.assert_no_disconnects(): 38 self.context.assert_ping_from_dut() 39 self.context.client.shill.disconnect(client_conf.ssid) 40 times_dict = { 41 'Discovery': assoc_result.discovery_time, 42 'Association': assoc_result.association_time, 43 'Configuration': assoc_result.configuration_time} 44 for key in times_dict.keys(): 45 self.output_perf_value( 46 description=key, 47 value=times_dict[key], 48 units='seconds', 49 higher_is_better=False, 50 graph=router_conf.perf_loggable_description) 51 self.context.client.shill.delete_entries_for_ssid(client_conf.ssid) 52 self.context.router.deconfig() 53 self.context.capture_host.stop_capture() 54