network_WiFi_IBSS.py revision 522dd1b90d0f7aba8e8112d73c7db03d28ecedc6
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
5from autotest_lib.client.common_lib.cros.network import xmlrpc_datatypes
6from autotest_lib.server import site_linux_system
7from autotest_lib.server.cros.network import hostap_config
8from autotest_lib.server.cros.network import wifi_cell_test_base
9
10
11class network_WiFi_IBSS(wifi_cell_test_base.WiFiCellTestBase):
12    """Test that we can connect to an IBSS (Adhoc) endpoint."""
13    version = 1
14
15
16    def run_once(self):
17        """Body of the test."""
18        self.context.router.require_capabilities(
19                [site_linux_system.LinuxSystem.CAPABILITY_IBSS])
20        # In the past, we have seen a bug where a previous association on a
21        # channel where IBSS was disallowed would prohibit wpa_supplicant
22        # from setting the interface to adhoc mode (since the kernel refuses
23        # to allow adhoc mode on the previous channel).
24        configuration = hostap_config.HostapConfig(
25                channel=52, mode=hostap_config.HostapConfig.MODE_11A)
26        self.context.configure(configuration)
27        assoc_params = xmlrpc_datatypes.AssociationParameters(
28                ssid=self.context.router.get_ssid())
29        self.context.assert_connect_wifi(assoc_params)
30        self.context.client.shill.disconnect(assoc_params.ssid)
31        # TODO(wiley): This packet capture is purely to help us debug flake
32        #              in this test.  Remove it if we're not seeing flake.
33        configuration = hostap_config.HostapConfig(
34                frequency=2412, mode=hostap_config.HostapConfig.MODE_11B)
35        self.context.router.start_capture(configuration.frequency)
36        self.context.configure(configuration, is_ibss=True)
37        assoc_params = xmlrpc_datatypes.AssociationParameters(
38                ssid=self.context.router.get_ssid(),
39                discovery_timeout=30,
40                association_timeout=30,
41                configuration_timeout=30,
42                station_type=xmlrpc_datatypes.
43                        AssociationParameters.STATION_TYPE_IBSS)
44        self.context.assert_connect_wifi(assoc_params)
45        self.context.assert_ping_from_dut()
46        self.context.client.shill.disconnect(assoc_params.ssid)
47        self.context.router.stop_capture()
48        self.context.router.deconfig_aps()
49