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

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
« no previous file with comments | « android_webview/tools/pylintrc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
17 sys.path.append(os.path.join(
18 os.path.dirname(__file__), os.pardir, os.pardir, 'build', 'android'))
19 import devil_chromium # pylint: disable=import-error
20 from devil.utils import cmd_helper # pylint: disable=import-error
21
22 sys.path.append(os.path.join(
23 os.path.dirname(__file__), os.pardir, os.pardir, 'build'))
24 import find_depot_tools # pylint: disable=import-error
25
26 _CTS_BUCKET = 'gs://chromium-cts'
27
28 _GSUTIL_PATH = os.path.join(find_depot_tools.DEPOT_TOOLS_PATH, 'gsutil.py')
29 _TEST_RUNNER_PATH = os.path.join(
30 os.path.dirname(__file__), os.pardir, os.pardir,
31 'build', 'android', 'test_runner.py')
32
33 _EXPECTED_FAILURES_FILE = os.path.join(
34 os.path.dirname(__file__), 'cts_config', 'expected_failure_on_bot.json')
35 _WEBVIEW_CTS_GCS_PATH_FILE = os.path.join(
36 os.path.dirname(__file__), 'cts_config', 'webview_cts_gcs_path.json')
37
38
39 def GetCtsPath(arch, platform):
40 """Gets relative path the CTS APK is stored at."""
41 with open(_WEBVIEW_CTS_GCS_PATH_FILE) as f:
42 cts_gcs_path_info = json.load(f)
43 try:
44 return cts_gcs_path_info[arch][platform]['apk']
45 except KeyError:
46 raise Exception('No CTS test available for arch:%s, android:%s' %
47 (arch, platform))
48
49
50 def GetExpectedFailures():
51 """Gets list of tests expected to fail."""
52 with open(_EXPECTED_FAILURES_FILE) as f:
53 expected_failures_info = json.load(f)
54 expected_failures = []
55 for class_name, methods in expected_failures_info.iteritems():
56 expected_failures.extend(['%s#%s' % (class_name, m['name'])
57 for m in methods])
58 return expected_failures
59
60
61 def DownloadAndRunCTS(args, test_runner_args):
62 base_cts_dir = None
63 delete_cts_dir = False
64 try:
65 relative_cts_path = GetCtsPath(args.arch, args.platform)
66
67 if args.apk_dir:
68 base_cts_dir = args.apk_dir
69 else:
70 base_cts_dir = tempfile.mkdtemp()
71 delete_cts_dir = True
72
73 local_cts_path = os.path.join(base_cts_dir, relative_cts_path)
74 google_storage_cts_path = '%s/%s' % (_CTS_BUCKET, relative_cts_path)
75
76 # Download CTS APK if needed.
77 if not os.path.exists(local_cts_path):
78 if cmd_helper.RunCmd(
79 [_GSUTIL_PATH, 'cp', google_storage_cts_path, local_cts_path]):
80 raise Exception('Error downloading CTS from Google Storage.')
81
82 test_runner_args += ['--test-apk', local_cts_path]
83 # TODO(mikecase): This doesn't work at all with the
jbudorick 2016/12/14 16:22:19 Oh, I think I understand what you mean now -- if s
84 # --gtest-filter test runner option currently. The
85 # filter options will just override eachother.
86 if args.skip_expected_failures:
87 test_runner_args += ['-f=-%s' % ':'.join(GetExpectedFailures())]
88 return cmd_helper.RunCmd(
89 [_TEST_RUNNER_PATH, 'instrumentation'] + test_runner_args)
90 finally:
91 if delete_cts_dir and base_cts_dir:
92 shutil.rmtree(base_cts_dir)
93
94
95 def main():
96 parser = argparse.ArgumentParser()
97 parser.add_argument(
98 '--arch',
99 choices=['arm_64'],
sgurun-gerrit only 2016/12/14 01:20:58 does this only work for 64 bits? how about L platf
the real yoland 2016/12/14 01:29:29 Yes, one can run CTS L with this script. This arch
sgurun-gerrit only 2016/12/14 18:00:29 yeah the tests should be in Java all.
100 default='arm_64',
101 help='Arch for CTS tests.')
102 parser.add_argument(
103 '--platform',
104 choices=['L', 'M', 'N'],
105 required=True,
106 help='Android platform version for CTS tests.')
107 parser.add_argument(
108 '--skip-expected-failures',
109 action='store_true',
110 help='Option to skip all tests that are expected to fail.')
111 parser.add_argument(
112 '--apk-dir',
113 help='Directory to load/save CTS APKs. Will try to load CTS APK '
114 'from this directory before downloading from Google Storage '
115 'and will then cache APK here.')
116
117 args, test_runner_args = parser.parse_known_args()
118 devil_chromium.Initialize()
119
120 return DownloadAndRunCTS(args, test_runner_args)
121
122
123 if __name__ == '__main__':
124 sys.exit(main())
OLDNEW
« no previous file with comments | « android_webview/tools/pylintrc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698