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
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
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
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
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 = ['apk', 'package', 'activity', 'perfetto_config'] botutil.load_params(test_params, required_keys=required_keys) #### Install APK botutil.install_apk(test_params) #### Retrieve device-specific perfetto config p = botutil.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 gapit = os.path.join(agi_dir, 'gapit') perfetto_trace = os.path.join(out_dir, test_params['package'] + '.perfetto') cmd = [ gapit, 'trace', '-api', 'perfetto', '-for', '5s', '-perfetto', perfetto_config, '-out', perfetto_trace ] 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']]) #### Check perfetto trace validity by formatting it to JSON perfetto_json = perfetto_trace.replace('.perfetto', '.json') cmd = [ gapit, 'perfetto', '-mode', 'metrics', '-format', 'json', '-out', perfetto_json, perfetto_trace ] p = botutil.runcmd(cmd) return p.returncode