1# Copyright (c) 2015 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 5AUTHOR = 'krisr, tienchang, bmahadev' 6NAME = 'network_WiFi_SuspendStress.WEP40' 7TIME = 'MEDIUM' 8TEST_TYPE = 'Server' 9DEPENDENCIES = 'servo, wificell' 10ATTRIBUTES = 'suite:wifi_matfunc, suite:wifi_matfunc_bcm4371' 11 12DOC = """ 13This test uses servo to simulate lid close and open events and checks that the 14wifi adapter is brought back up and connects to a WEP network. 15""" 16 17from autotest_lib.client.common_lib.cros.network import xmlrpc_datatypes 18from autotest_lib.client.common_lib.cros.network import xmlrpc_security_types 19from autotest_lib.server.cros.network import hostap_config 20from autotest_lib.server import utils 21 22args_dict = utils.args_to_dict(args) 23servo_args = hosts.CrosHost.get_servo_arguments(args_dict) 24 25def run(machine): 26 try: 27 host = hosts.create_host(machine, servo_args=servo_args) 28 except IOError: 29 # We probably failed to connect to the servo. That's probably 30 # because the cell doesn't have a servo. 31 # 32 # Ideally, we'd raise TestNAError here, and be done. But the 33 # test isn't actually running yet. So we instantiate a host 34 # without servo, and let the network_WiFi_SuspendStress 35 # instance report the TestNAError. 36 host = hosts.create_host(machine) 37 38 # FYI: D-Bus requires string parameters must be valid UTF-8. 39 wep_keys = ['abcde', # Interpretted as ASCII. 40 'fedcba9876', # Interpretted as hex. 41 # Mix ASCII characters with a 3-byte UTF-8 character. 42 'ab\xe4\xb8\x89', 43 # Mix different byte length UTF-8 characters. 44 '\xe4\xb8\x89\xc2\xa2'] 45 auth_algs = (xmlrpc_security_types.WEPConfig.AUTH_ALGORITHM_OPEN, 46 xmlrpc_security_types.WEPConfig.AUTH_ALGORITHM_SHARED) 47 configurations = [] 48 for auth_algorithm in auth_algs: 49 for i in range(len(wep_keys)): 50 wep_config = xmlrpc_security_types.WEPConfig( 51 wep_keys, 52 wep_default_key=i, 53 auth_algorithm=auth_algorithm) 54 ap_config = hostap_config.HostapConfig( 55 frequency=2412, 56 mode=hostap_config.HostapConfig.MODE_11G, 57 security_config=wep_config) 58 assoc_params = xmlrpc_datatypes.AssociationParameters( 59 security_config=wep_config) 60 configurations.append((ap_config, assoc_params)) 61 job.run_test('network_WiFi_SuspendStress', 62 host=host, 63 tag=NAME.split('.')[1], 64 suspends=5, 65 raw_cmdline_args=args, 66 additional_params=configurations) 67 68 69parallel_simple(run, machines) 70