Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: android_webview/tools/run_cts.py

Issue 2551353004: Add helper script for running CTS APKs stored in the GS buckets. (Closed)
Patch Set: Add helper script for running CTS APKs stored in the GS buckets. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
3 # Copyright 2016 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 """Runs the CTS test APKs stored in GS."""
8
9 import argparse
10 import json
11 import os
12 import shutil
13 import sys
14 import tempfile
15
16 # pylint: disable=import-error
jbudorick 2016/12/12 18:40:56 Disable this on a line-by-line basis and remove th
mikecase (-- gone --) 2016/12/12 19:50:26 Done
17 sys.path.append(os.path.join(
18 os.path.dirname(__file__), os.pardir, os.pardir, 'build', 'android'))
19 import devil_chromium
20 from devil.utils import cmd_helper
21
22 sys.path.append(os.path.join(
23 os.path.dirname(__file__), os.pardir, os.pardir, 'build'))
24 import find_depot_tools
25 # pylint: enable=import-error
26
27 _CTS_BUCKET = 'gs://chromium-cts'
28
29 _GSUTIL_PATH = os.path.join(find_depot_tools.DEPOT_TOOLS_PATH, 'gsutil.py')
30 _TEST_RUNNER_PATH = os.path.join(
31 os.path.dirname(__file__), os.pardir, os.pardir,
32 'build', 'android', 'test_runner.py')
33
34 _EXPECTED_FAILURES_FILE = os.path.join(
35 os.path.dirname(__file__), 'cts_config', 'expected_failure_on_bot.json')
36 _WEBVIEW_CTS_GCS_PATH_FILE = os.path.join(
37 os.path.dirname(__file__), 'cts_config', 'webview_cts_gcs_path.json')
38
39
40 def GetCtsPath(arch, platform):
41 """Gets relative path CTS APK is stored."""
jbudorick 2016/12/12 18:40:56 nit: this sounds like you're missing a word or two
mikecase (-- gone --) 2016/12/12 19:50:26 Done.
42 with open(_WEBVIEW_CTS_GCS_PATH_FILE) as f:
43 cts_gcs_path_info = json.load(f)
44 try:
45 return cts_gcs_path_info[arch][platform]['apk']
46 except KeyError:
47 raise Exception('No CTS test available for arch:%s, android:%s' %
48 (arch, platform))
49
50
51 def GetExpectedFailures():
52 """Gets list of tests expected to fail."""
53 with open(_EXPECTED_FAILURES_FILE) as f:
54 expected_failures_info = json.load(f)
55 expected_failures = []
56 for class_name, methods in expected_failures_info.iteritems():
57 expected_failures.extend(['%s#%s' % (class_name, m['name'])
58 for m in methods])
59 return expected_failures
60
61
62 def DownloadAndRunCTS(args, test_runner_args):
63 base_cts_dir = None
64 delete_cts_dir = False
65 try:
66 relative_cts_path = GetCtsPath(args.arch, args.platform)
67
68 if args.apk_dir:
69 base_cts_dir = args.apk_dir
70 else:
71 base_cts_dir = tempfile.mkdtemp()
72 delete_cts_dir = True
73
74 local_cts_path = os.path.join(base_cts_dir, relative_cts_path)
75 google_storage_cts_path = '%s/%s' % (_CTS_BUCKET, relative_cts_path)
76
77 # Download CTS APK if needed.
78 if not os.path.exists(local_cts_path):
79 if cmd_helper.RunCmd(
80 [_GSUTIL_PATH, 'cp', google_storage_cts_path, local_cts_path]):
81 raise Exception('Error downloading CTS from Google Storage.')
82
83 test_runner_args += ['--test-apk', local_cts_path]
84 # TODO(mikecase): This doesn't work at all with the
jbudorick 2016/12/12 18:40:56 -f and --gtest-filter are the same?
mikecase (-- gone --) 2016/12/12 19:50:26 yeah, custom -f option wont work with --skip-expec
85 # --gtest-filter test runner option currently. The
86 # filter options will just override eachother.
87 if args.skip_expected_failures:
88 test_runner_args += ['-f=-%s' % ':'.join(GetExpectedFailures())]
89 return cmd_helper.RunCmd(
90 [_TEST_RUNNER_PATH] + ['instrumentation'] + test_runner_args)
jbudorick 2016/12/12 18:40:56 nit: [_TEST_RUNNER_PATH, 'instrumentation'] + test
mikecase (-- gone --) 2016/12/12 19:50:26 Done
91 finally:
92 if delete_cts_dir and base_cts_dir:
93 shutil.rmtree(base_cts_dir)
94
95
96 def main():
97 parser = argparse.ArgumentParser()
98 parser.add_argument(
99 '--arch',
100 choices=['arm_64'],
jbudorick 2016/12/12 18:40:56 Just arm64?
the real yoland 2016/12/12 19:04:14 I believe this is so because the recipe module fun
mikecase (-- gone --) 2016/12/12 19:50:26 Probably should be, but since I store the CTS APKs
101 default='arm_64',
102 help='Arch for CTS tests.')
103 parser.add_argument(
104 '--platform',
105 choices=['L', 'M', 'N'],
106 required=True,
107 help='Android platform version for CTS tests.')
108 parser.add_argument(
109 '--skip-expected-failures',
110 action='store_true',
111 help='Option to skip all tests that are expected to fail.')
112 parser.add_argument(
113 '--apk-dir',
114 help='Directory to load/save CTS APKs. Will try to load CTS APK '
115 'from this directory before downloading from Google Storage '
116 'and will then cache APK here.')
117
118 args, test_runner_args = parser.parse_known_args()
119 devil_chromium.Initialize()
120
121 return DownloadAndRunCTS(args, test_runner_args)
122
123
124 if __name__ == '__main__':
125 sys.exit(main())
OLDNEW
« android_webview/tools/pylintrc ('K') | « android_webview/tools/pylintrc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698