def __setup(self): """Set up this system. Can be used either to complete initialization of a LinuxRouter object, or to re-establish a good state after a reboot. """ self.cmd_dhcpd = '/usr/sbin/dhcpd' self.cmd_hostapd = path_utils.must_be_installed( '/usr/sbin/hostapd', host=self.host) self.cmd_hostapd_cli = path_utils.must_be_installed( '/usr/sbin/hostapd_cli', host=self.host) self.cmd_wpa_supplicant = path_utils.must_be_installed( '/usr/sbin/wpa_supplicant', host=self.host) self.dhcpd_conf = '/tmp/dhcpd.%s.conf' self.dhcpd_leases = '/tmp/dhcpd.leases' # Log the most recent message on the router so that we can rebuild the # suffix relevant to us when debugging failures. last_log_line = self.host.run('tail -1 /var/log/messages').stdout # We're trying to get the timestamp from: # 2014-07-23T17:29:34.961056+00:00 localhost kernel: blah blah blah self._log_start_timestamp = last_log_line.strip().split(None, 2)[0] logging.debug('Will only retrieve logs after %s.', self._log_start_timestamp) # hostapd configuration persists throughout the test, subsequent # 'config' commands only modify it. if self._ssid_prefix.startswith(self.KNOWN_TEST_PREFIX): # Many of our tests start with an uninteresting prefix. # Remove it so we can have more unique bytes. self._ssid_prefix = self._ssid_prefix[len(self.KNOWN_TEST_PREFIX):] self._number_unique_ssids = 0 self._total_hostapd_instances = 0 self.local_servers = [] self.server_address_index = [] self.hostapd_instances = [] self.station_instances = [] self.dhcp_low = 1 self.dhcp_high = 128 # Kill hostapd and dhcp server if already running. self._kill_process_instance('hostapd', timeout_seconds=30) self.stop_dhcp_server(instance=None) # Place us in the US by default self.iw_runner.set_regulatory_domain('US') self.enable_all_antennas() # Some tests want this functionality, but otherwise, it's a distraction. if self._enable_avahi: self.host.run('start avahi', ignore_status=True) else: self.host.run('stop avahi', ignore_status=True)
def __setup(self): """Set up this system. Can be used either to complete initialization of a LinuxSystem object, or to re-establish a good state after a reboot. """ # Command locations. cmd_iw = path_utils.must_be_installed('/usr/sbin/iw', host=self.host) self.cmd_ip = path_utils.must_be_installed('/usr/sbin/ip', host=self.host) self.cmd_readlink = '%s -l' % path_utils.must_be_installed( '/bin/ls', host=self.host) self._packet_capturer = packet_capturer.get_packet_capturer( self.host, host_description=self.role, cmd_ip=self.cmd_ip, cmd_iw=cmd_iw, ignore_failures=True) self.iw_runner = iw_runner.IwRunner(remote_host=self.host, command_iw=cmd_iw) self._phy_list = None self.phys_for_frequency, self.phy_bus_type = self._get_phy_info() logging.debug('Current regulatory domain %r', self.iw_runner.get_regulatory_domain()) self._interfaces = [] self._brif_index = 0 for interface in self.iw_runner.list_interfaces(): if self.inherit_interfaces: self._interfaces.append( NetDev(inherited=True, if_name=interface.if_name, if_type=interface.if_type, phy=interface.phy)) else: self.iw_runner.remove_interface(interface.if_name) self._wlanifs_in_use = [] self._local_macs_in_use = set() self._capture_interface = None self._board = None # Some uses of LinuxSystem don't use the interface allocation facility. # Don't force us to remove all the existing interfaces if this facility # is not desired. self._wlanifs_initialized = False self._capabilities = None self._ping_runner = ping_runner.PingRunner(host=self.host) self._bridge_interface = None self._virtual_ethernet_pair = None
def get_arch(self): """ Get the hardware architecture of the remote machine. """ cmd_uname = path_utils.must_be_installed('/bin/uname', host=self) arch = self.run('%s -m' % cmd_uname).stdout.rstrip() if re.match(r'i\d86$', arch): arch = 'i386' return arch
def get_capabilities(self): """@return iterable object of AP capabilities for this system.""" caps = set() try: self.cmd_send_management_frame = path_utils.must_be_installed( '/usr/bin/send_management_frame', host=self.host) caps.add(self.CAPABILITY_SEND_MANAGEMENT_FRAME) except error.TestFail: pass return super(LinuxRouter, self).get_capabilities().union(caps)
def __init__(self, client_host, config): """Construct a ResourceMonitor. @param client_host: SSHHost object representing a remote ssh host """ self._client_host = client_host self._config = config self._command_top = path_utils.must_be_installed( 'top', host=self._client_host) self._top_pid = None
def __init__(self, client_proxy, server_proxy, config): """Construct a NetperfRunner. @param client WiFiClient object. @param server LinuxSystem object. """ self._client_proxy = client_proxy self._server_proxy = server_proxy if config.server_serves: self._server_host = server_proxy.host self._client_host = client_proxy.host self._target_ip = server_proxy.wifi_ip else: self._server_host = client_proxy.host self._client_host = server_proxy.host self._target_ip = client_proxy.wifi_ip self._command_netserv = path_utils.must_be_installed( 'netserver', host=self._server_host) self._command_netperf = path_utils.must_be_installed( 'netperf', host=self._client_host) self._config = config
def __init__(self, host, ping_interface): self._host = host self._arping_command = path_utils.must_be_installed('/usr/bin/arping', host=host) self._ping_interface = ping_interface
def get_kernel_ver(self): """ Get the kernel version of the remote machine. """ cmd_uname = path_utils.must_be_installed('/bin/uname', host=self) return self.run('%s -r' % cmd_uname).stdout.rstrip()
def __setup(self): """Set up this system. Can be used either to complete initialization of a LinuxRouter object, or to re-establish a good state after a reboot. """ self.cmd_dhcpd = '/usr/sbin/dhcpd' self.cmd_hostapd = path_utils.must_be_installed('/usr/sbin/hostapd', host=self.host) self.cmd_hostapd_cli = path_utils.must_be_installed( '/usr/sbin/hostapd_cli', host=self.host) self.cmd_wpa_supplicant = path_utils.must_be_installed( '/usr/sbin/wpa_supplicant', host=self.host) self.dhcpd_conf = '/tmp/dhcpd.%s.conf' self.dhcpd_leases = '/tmp/dhcpd.leases' # TODO(crbug.com/839164): some routers fill their stateful partition # with uncollected metrics. self.host.run('rm -f /var/lib/metrics/uma-events', ignore_status=True) # Log the most recent message on the router so that we can rebuild the # suffix relevant to us when debugging failures. last_log_line = self.host.run('tail -1 /var/log/messages', ignore_status=True).stdout # We're trying to get the timestamp from: # 2014-07-23T17:29:34.961056+00:00 localhost kernel: blah blah blah self._log_start_timestamp = last_log_line.strip().partition(' ')[0] if self._log_start_timestamp: logging.debug('Will only retrieve logs after %s.', self._log_start_timestamp) else: # If syslog is empty, we just use a wildcard pattern, to grab # everything. logging.debug('Empty or corrupt log; will retrieve whole log') self._log_start_timestamp = '.' # hostapd configuration persists throughout the test, subsequent # 'config' commands only modify it. if self._ssid_prefix.startswith(self.KNOWN_TEST_PREFIX): # Many of our tests start with an uninteresting prefix. # Remove it so we can have more unique bytes. self._ssid_prefix = self._ssid_prefix[len(self.KNOWN_TEST_PREFIX):] self._number_unique_ssids = 0 self._total_hostapd_instances = 0 self.local_servers = [] self.server_address_index = [] self.hostapd_instances = [] self.station_instances = [] self.dhcp_low = 1 self.dhcp_high = 128 # Tear down hostapbr bridge interfaces result = self.host.run('ls -d /sys/class/net/%s*' % self.HOSTAP_BRIDGE_INTERFACE_PREFIX, ignore_status=True) if result.exit_status == 0: for path in result.stdout.splitlines(): self.delete_link(path.split('/')[-1]) # Kill hostapd and dhcp server if already running. self._kill_process_instance('hostapd', timeout_seconds=30) self.stop_dhcp_server(instance=None) # Place us in the US by default self.iw_runner.set_regulatory_domain('US') self.enable_all_antennas() # Some tests want this functionality, but otherwise, it's a distraction. if self._enable_avahi: self.host.run('start avahi', ignore_status=True) else: self.host.run('stop avahi', ignore_status=True) # Some routers have bad (slow?) random number generators. self.rng_configure()