def __init__(self, serial="", host_port=None, device_port=sl4a_client.DEFAULT_DEVICE_SIDE_PORT, ssh_connection=None): self.serial = serial self.h_port = host_port self.d_port = device_port # logging.log_path only exists when this is used in an ACTS test run. log_path_base = getattr(logging, "log_path", "/tmp/logs") self.log_path = os.path.join(log_path_base, "AndroidDevice%s" % serial) self.log = tracelogger.TraceLogger( AndroidDeviceLoggerAdapter(logging.getLogger(), {"serial": self.serial})) self._droid_sessions = {} self._event_dispatchers = {} self.adb_logcat_process = None self.adb_logcat_file_path = None self.adb = adb.AdbProxy(serial, ssh_connection=ssh_connection) self.fastboot = fastboot.FastbootProxy(serial, ssh_connection=ssh_connection) if not self.is_bootloader: self.root_adb() self._ssh_connection = ssh_connection self.skip_sl4a = False self.crash_report = None self.device_password = None
def __init__(self, configs): """Initializes a BaseTestClass given a TestRunConfig, which provides all of the config information for this test class. Args: configs: A config_parser.TestRunConfig object. """ super().__init__(configs) self.__handle_file_user_params() self.class_subscriptions = SubscriptionBundle() self.class_subscriptions.register() self.all_subscriptions = [self.class_subscriptions] self.current_test_name = None self.log = tracelogger.TraceLogger(logging.getLogger()) # TODO: remove after converging log path definitions with mobly self.log_path = configs.log_path self.consecutive_failures = 0 self.consecutive_failure_limit = self.user_params.get( 'consecutive_failure_limit', -1) self.size_limit_reached = False self.retryable_exceptions = signals.TestFailure
def __init__(self, grpc_port, grpc_root_server_port, cmd, label, type_identifier): self.label = label if label is not None else grpc_port # logging.log_path only exists when this is used in an ACTS test run. log_path_base = getattr(logging, 'log_path', '/tmp/logs') self.log = tracelogger.TraceLogger( GdDeviceBaseLoggerAdapter(logging.getLogger(), { 'device': label, 'type_identifier': type_identifier })) backing_process_logpath = os.path.join( log_path_base, '%s_%s_backing_logs.txt' % (type_identifier, label)) self.backing_process_logs = open(backing_process_logpath, 'w') btsnoop_path = os.path.join(log_path_base, '%s_btsnoop_hci.log' % label) cmd.append("--btsnoop=" + btsnoop_path) self.backing_process = subprocess.Popen( cmd, cwd=ANDROID_BUILD_TOP, env=os.environ.copy(), stdout=self.backing_process_logs, stderr=self.backing_process_logs) self.grpc_root_server_channel = grpc.insecure_channel( "localhost:" + grpc_root_server_port) self.grpc_port = int(grpc_port) self.grpc_channel = grpc.insecure_channel("localhost:" + grpc_port)
def create_logger(logging_lambda=lambda message: message): """Returns a logger with logging defined by a given lambda. Args: logging_lambda: A lambda of the form: >>> lambda log_message: return 'string' """ return tracelogger.TraceLogger(LoggerAdapter(logging_lambda))
def __init__(self, host, username, password): if type(self) is PduDevice: raise NotImplementedError( "Base class: cannot be instantiated directly") self.host = host self.username = username self.password = password self.log = tracelogger.TraceLogger(logging.getLogger())
def __init__(self, configs): self.tests = [] if not self.TAG: self.TAG = self.__class__.__name__ # Set all the controller objects and params. for name, value in configs.items(): setattr(self, name, value) self.results = records.TestResult() self.current_test_name = None self.log = tracelogger.TraceLogger(self.log) if 'android_devices' in self.__dict__: for ad in self.android_devices: if ad.droid: utils.set_location_service(ad, False) utils.sync_device_time(ad)
def __init__(self, ip_address): self._ipaddr = ip_address self.log = tracelogger.TraceLogger(logging.getLogger()) # Open socket connection to Signaling Tester self.log.info("Opening Socket Connection with " "Signal Generator MG3710A ({}) ".format(self._ipaddr)) try: self._sock = socket.create_connection( (self._ipaddr, 49158), timeout=30) self.send_query("*IDN?", 60) self.log.info("Communication Signal Generator MG3710A OK.") self.log.info("Opened Socket connection to ({})" "with handle ({})".format(self._ipaddr, self._sock)) except socket.timeout: raise AnritsuError("Timeout happened while conencting to" " Anritsu MG3710A") except socket.error: raise AnritsuError("Socket creation error")
def __init__(self, grpc_port, grpc_root_server_port, signal_port, cmd, label, type_identifier): self.label = label if label is not None else grpc_port # logging.log_path only exists when this is used in an ACTS test run. log_path_base = getattr(logging, 'log_path', '/tmp/logs') self.log = tracelogger.TraceLogger( GdDeviceBaseLoggerAdapter(logging.getLogger(), { 'device': label, 'type_identifier': type_identifier })) backing_process_logpath = os.path.join( log_path_base, '%s_%s_backing_logs.txt' % (type_identifier, label)) self.backing_process_logs = open(backing_process_logpath, 'w') btsnoop_path = os.path.join(log_path_base, '%s_btsnoop_hci.log' % label) cmd.append("--btsnoop=" + btsnoop_path) tester_signal_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) tester_signal_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) socket_address = ('localhost', int(signal_port)) tester_signal_socket.bind(socket_address) tester_signal_socket.listen(1) self.backing_process = subprocess.Popen( cmd, cwd=ANDROID_BUILD_TOP, env=os.environ.copy(), stdout=self.backing_process_logs, stderr=self.backing_process_logs) tester_signal_socket.accept() tester_signal_socket.close() self.grpc_root_server_channel = grpc.insecure_channel( "localhost:" + grpc_root_server_port) self.grpc_port = int(grpc_port) self.grpc_channel = grpc.insecure_channel("localhost:" + grpc_port)
def __init__(self, grpc_port, grpc_root_server_port, signal_port, cmd, label, type_identifier, serial_number): self.label = label if label is not None else grpc_port # logging.log_path only exists when this is used in an ACTS test run. self.log_path_base = context.get_current_context( ).get_full_output_path() self.log = tracelogger.TraceLogger( GdDeviceBaseLoggerAdapter(logging.getLogger(), { 'device': label, 'type_identifier': type_identifier })) backing_process_logpath = os.path.join( self.log_path_base, '%s_%s_backing_logs.txt' % (type_identifier, label)) self.backing_process_logs = open(backing_process_logpath, 'w') cmd_str = json.dumps(cmd) if "--btsnoop=" not in cmd_str: btsnoop_path = os.path.join(self.log_path_base, '%s_btsnoop_hci.log' % label) cmd.append("--btsnoop=" + btsnoop_path) self.serial_number = serial_number if self.serial_number: self.ad = AdbProxy(serial_number) self.ad.shell("date " + time.strftime("%m%d%H%M%Y.%S")) self.ad.tcp_forward(int(grpc_port), int(grpc_port)) self.ad.tcp_forward(int(grpc_root_server_port), int(grpc_root_server_port)) self.ad.reverse("tcp:%s tcp:%s" % (signal_port, signal_port)) self.ad.push( os.path.join(ANDROID_PRODUCT_OUT, "system/bin/bluetooth_stack_with_facade"), "system/bin") self.ad.push( os.path.join(ANDROID_PRODUCT_OUT, "system/lib64/libbluetooth_gd.so"), "system/lib64") self.ad.push( os.path.join(ANDROID_PRODUCT_OUT, "system/lib64/libgrpc++_unsecure.so"), "system/lib64") self.ad.shell("logcat -c") self.ad.shell("rm /data/misc/bluetooth/logs/btsnoop_hci.log") self.ad.shell("svc bluetooth disable") tester_signal_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) tester_signal_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) socket_address = ('localhost', int(signal_port)) tester_signal_socket.bind(socket_address) tester_signal_socket.listen(1) self.backing_process = subprocess.Popen( cmd, cwd=ANDROID_BUILD_TOP, env=os.environ.copy(), stdout=self.backing_process_logs, stderr=self.backing_process_logs) tester_signal_socket.accept() tester_signal_socket.close() self.grpc_root_server_channel = grpc.insecure_channel( "localhost:" + grpc_root_server_port) self.grpc_port = int(grpc_port) self.grpc_channel = grpc.insecure_channel("localhost:" + grpc_port)
def __init__(self, iperf_config, identifier, wlan_device=None, access_point=None, port_range_start=5201): self.identifier = identifier self.log = tracelogger.TraceLogger( WmmTransceiverLoggerAdapter(logging.getLogger(), {'identifier': self.identifier})) # WlanDevice or AccessPoint, that is used as the transceiver. Only one # will be set. This helps consolodate association, setup, teardown, etc. self.wlan_device = wlan_device self.access_point = access_point # Parameters used to create IPerfClient and IPerfServer objects on # device self._iperf_config = iperf_config self._test_interface = self._iperf_config.get('test_interface') self._port_range_start = port_range_start self._next_server_port = port_range_start # Maps IPerfClients, used for streams from this device, to True if # available, False if reserved self._iperf_clients = {} # Maps IPerfServers, used to receive streams from other devices, to True # if available, False if reserved self._iperf_servers = {} # Maps ports of servers, which are provided to other transceivers, to # the actual IPerfServer objects self._iperf_server_ports = {} # Maps stream UUIDs to IPerfClients reserved for that streams use self._reserved_clients = {} # Maps stream UUIDs to (WmmTransceiver, IPerfServer) tuples, where the # server is reserved on the transceiver for that streams use self._reserved_servers = {} # Maps with shared memory functionality to be used across the parallel # streams. active_streams holds UUIDs of streams that are currently # running on this device (mapped to True, since there is no # multiprocessing set). stream_results maps UUIDs of streams completed # on this device to IPerfResult results for that stream. self._manager = multiprocessing.Manager() self._active_streams = self._manager.dict() self._stream_results = self._manager.dict() # Holds parameters for streams that are prepared to run asynchronously # (i.e. resources have been allocated). Maps UUIDs of the future streams # to a dict, containing the stream parameters. self._pending_async_streams = {} # Set of UUIDs of asynchronous streams that have at least started, but # have not had their resources reclaimed yet self._ran_async_streams = set() # Set of stream parallel process, which can be joined if completed # successfully, or terminated and joined in the event of an error self._running_processes = set()