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

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
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 GetGSCtsApkPath(arch, platform):
41 """Gets path of CTS APK from Google Storage"""
42 with open(_WEBVIEW_CTS_GCS_PATH_FILE) as f:
43 cts_gcs_path_info = json.load(f)
44 try:
45 return '%s/%s' % (_CTS_BUCKET, 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 temp_dir = None
the real yoland 2016/12/08 19:16:03 hmm, I wonder if we can store CTS apk in a third_p
mikecase (-- gone --) 2016/12/08 19:17:58 How about an optionally --apk-dir arg. If specifie
mikecase (-- gone --) 2016/12/08 22:58:43 CTS are now cached locally if you specify apk-dir
the real yoland 2016/12/09 20:56:36 ya, make sense, not everyone need CTS, third_party
64 try:
65 temp_dir = tempfile.mkdtemp()
66 cmd = [_GSUTIL_PATH, 'cp',
67 GetGSCtsApkPath(args.arch, args.platform),
68 temp_dir]
69 if cmd_helper.RunCmd(cmd):
70 raise Exception('Error downloading CTS from Google Storage.')
71 cts_apk_name = os.listdir(temp_dir)[0]
72 local_cts_apk_path = os.path.join(temp_dir, cts_apk_name)
73
74 test_runner_args += ['--test-apk', local_cts_apk_path]
75 # TODO(mikecase): This doesn't work at all with the
76 # --gtest-filter test runner option currently. The
77 # filter options will just override eachother.
78 if args.skip_expected_failures:
79 test_runner_args += ['-f=-%s' % ':'.join(GetExpectedFailures())]
80 return cmd_helper.RunCmd(
81 [_TEST_RUNNER_PATH] + ['instrumentation'] + test_runner_args)
82 finally:
83 if temp_dir:
84 shutil.rmtree(temp_dir)
85
86
87 def main():
88 parser = argparse.ArgumentParser()
89 parser.add_argument(
90 '--arch',
91 choices=['arm_64'],
92 required=True,
93 help='Arch for CTS tests.')
94 parser.add_argument(
95 '--platform',
96 choices=['L', 'M', 'N'],
97 required=True,
98 help='Android platform version for CTS tests.')
99 parser.add_argument(
100 '--skip-expected-failures',
101 action='store_true')
102
103 args, test_runner_args = parser.parse_known_args()
104 devil_chromium.Initialize()
105
106 return DownloadAndRunCTS(args, test_runner_args)
107
108
109 if __name__ == '__main__':
110 sys.exit(main())
OLDNEW
« android_webview/tools/cts_config/webview_cts_gcs_path.json ('K') | « android_webview/tools/pylintrc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698