def test_negative_ipv6_invalid_string(self): ip_address = 'fdsafdsafdsafdsf' self.assertFalse(utils.is_valid_ipv6_address(ip_address))
def test_negative_ipv6_invalid_characters(self): ip_address = 'fe80:jkyr:f693:9fff:fef4:1ac' self.assertFalse(utils.is_valid_ipv6_address(ip_address))
def test_negative_ipv6_with_ipv4_address(self): ip_address = '192.168.1.123' self.assertFalse(utils.is_valid_ipv6_address(ip_address))
def test_positive_ipv6_link_local(self): ip_address = 'fe80::' self.assertTrue(utils.is_valid_ipv6_address(ip_address))
def test_positive_ipv6(self): ip_address = 'fe80::f693:9fff:fef4:1ac' self.assertTrue(utils.is_valid_ipv6_address(ip_address))
def __init__(self, fd_conf_data): """ Args: fd_conf_data: A dict of a fuchsia device configuration data Required keys: ip: IP address of fuchsia device optional key: port: Port for the sl4f web server on the fuchsia device (Default: 80) ssh_config: Location of the ssh_config file to connect to the fuchsia device (Default: None) """ self.conf_data = fd_conf_data if "ip" not in fd_conf_data: raise FuchsiaDeviceError(FUCHSIA_DEVICE_NO_IP_MSG) self.ip = fd_conf_data["ip"] self.port = fd_conf_data.get("port", 80) self.ssh_config = fd_conf_data.get("ssh_config", None) self.ssh_username = fd_conf_data.get("ssh_username", FUCHSIA_SSH_USERNAME) self.hard_reboot_on_fail = fd_conf_data.get("hard_reboot_on_fail", False) self.device_pdu_config = fd_conf_data.get("PduDevice", None) self._persistent_ssh_conn = None self.log = acts_logger.create_tagged_trace_logger( "FuchsiaDevice | %s" % self.ip) if utils.is_valid_ipv4_address(self.ip): self.address = "http://{}:{}".format(self.ip, self.port) elif utils.is_valid_ipv6_address(self.ip): self.address = "http://[{}]:{}".format(self.ip, self.port) else: raise ValueError('Invalid IP: %s' % self.ip) self.init_address = self.address + "/init" self.cleanup_address = self.address + "/cleanup" self.print_address = self.address + "/print_clients" self.ping_rtt_match = re.compile(r'RTT Min/Max/Avg ' r'= \[ (.*?) / (.*?) / (.*?) \] ms') # TODO(): Come up with better client numbering system self.client_id = "FuchsiaClient" + str(random.randint(0, 1000000)) self.test_counter = 0 self.serial = re.sub('[.:%]', '_', self.ip) log_path_base = getattr(logging, 'log_path', '/tmp/logs') self.log_path = os.path.join(log_path_base, 'FuchsiaDevice%s' % self.serial) self.fuchsia_log_file_path = os.path.join( self.log_path, "fuchsialog_%s_debug.txt" % self.serial) self.log_process = None # Grab commands from FuchsiaAvdtpLib self.avdtp_lib = FuchsiaAvdtpLib(self.address, self.test_counter, self.client_id) # Grab commands from FuchsiaLightLib self.light_lib = FuchsiaLightLib(self.address, self.test_counter, self.client_id) # Grab commands from FuchsiaBacklightLib self.backlight_lib = FuchsiaBacklightLib(self.address, self.test_counter, self.client_id) # Grab commands from FuchsiaBleLib self.ble_lib = FuchsiaBleLib(self.address, self.test_counter, self.client_id) # Grab commands from FuchsiaBtcLib self.btc_lib = FuchsiaBtcLib(self.address, self.test_counter, self.client_id) # Grab commands from FuchsiaGattcLib self.gattc_lib = FuchsiaGattcLib(self.address, self.test_counter, self.client_id) # Grab commands from FuchsiaGattsLib self.gatts_lib = FuchsiaGattsLib(self.address, self.test_counter, self.client_id) # Grab commands from FuchsiaGpioLib self.gpio_lib = FuchsiaGpioLib(self.address, self.test_counter, self.client_id) # Grab commands from FuchsiaHardwarePowerStatecontrolLib self.hardware_power_statecontrol_lib = FuchsiaHardwarePowerStatecontrolLib( self.address, self.test_counter, self.client_id) # Grab commands from FuchsiaHwinfoLib self.hwinfo_lib = FuchsiaHwinfoLib(self.address, self.test_counter, self.client_id) # Grab commands from FuchsiaI2cLib self.i2c_lib = FuchsiaI2cLib(self.address, self.test_counter, self.client_id) # Grab commands from FuchsiaInputReportLib self.input_report_lib = FuchsiaInputReportLib(self.address, self.test_counter, self.client_id) # Grab commands from FuchsiaKernelLib self.kernel_lib = FuchsiaKernelLib(self.address, self.test_counter, self.client_id) # Grab commands from FuchsiaLoggingLib self.logging_lib = FuchsiaLoggingLib(self.address, self.test_counter, self.client_id) # Grab commands from FuchsiaNetstackLib self.netstack_lib = FuchsiaNetstackLib(self.address, self.test_counter, self.client_id) # Grab commands from FuchsiaProfileServerLib self.sdp_lib = FuchsiaProfileServerLib(self.address, self.test_counter, self.client_id) # Grab commands from FuchsiaRegulatoryRegionLib self.regulatory_region_lib = FuchsiaRegulatoryRegionLib( self.address, self.test_counter, self.client_id) # Grab commands from FuchsiaSysInfoLib self.sysinfo_lib = FuchsiaSysInfoLib(self.address, self.test_counter, self.client_id) # Grabs command from FuchsiaWlanDeprecatedConfigurationLib self.wlan_deprecated_configuration_lib = FuchsiaWlanDeprecatedConfigurationLib( self.address, self.test_counter, self.client_id) # Grab commands from FuchsiaWlanLib self.wlan_lib = FuchsiaWlanLib(self.address, self.test_counter, self.client_id) # Grab commands from FuchsiaWlanApPolicyLib self.wlan_ap_policy_lib = FuchsiaWlanApPolicyLib( self.address, self.test_counter, self.client_id) # Grab commands from FuchsiaWlanPolicyLib self.wlan_policy_lib = FuchsiaWlanPolicyLib(self.address, self.test_counter, self.client_id) self.skip_sl4f = False # Start sl4f on device self.start_services(skip_sl4f=self.skip_sl4f) # Init server self.init_server_connection()