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'
8MAX_RESULT_SIZE_KB = 512000
9TEST_TYPE = 'Server'
10DEPENDENCIES = 'wificell'
11ATTRIBUTES = ('suite:wifi_matfunc')
12
13DOC = """
14This test uses powerd_dbus to suspend and resume and checks that the
15wifi adapter is brought back up and connects to a WEP network.
16"""
17
18from autotest_lib.client.common_lib.cros.network import xmlrpc_datatypes
19from autotest_lib.client.common_lib.cros.network import xmlrpc_security_types
20from autotest_lib.server.cros.network import hostap_config
21
22def run(machine):
23    host = hosts.create_host(machine)
24    # FYI: D-Bus requires string parameters must be valid UTF-8.
25    wep_keys = ['abcde', # Interpretted as ASCII.
26                'fedcba9876',  # Interpretted as hex.
27                # Mix ASCII characters with a 3-byte UTF-8 character.
28                'ab\xe4\xb8\x89',
29                # Mix different byte length UTF-8 characters.
30                '\xe4\xb8\x89\xc2\xa2']
31    auth_algs = (xmlrpc_security_types.WEPConfig.AUTH_ALGORITHM_OPEN,
32                 xmlrpc_security_types.WEPConfig.AUTH_ALGORITHM_SHARED)
33    configurations = []
34    for auth_algorithm in auth_algs:
35        for i in range(len(wep_keys)):
36            wep_config = xmlrpc_security_types.WEPConfig(
37                    wep_keys,
38                    wep_default_key=i,
39                    auth_algorithm=auth_algorithm)
40            ap_config = hostap_config.HostapConfig(
41                    frequency=2412,
42                    mode=hostap_config.HostapConfig.MODE_11G,
43                    security_config=wep_config)
44            assoc_params = xmlrpc_datatypes.AssociationParameters(
45                    security_config=wep_config)
46            configurations.append((ap_config, assoc_params))
47    job.run_test('network_WiFi_SuspendStress',
48                 host=host,
49                 tag=NAME.split('.')[1],
50                 suspends=5,
51                 raw_cmdline_args=args,
52                 additional_params=configurations)
53
54
55parallel_simple(run, machines)
56