示例#1
0
    def run(self):
        """Actually runs a emulator, assuming `create` has already been called."""
        if not self.process_runner:
            raise EmulatorError(
                'Attempted to `run` emulator before calling `create`')

        logs.log('Starting emulator.')
        self.process = self.process_runner.run(stdout=subprocess.PIPE,
                                               stderr=subprocess.DEVNULL)

        device_serial = None
        while not device_serial:
            line = self.process.popen.stdout.readline().decode()
            match = DEVICE_SERIAL_RE.match(line)
            if match:
                device_serial = match.group(1)

        # Close the pipe so we don't hang.
        self.process.popen.stdout.close()

        logs.log('Found serial ID: %s.' % device_serial)
        environment.set_value('ANDROID_SERIAL', device_serial)

        logs.log('Waiting on device')
        adb.wait_until_fully_booted()
        logs.log('Device is online')
示例#2
0
def reboot():
  """Reboots device and clear config state."""
  # Make sure to clear logcat before reboot occurs. In case of kernel crashes,
  # we use the log before reboot, so it is good to clear it when we are doing
  # the reboot explicitly.
  logger.clear_log()

  # Reboot.
  logs.log('Rebooting device.')
  adb.reboot()

  # Wait for boot to complete.
  adb.wait_until_fully_booted()
示例#3
0
def reboot():
    """Reboots device and clear config state."""
    # Make sure to clear logcat before reboot occurs. In case of kernel crashes,
    # we use the log before reboot, so it is good to clear it when we are doing
    # the reboot explicitly.
    logger.clear_log()

    # Reboot.
    logs.log('Rebooting device.')
    adb.reboot()

    # Wait for boot to complete.
    adb.wait_until_fully_booted()

    # Start memory monitor script to prevent out-of-memory scenarios.
    setup_memory_monitor_script_if_needed()
示例#4
0
def setup_asan_if_needed():
    """Sets the asan.options device property."""
    if not environment.get_value('ASAN_DEVICE_SETUP'):
        # Only do this step if explicitly enabled in the job type. This cannot be
        # determined from libraries in application directory since they can go
        # missing in a bad build, so we want to catch that.
        return

    if get_sanitizer_tool_name():
        # If this is a sanitizer build, no need to setup ASAN (incompatible).
        return

    app_directory = environment.get_value('APP_DIR')
    if not app_directory:
        # No app directory -> No ASAN runtime library. No work to do, bail out.
        return

    # Initialize variables.
    android_directory = environment.get_platform_resources_directory()
    device_id = environment.get_value('ANDROID_SERIAL')

    # Execute the script.
    logs.log('Executing ASan device setup script.')
    asan_device_setup_script_path = os.path.join(android_directory,
                                                 'third_party',
                                                 'asan_device_setup.sh')
    asan_runtime_library_argument = '--lib %s' % app_directory
    device_argument = '--device %s' % device_id
    asan_options_file_path = get_sanitizer_options_file_path('ASAN')
    extra_asan_options = ('--extra-options include_if_exists=%s' %
                          asan_options_file_path)
    command = '%s %s %s %s' % (asan_device_setup_script_path, device_argument,
                               asan_runtime_library_argument,
                               extra_asan_options)
    adb.execute_command(command, timeout=ASAN_SCRIPT_TIMEOUT)

    # Wait until fully booted as otherwise shell restart followed by a quick
    # reboot can trigger data corruption in /data/data.
    adb.wait_until_fully_booted()