Beispiel #1
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('adb_path', help='Path to adb command')
    parser.add_argument('agi_dir', help='Path to AGI build')
    parser.add_argument('out_dir', help='Path to output directory')
    args = parser.parse_args()

    #### Early checks and sanitization
    assert os.path.isfile(args.adb_path)
    adb_path = os.path.abspath(args.adb_path)
    assert os.path.isdir(args.agi_dir)
    agi_dir = os.path.abspath(args.agi_dir)
    assert os.path.isdir(args.out_dir)
    out_dir = os.path.abspath(args.out_dir)
    gapit_path = os.path.join(agi_dir, 'gapit')

    #### Create BotUtil with relevant adb and gapit paths
    bu = botutil.BotUtil(adb_path)
    bu.set_gapit_path(gapit_path)

    #### Test parameters
    test_params = {}
    required_keys = ['gfxtrace']
    botutil.load_params(test_params, required_keys=required_keys)
    assert os.path.isfile(test_params['gfxtrace'])

    #### Profile
    gapit_args = [
        '-gapir-os', 'android', '-gapir-nofallback', test_params['gfxtrace']
    ]

    with open(os.path.join(out_dir, 'profile.stdout'), 'w') as f:
        p = bu.gapit('profile', gapit_args, stdout=f)
    return p.returncode
Beispiel #2
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('agi_dir', help='Path to AGI build')
    parser.add_argument('out_dir', help='Path to output directory')
    args = parser.parse_args()

    #### Early checks and sanitization
    assert os.path.isdir(args.agi_dir)
    agi_dir = os.path.normpath(args.agi_dir)
    assert os.path.isdir(args.out_dir)
    out_dir = os.path.normpath(args.out_dir)

    #### Test parameters
    test_params = {}
    required_keys = ['gfxtrace']
    botutil.load_params(test_params, required_keys=required_keys)
    assert os.path.isfile(test_params['gfxtrace'])

    #### Profile
    gapit = os.path.join(agi_dir, 'gapit')
    cmd = [
        gapit, 'profile', '-gapir-os', 'android', '-gapir-nofallback',
        test_params['gfxtrace']
    ]
    print(cmd)
    with open(os.path.join(out_dir, 'profile.stdout'), 'w') as f:
        p = subprocess.run(cmd, stdout=f, stderr=sys.stderr)
    return p.returncode
Beispiel #3
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('adb_path', help='Path to adb command')
    parser.add_argument('agi_dir', help='Path to AGI build')
    parser.add_argument('out_dir', help='Path to output directory')
    args = parser.parse_args()

    #### Early checks and sanitization
    assert os.path.isfile(args.adb_path)
    adb_path = os.path.abspath(args.adb_path)
    assert os.path.isdir(args.agi_dir)
    agi_dir = os.path.abspath(args.agi_dir)
    assert os.path.isdir(args.out_dir)
    out_dir = os.path.abspath(args.out_dir)
    gapit_path = os.path.join(agi_dir, 'gapit')

    #### Create BotUtil with relevant adb and gapit paths
    bu = botutil.BotUtil(adb_path)
    bu.set_gapit_path(gapit_path)

    #### Test parameters
    test_params = {}
    botutil.load_params(test_params)

    #### Here add your debug experiments
    # For instance, list packages installed on the device:
    botutil.runcmd(['adb', 'shell', 'pm', 'list', 'packages'])
Beispiel #4
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('agi_dir', help='Path to AGI build')
    parser.add_argument('out_dir', help='Path to output directory')
    args = parser.parse_args()

    #### Early checks and sanitization
    assert os.path.isdir(args.agi_dir)
    agi_dir = os.path.normpath(args.agi_dir)
    assert os.path.isdir(args.out_dir)
    out_dir = os.path.normpath(args.out_dir)

    #### Load test parameters
    test_params = {}
    # Do not require 'apk' and 'package' params, as some drivers are just
    # obtained by system update.
    botutil.load_params(test_params)

    #### Install APK
    if 'apk' in test_params.keys():
        if not 'package' in test_params.keys():
            botutil.log('Error: have "apk" but no "package" in params.json')
            return 1
        botutil.install_apk(test_params)

    #### Call gapit command
    gapit = os.path.join(agi_dir, 'gapit')
    cmd = [gapit, 'validate_gpu_profiling', '-os', 'android']
    p = botutil.runcmd(cmd)
    return p.returncode
Beispiel #5
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('agi_dir', help='Path to AGI build')
    parser.add_argument('out_dir', help='Path to output directory')
    args = parser.parse_args()

    #### Early checks and sanitization
    assert os.path.isdir(args.agi_dir)
    agi_dir = os.path.normpath(args.agi_dir)
    assert os.path.isdir(args.out_dir)
    out_dir = os.path.normpath(args.out_dir)

    #### Test parameters
    test_params = {
        'startframe': '100',
        'numframes': '5',
        'observe_frames': '1',
        'api': 'vulkan',
    }
    required_keys = ['apk', 'package', 'activity']
    botutil.load_params(test_params, required_keys=required_keys)

    #### Install APK
    botutil.install_apk(test_params)

    #### Trace the app
    gapit = os.path.join(agi_dir, 'gapit')
    gfxtrace = os.path.join(out_dir, test_params['package'] + '.gfxtrace')
    cmd = [
        gapit, 'trace', '-api', test_params['api'], '-start-at-frame',
        test_params['startframe'], '-capture-frames', test_params['numframes'],
        '-observe-frames', test_params['observe_frames'], '-out', gfxtrace
    ]

    if 'additionalargs' in test_params.keys():
        cmd += ['-additionalargs', test_params['additionalargs']]

    cmd += [test_params['package'] + '/' + test_params['activity']]

    p = botutil.runcmd(cmd)
    if p.returncode != 0:
        return 1

    #### Stop the app asap for device cool-down
    botutil.adb(['shell', 'am', 'force-stop', test_params['package']])

    #### Replay
    videofile = os.path.join(out_dir, test_params['package'] + '.mp4')
    cmd = [
        gapit, 'video', '-gapir-nofallback', '-type', 'sxs', '-frames-minimum',
        test_params['numframes'], '-out', videofile, gfxtrace
    ]
    p = botutil.runcmd(cmd)
    return p.returncode
Beispiel #6
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('agi_dir', help='Path to AGI build')
    parser.add_argument('out_dir', help='Path to output directory')
    args = parser.parse_args()

    #### Early checks and sanitization
    assert os.path.isdir(args.agi_dir)
    agi_dir = os.path.normpath(args.agi_dir)
    assert os.path.isdir(args.out_dir)
    out_dir = os.path.normpath(args.out_dir)

    #### Check test parameters
    test_params = {}
    required_keys = ['apk', 'package', 'activity', 'startframe', 'numframes']
    botutil.load_params(test_params, required_keys=required_keys)

    #### Install APK
    botutil.install_apk(test_params)

    #### Call benchmark command
    gapit = os.path.join(agi_dir, 'gapit')
    dumptrace = os.path.join(out_dir, 'benchmark.systrace')
    cmd = [
        gapit, 'benchmark', '-startframe', test_params['startframe'],
        '-numframes', test_params['numframes'], '-dumptrace', dumptrace
    ]

    if 'additionalargs' in test_params.keys():
        cmd += ['-additionalargs', test_params['additionalargs']]

    cmd += [test_params['package'] + '/' + test_params['activity']]

    p = botutil.runcmd(cmd)

    #### Save gfxtrace
    gfxtrace = 'benchmark.gfxtrace'
    if os.path.isfile(gfxtrace):
        dest = os.path.join(out_dir, gfxtrace)
        os.rename(gfxtrace, dest)

    return p.returncode
Beispiel #7
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('adb_path', help='Path to adb command')
    parser.add_argument('agi_dir', help='Path to AGI build')
    parser.add_argument('out_dir', help='Path to output directory')
    args = parser.parse_args()

    #### Early checks and sanitization
    assert os.path.isfile(args.adb_path)
    adb_path = os.path.abspath(args.adb_path)
    assert os.path.isdir(args.agi_dir)
    agi_dir = os.path.abspath(args.agi_dir)
    assert os.path.isdir(args.out_dir)
    out_dir = os.path.abspath(args.out_dir)
    gapit_path = os.path.join(agi_dir, 'gapit')

    #### Create BotUtil with relevant adb and gapit paths
    bu = botutil.BotUtil(adb_path)
    bu.set_gapit_path(gapit_path)

    #### Load test parameters
    test_params = {}
    # Do not require 'apk' and 'package' params, as some drivers are just
    # obtained by system update.
    botutil.load_params(test_params)

    #### Install APK if need be
    if 'apk' in test_params.keys():
        if not 'package' in test_params.keys():
            botutil.log('Error: have "apk" but no "package" in params.json')
            return 1
        bu.install_apk(test_params)

    #### Call gapit command
    gapit_args = ['-os', 'android']
    p = bu.gapit('validate_gpu_profiling', gapit_args)
    return p.returncode
Beispiel #8
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('adb_path', help='Path to adb command')
    parser.add_argument('agi_dir', help='Path to AGI build')
    parser.add_argument('out_dir', help='Path to output directory')
    args = parser.parse_args()

    #### Early checks and sanitization
    assert os.path.isfile(args.adb_path)
    adb_path = os.path.abspath(args.adb_path)
    assert os.path.isdir(args.agi_dir)
    agi_dir = os.path.abspath(args.agi_dir)
    assert os.path.isdir(args.out_dir)
    out_dir = os.path.abspath(args.out_dir)
    gapit_path = os.path.join(agi_dir, 'gapit')

    #### Create BotUtil with relevant adb and gapit paths
    bu = botutil.BotUtil(adb_path)
    bu.set_gapit_path(gapit_path)

    #### Test parameters
    test_params = {
        'startframe': '100',
        'numframes': '5',
        'observe_frames': '1',
        'api': 'vulkan',
    }
    required_keys = ['apk', 'package', 'activity']
    botutil.load_params(test_params, required_keys=required_keys)

    #### Install APK
    bu.install_apk(test_params)

    #### Trace the app
    gfxtrace = os.path.join(out_dir, test_params['package'] + '.gfxtrace')
    args = [
        '-api', test_params['api'],
        '-start-at-frame', test_params['startframe'],
        '-capture-frames', test_params['numframes'],
        '-observe-frames', test_params['observe_frames'],
        '-out', gfxtrace
    ]

    if 'additionalargs' in test_params.keys():
        args += ['-additionalargs', test_params['additionalargs']]

    args += [test_params['package'] + '/' + test_params['activity']]

    p = bu.gapit('trace', args)
    if p.returncode != 0:
        return 1

    #### Stop the app asap for device cool-down
    bu.adb(['shell', 'am', 'force-stop', test_params['package']])

    #### Replay
    # Use the 'sxs-frames' mode that generates a series of PNGs rather
    # than an mp4 video. This makes inspection easier, and removes the
    # dependency on ffmpeg on the running hosts.
    videooutfile = os.path.join(out_dir, test_params['package'] + '.frame.png')
    gapit_args = [
        '-gapir-nofallback',
        '-type', 'sxs-frames',
        '-frames-minimum', test_params['numframes'],
        '-out', videooutfile,
        gfxtrace
    ]
    p = bu.gapit('video', gapit_args)
    if p.returncode != 0:
        return p.returncode

    #### Screenshot test to retrieve mid-frame resources
    # This is meant to test the command buffer splitter, which is invoked to be
    # able to retrieve the framebuffer in the middle of a render pass. We ask
    # for the framebuffer at the 5th draw call, this number was choosen because:
    # it is low enough to be present in most frames (i.e. we expect frames to
    # have at least 5 draw calls), and it hopefully falls in the middle of a
    # renderpass. Also, we don't want to have a random number here, as we want
    # to keep the tests as reproducible as feasible.
    screenshotfile = os.path.join(out_dir, test_params['package'] + '.png')
    gapit_args = [
        '-executeddraws', '5',
        '-out', screenshotfile,
        gfxtrace
    ]
    p = bu.gapit('screenshot', gapit_args)
    if p.returncode != 0:
        return p.returncode

    #### Frame profiler
    # Check that frame profiling generates valid JSON
    profile_json = os.path.join(out_dir, test_params['package'] + '.profiling.json')
    gapit_args = [
        '-json',
        '-out', profile_json,
        gfxtrace
    ]
    p = bu.gapit('profile', gapit_args)
    if p.returncode != 0:
        return p.returncode
    assert botutil.is_valid_json(profile_json)

    #### Frame graph
    # Check that framegraph generates valid JSON
    framegraph_json = os.path.join(out_dir, test_params['package'] + '.framegraph.json')
    gapit_args = [
        '-json', framegraph_json,
        gfxtrace
    ]
    p = bu.gapit('framegraph', gapit_args)
    if p.returncode != 0:
        return p.returncode
    assert botutil.is_valid_json(framegraph_json)

    #### All tests have passed, return success
    return 0
Beispiel #9
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('agi_dir', help='Path to AGI build')
    parser.add_argument('out_dir', help='Path to output directory')
    args = parser.parse_args()

    #### Early checks and sanitization
    assert os.path.isdir(args.agi_dir)
    agi_dir = os.path.normpath(args.agi_dir)
    assert os.path.isdir(args.out_dir)
    out_dir = os.path.normpath(args.out_dir)

    #### Test parameters
    test_params = {
        'startframe': '100',
        'numframes': '5',
        'observe_frames': '1',
        'api': 'vulkan',
    }
    required_keys = ['apk', 'package', 'activity']
    botutil.load_params(test_params, required_keys=required_keys)

    #### Install APK
    botutil.install_apk(test_params)

    #### Trace the app
    gapit = os.path.join(agi_dir, 'gapit')
    gfxtrace = os.path.join(out_dir, test_params['package'] + '.gfxtrace')
    cmd = [
        gapit, 'trace', '-api', test_params['api'], '-start-at-frame',
        test_params['startframe'], '-capture-frames', test_params['numframes'],
        '-observe-frames', test_params['observe_frames'], '-out', gfxtrace
    ]

    if 'additionalargs' in test_params.keys():
        cmd += ['-additionalargs', test_params['additionalargs']]

    cmd += [test_params['package'] + '/' + test_params['activity']]

    p = botutil.runcmd(cmd)
    if p.returncode != 0:
        return 1

    #### Stop the app asap for device cool-down
    botutil.adb(['shell', 'am', 'force-stop', test_params['package']])

    #### Replay
    # Use the 'sxs-frames' mode that generates a series of PNGs rather
    # than an mp4 video. This makes inspection easier, and removes the
    # dependency on ffmpeg on the running hosts.
    videooutfile = os.path.join(out_dir, test_params['package'] + '.frame.png')
    cmd = [
        gapit, 'video', '-gapir-nofallback', '-type', 'sxs-frames',
        '-frames-minimum', test_params['numframes'], '-out', videooutfile,
        gfxtrace
    ]
    p = botutil.runcmd(cmd)
    if p.returncode != 0:
        return p.returncode

    #### Screenshot test to retrieve mid-frame resources
    screenshotfile = os.path.join(out_dir, test_params['package'] + '.png')
    cmd = [
        gapit, 'screenshot', '-executeddraws', '5', '-out', screenshotfile,
        gfxtrace
    ]
    p = botutil.runcmd(cmd)
    if p.returncode != 0:
        return p.returncode

    #### Frame profiler
    # Check that frame profiling generates valid JSON
    profile_json = os.path.join(out_dir,
                                test_params['package'] + '.profiling.json')
    cmd = [gapit, 'profile', '-json', '-out', profile_json, gfxtrace]
    p = botutil.runcmd(cmd)
    if p.returncode != 0:
        return p.returncode
    assert botutil.is_valid_json(profile_json)

    #### Frame graph
    # Check that framegraph generates valid JSON
    framegraph_json = os.path.join(out_dir,
                                   test_params['package'] + '.framegraph.json')
    cmd = [gapit, 'framegraph', '-json', framegraph_json, gfxtrace]
    p = botutil.runcmd(cmd)
    if p.returncode != 0:
        return p.returncode
    assert botutil.is_valid_json(framegraph_json)

    #### All tests have passed, return success
    return 0
Beispiel #10
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('adb_path', help='Path to adb command')
    parser.add_argument('agi_dir', help='Path to AGI build')
    parser.add_argument('out_dir', help='Path to output directory')
    args = parser.parse_args()

    #### Early checks and sanitization
    assert os.path.isfile(args.adb_path)
    adb_path = os.path.abspath(args.adb_path)
    assert os.path.isdir(args.agi_dir)
    agi_dir = os.path.abspath(args.agi_dir)
    assert os.path.isdir(args.out_dir)
    out_dir = os.path.abspath(args.out_dir)
    gapit_path = os.path.join(agi_dir, 'gapit')

    #### Create BotUtil with relevant adb and gapit paths
    bu = botutil.BotUtil(adb_path)
    bu.set_gapit_path(gapit_path)

    #### Test parameters
    test_params = {}
    required_keys = ['apk', 'package', 'activity', 'perfetto_config']
    botutil.load_params(test_params, required_keys=required_keys)

    #### Install APK
    bu.install_apk(test_params)

    #### Retrieve device-specific perfetto config
    p = bu.adb(['shell', 'getprop', 'ro.product.device'])
    device = p.stdout.rstrip()
    if not device in test_params['perfetto_config'].keys():
        botutil.log('Error: no perfetto config found for device: ' + device)
        return 1
    perfetto_config = test_params['perfetto_config'][device]
    if not os.path.isfile(perfetto_config):
        botutil.log('Error: perfetto config file not found: ' +
                    perfetto_config)
        return 1

    #### Trace the app
    perfetto_trace = os.path.join(out_dir,
                                  test_params['package'] + '.perfetto')
    gapit_args = [
        '-api', 'perfetto', '-for', '5s', '-perfetto', perfetto_config, '-out',
        perfetto_trace
    ]

    if 'additionalargs' in test_params.keys():
        gapit_args += ['-additionalargs', test_params['additionalargs']]

    gapit_args += [test_params['package'] + '/' + test_params['activity']]

    p = bu.gapit('trace', gapit_args)
    if p.returncode != 0:
        return 1

    #### Stop the app asap for device cool-down
    bu.adb(['shell', 'am', 'force-stop', test_params['package']])

    #### Check perfetto trace validity by formatting it to JSON
    perfetto_json = perfetto_trace.replace('.perfetto', '.json')
    gapit_args = [
        '-mode', 'metrics', '-format', 'json', '-out', perfetto_json,
        perfetto_trace
    ]
    p = bu.gapit('perfetto', gapit_args)
    return p.returncode