1 #! /usr/bin/env python 2 3 # Copyright 2018 Google Inc. 4 # Use of this source code is governed by a BSD-style license that can be 5 # found in the LICENSE file. 6 7 import os 8 import subprocess 9 import tempfile 10 import sysopen 11 import sys 12 13 def skqp(build): 14 def adb(*args): 15 sys.stdout.write("adb '" + "' '".join(args) + "'\n") 16 subprocess.check_call(['adb'] + list(args)) 17 18 assert os.path.isdir(build) 19 build = os.path.abspath(build) 20 21 os.chdir(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) 22 23 adb('shell', 'rm -rf /data/local/tmp/skqp; mkdir -p /data/local/tmp/skqp') 24 25 adb('push', 26 os.path.join(*'platform_tools/android/apps/skqp/src/main/assets'.split('/')), 27 '/data/local/tmp/skqp/skqp_assets') 28 29 adb('push', os.path.join(build, 'skqp'), '/data/local/tmp/skqp/skqp') 30 31 cmd = "cd /data/local/tmp/skqp; ./skqp skqp_assets report" 32 sys.stdout.write("adb 'shell' '%s'\n" % cmd) 33 ret = subprocess.call(['adb', 'shell', cmd]) 34 35 tmpdir = tempfile.mkdtemp(prefix='skqp') 36 37 adb('pull', "/data/local/tmp/report", tmpdir) 38 39 return ret, os.path.join(tmpdir, 'report') 40 41 if __name__ == '__main__': 42 if len(sys.argv) != 2 or not os.path.isdir(sys.argv[1]): 43 sys.stderr.write('Usage\n %s BUILD_DIR\n\n' % sys.argv[0]) 44 sys.exit(1) 45 try: 46 ret, report = skqp(sys.argv[1]) 47 except subprocess.CalledProcessError: 48 sys.stderr.write('Command failed.\n') 49 sys.exit(1) 50 51 sys.stdout.write('\nReturn code: %d\nOutput written to "%s"\n' % (ret, report)) 52 sysopen.sysopen(os.path.join(report, 'report.html')) 53 54