Ejemplo n.º 1
0
def main(args):
    device_info = AndroidDeviceInfo.from_adb()
    if args.verbose:
        print(device_info)

    if device_info.cpu_abi.lower() not in CPU_ABI_TO_TARGET_ARCH_MAP:
        raise ValueError(f"Unrecognized CPU ABI: '{device_info.cpu_abi}'; "
                         "need to update the map")
    if device_info.gpu_name.lower() not in GPU_NAME_TO_TARGET_ARCH_MAP:
        raise ValueError(f"Unrecognized GPU name: '{device_info.gpu_name}'; "
                         "need to update the map")

    # Clear the benchmark directory on the Android device first just in case
    # there are leftovers from manual or failed runs.
    get_output(["adb", "shell", "rm", "-rf", ANDROID_TMP_DIR],
               verbose=args.verbose)

    results = filter_and_run_benchmarks(device_info, args.build_dir,
                                        args.benchmark_tool, args.verbose)

    if args.output is not None:
        with open(args.output, "w") as f:
            f.write(results.to_json_str())
    if args.verbose:
        print(results.commit)
        print(results.benchmarks)

    if not args.no_clean:
        # Clear the benchmark directory on the Android device.
        get_output(["adb", "shell", "rm", "-rf", ANDROID_TMP_DIR],
                   verbose=args.verbose)
Ejemplo n.º 2
0
def get_origin_tree_top_commit(verbose: bool = False) -> str:
    """Returns the top of the tree commit for the origin base branch."""
    base_branch = get_required_env_var("BUILDKITE_PULL_REQUEST_BASE_BRANCH")
    get_output(['git', 'fetch', '--prune', '--', 'origin', base_branch],
               cwd=THIS_DIRECTORY,
               verbose=verbose)
    return get_git_commit_hash(f'origin/{base_branch}', verbose)
Ejemplo n.º 3
0
def adb_push_to_tmp_dir(content: str,
                        relative_dir: str,
                        verbose: bool = False) -> str:
    """Pushes content onto the Android device.

  Args:
  - content: the full path to the source file.
  - relative_dir: the directory to push to; relative to ANDROID_TMP_DIR.

  Returns:
  - The full path to the content on the Android device.
  """
    filename = os.path.basename(content)
    android_path = os.path.join(ANDROID_TMP_DIR, relative_dir, filename)
    get_output(
        ["adb", "push", os.path.abspath(content), android_path],
        verbose=verbose)
    return android_path
Ejemplo n.º 4
0
def get_git_commit_info(commit: str, verbose: bool = False) -> Dict[str, str]:
    """Gets commit information dictory for the given commit."""
    cmd = [
        'git', 'show', '--format=%H:::%h:::%an:::%ae:::%s', '--no-patch',
        commit
    ]
    info = get_output(cmd, cwd=THIS_DIRECTORY, verbose=verbose)
    segments = info.split(':::')
    return {
        'hash': segments[0],
        'abbrevHash': segments[1],
        'authorName': segments[2],
        'authorEmail': segments[3],
        'subject': segments[4],
    }
Ejemplo n.º 5
0
def adb_execute_in_dir(cmd_args: Sequence[str],
                       relative_dir: str,
                       verbose: bool = False) -> str:
    """Executes command with adb shell in a directory.

  Args:
  - cmd_args: a list containing the command to execute and its parameters
  - relative_dir: the directory to execute the command in; relative to
    ANDROID_TMP_DIR.

  Returns:
  - A string for the command output.
  """
    cmd = ["adb", "shell"]
    cmd.extend(["cd", f"{ANDROID_TMP_DIR}/{relative_dir}"])
    cmd.append("&&")
    cmd.extend(cmd_args)

    return get_output(cmd, verbose=verbose)
Ejemplo n.º 6
0
def get_git_commit_hash(commit: str) -> str:
    return get_output(['git', 'rev-parse', commit],
                      cwd=os.path.dirname(os.path.realpath(__file__)))
Ejemplo n.º 7
0
def get_git_total_commit_count(commit: str, verbose: bool = False) -> int:
    """Gets the total commit count in history ending with the given commit."""
    count = get_output(['git', 'rev-list', '--count', commit],
                       cwd=THIS_DIRECTORY,
                       verbose=verbose)
    return int(count)
Ejemplo n.º 8
0
def get_git_commit_hash(commit: str, verbose: bool = False) -> str:
    """Gets the commit hash for the given commit."""
    return get_output(['git', 'rev-parse', commit],
                      cwd=THIS_DIRECTORY,
                      verbose=verbose)