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.client.common_lib import error 8from autotest_lib.server.cros.network import wifi_cell_test_base 9 10class network_WiFi_SimpleConnect(wifi_cell_test_base.WiFiCellTestBase): 11 """Test that we can connect to router configured in various ways.""" 12 version = 1 13 14 def parse_additional_arguments(self, commandline_args, additional_params): 15 """Hook into super class to take control files parameters. 16 17 @param commandline_args dict of parsed parameters from the autotest. 18 @param additional_params list of tuple(HostapConfig, 19 AssociationParameters). 20 21 """ 22 self._configurations = additional_params 23 24 25 def run_once(self): 26 """Sets up a router, connects to it, pings it, and repeats.""" 27 client_mac = self.context.client.wifi_mac 28 for router_conf, client_conf in self._configurations: 29 self.context.configure(router_conf) 30 self.context.capture_host.start_capture(router_conf.frequency, 31 width_type=router_conf.packet_capture_mode) 32 client_conf.ssid = self.context.router.get_ssid() 33 assoc_result = self.context.assert_connect_wifi(client_conf) 34 if client_conf.expect_failure: 35 logging.info('Skipping ping because we expected this ' 36 'attempt to fail.') 37 else: 38 with self.context.client.assert_no_disconnects(): 39 self.context.assert_ping_from_dut() 40 if self.context.router.detect_client_deauth(client_mac): 41 raise error.TestFail( 42 'Client de-authenticated during the test') 43 self.context.client.shill.disconnect(client_conf.ssid) 44 times_dict = { 45 'Discovery': assoc_result.discovery_time, 46 'Association': assoc_result.association_time, 47 'Configuration': assoc_result.configuration_time} 48 for key in times_dict.keys(): 49 self.output_perf_value( 50 description=key, 51 value=times_dict[key], 52 units='seconds', 53 higher_is_better=False, 54 graph=router_conf.perf_loggable_description) 55 self.context.client.shill.delete_entries_for_ssid(client_conf.ssid) 56 self.context.router.deconfig() 57 self.context.capture_host.stop_capture() 58