1# Copyright 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
5from autotest_lib.server import utils
6
7AUTHOR = 'krisr, tienchang, bmahadev'
8NAME = 'network_WiFi_SuspendStress.11a'
9TIME = 'MEDIUM'
10TEST_TYPE = 'Server'
11DEPENDENCIES = 'servo, wificell'
12ATTRIBUTES = 'suite:wifi_matfunc, suite:wifi_matfunc_bcm4371'
13DOC = """
14This test uses servo to simulate lid close and open events and checks that the
15wifi adapter is brought back up and connects to a 802.11a network on channels
1648, 64.
17"""
18
19from autotest_lib.client.common_lib.cros.network import xmlrpc_datatypes
20from autotest_lib.server.cros.network import hostap_config
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    a_mode = hostap_config.HostapConfig.MODE_11A
39    configurations = [(hostap_config.HostapConfig(channel=48, mode=a_mode),
40                       xmlrpc_datatypes.AssociationParameters()),
41                      (hostap_config.HostapConfig(channel=64, mode=a_mode),
42                       xmlrpc_datatypes.AssociationParameters())]
43
44    job.run_test('network_WiFi_SuspendStress',
45                 host=host,
46                 tag=NAME.split('.')[1],
47                 suspends=5,
48                 raw_cmdline_args=args,
49                 additional_params=configurations)
50
51parallel_simple(run, machines)
52