• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
7import os
8import subprocess
9import tempfile
10import sys
11
12def skqp(build):
13    def adb(*args):
14        sys.stdout.write("adb '" + "' '".join(args) + "'\n")
15        subprocess.check_call(['adb'] + list(args))
16
17    assert os.path.isdir(build)
18    build = os.path.abspath(build)
19
20    os.chdir(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
21
22    adb('shell', 'rm -rf /data/local/tmp/skqp; mkdir -p /data/local/tmp/skqp/skqp_assets')
23
24    adb('push',
25        os.path.join(*'platform_tools/android/apps/skqp/src/main/assets/skqp'.split('/')),
26        '/data/local/tmp/skqp/skqp_assets')
27    adb('push',
28        os.path.join(*'out/skqp/gmkb'.split('/')), '/data/local/tmp/skqp/skqp_assets')
29    adb('push', 'resources', '/data/local/tmp/skqp/skqp_assets')
30
31    adb('push', os.path.join(build, 'skqp'), '/data/local/tmp/skqp/skqp')
32
33    cmd = "cd /data/local/tmp/skqp; ./skqp skqp_assets '' report"
34    sys.stdout.write("adb 'shell' '%s'\n" % cmd)
35    ret = subprocess.call(['adb', 'shell', cmd])
36
37    tmpdir = tempfile.mkdtemp(prefix='skqp')
38
39    adb('pull', "/data/local/tmp/skqp/report", tmpdir)
40
41    return ret, os.path.join(tmpdir, 'report')
42
43if __name__ == '__main__':
44    if len(sys.argv) != 2 or not os.path.isdir(sys.argv[1]):
45        sys.stderr.write('Usage\n  %s BUILD_DIR\n\n' % sys.argv[0])
46        sys.exit(1)
47    try:
48        ret, report = skqp(sys.argv[1])
49    except subprocess.CalledProcessError:
50        sys.stderr.write('Command failed.\n')
51        sys.exit(1)
52
53    sys.stdout.write('\nReturn code: %d\nOutput written to "%s"\n' % (ret, report))
54    os.system("bin/sysopen " + os.path.join(report, 'report.html'))
55