blob: 5f3b9b9b1d920ec5bad754abb5d7f59f6e297a22 [file] [log] [blame]
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import logging
from autotest_lib.client.common_lib import utils
from import xmlrpc_datatypes
from autotest_lib.server import test
from import wifi_test_context_manager
class WiFiCellTestBase(test.test):
"""An abstract base class for autotests in WiFi cells.
WiFiCell tests refer to participants in the test as client, router, and
server. The client is just the DUT and the router is a nearby AP which we
configure in various ways to test the ability of the client to connect.
There is a third entity called a server which is distinct from the autotest
server. In WiFiTests, the server is a host which the client can only talk
to over the WiFi network.
WiFiTests have a notion of the control network vs the WiFi network. The
control network refers to the network between the machine running the
autotest server and the various machines involved in the test. The WiFi
network is the subnet(s) formed by WiFi routers between the server and the
def context(self):
"""@return the WiFi context for this test."""
return self._wifi_context
def parse_additional_arguments(self, commandline_args, additional_params):
"""Parse additional arguments for use in test.
Subclasses should override this method do any other commandline parsing
and setting grabbing that they need to do. For test clarity, do not
parse additional settings in the body of run_once.
@param commandline_args dict of argument key, value pairs.
@param additional_params object defined by test control file.
def warmup(self, host, raw_cmdline_args, additional_params=None):
Use the additional_params argument to pass in custom test data from
control file to reuse test logic. This object will be passed down via
@param host host object representing the client DUT.
@param raw_cmdline_args raw input from autotest.
@param additional_params object passed in from control file.
cmdline_args = utils.args_to_dict(raw_cmdline_args)'Running wifi test with commandline arguments: %r',
self._wifi_context = wifi_test_context_manager.WiFiTestContextManager(
self.parse_additional_arguments(cmdline_args, additional_params)
msg = '======= WiFi autotest setup complete. Starting test... ======='
def cleanup(self):
msg = '======= WiFi autotest complete. Cleaning up... ======='
# If we fail during initialization, we might not have a context.
if hasattr(self, '_wifi_context'):
def configure_and_connect_to_ap(self, ap_config):
Configure the router as an AP with the given config and connect
the DUT to it.
@param ap_config HostapConfig object.
@return name of the configured AP
ap_ssid = self.context.router.get_ssid()
assoc_params = xmlrpc_datatypes.AssociationParameters(ssid=ap_ssid)
return ap_ssid