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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: android_webview/tools/run_cts.py
diff --git a/android_webview/tools/run_cts.py b/android_webview/tools/run_cts.py
new file mode 100755
index 0000000000000000000000000000000000000000..058b0f83b12a3ce0ca64cacf7c1113f2dfb254d0
--- /dev/null
+++ b/android_webview/tools/run_cts.py
@@ -0,0 +1,110 @@
+#!/usr/bin/env python
+#
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Runs the CTS test APKs stored in GS."""
+
+import argparse
+import json
+import os
+import shutil
+import sys
+import tempfile
+
+# pylint: disable=import-error
+sys.path.append(os.path.join(
+ os.path.dirname(__file__), os.pardir, os.pardir, 'build', 'android'))
+import devil_chromium
+from devil.utils import cmd_helper
+
+sys.path.append(os.path.join(
+ os.path.dirname(__file__), os.pardir, os.pardir, 'build'))
+import find_depot_tools
+# pylint: enable=import-error
+
+_CTS_BUCKET = 'gs://chromium-cts'
+
+_GSUTIL_PATH = os.path.join(find_depot_tools.DEPOT_TOOLS_PATH, 'gsutil.py')
+_TEST_RUNNER_PATH = os.path.join(
+ os.path.dirname(__file__), os.pardir, os.pardir,
+ 'build', 'android', 'test_runner.py')
+
+_EXPECTED_FAILURES_FILE = os.path.join(
+ os.path.dirname(__file__), 'cts_config', 'expected_failure_on_bot.json')
+_WEBVIEW_CTS_GCS_PATH_FILE = os.path.join(
+ os.path.dirname(__file__), 'cts_config', 'webview_cts_gcs_path.json')
+
+
+def GetGSCtsApkPath(arch, platform):
+ """Gets path of CTS APK from Google Storage"""
+ with open(_WEBVIEW_CTS_GCS_PATH_FILE) as f:
+ cts_gcs_path_info = json.load(f)
+ try:
+ return '%s/%s' % (_CTS_BUCKET, cts_gcs_path_info[arch][platform]['apk'])
+ except KeyError:
+ raise Exception('No CTS test available for arch:%s, android:%s' %
+ (arch, platform))
+
+
+def GetExpectedFailures():
+ """Gets list of tests expected to fail."""
+ with open(_EXPECTED_FAILURES_FILE) as f:
+ expected_failures_info = json.load(f)
+ expected_failures = []
+ for class_name, methods in expected_failures_info.iteritems():
+ expected_failures.extend(['%s#%s' % (class_name, m['name'])
+ for m in methods])
+ return expected_failures
+
+
+def DownloadAndRunCTS(args, test_runner_args):
+ 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
+ try:
+ temp_dir = tempfile.mkdtemp()
+ cmd = [_GSUTIL_PATH, 'cp',
+ GetGSCtsApkPath(args.arch, args.platform),
+ temp_dir]
+ if cmd_helper.RunCmd(cmd):
+ raise Exception('Error downloading CTS from Google Storage.')
+ cts_apk_name = os.listdir(temp_dir)[0]
+ local_cts_apk_path = os.path.join(temp_dir, cts_apk_name)
+
+ test_runner_args += ['--test-apk', local_cts_apk_path]
+ # TODO(mikecase): This doesn't work at all with the
+ # --gtest-filter test runner option currently. The
+ # filter options will just override eachother.
+ if args.skip_expected_failures:
+ test_runner_args += ['-f=-%s' % ':'.join(GetExpectedFailures())]
+ return cmd_helper.RunCmd(
+ [_TEST_RUNNER_PATH] + ['instrumentation'] + test_runner_args)
+ finally:
+ if temp_dir:
+ shutil.rmtree(temp_dir)
+
+
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument(
+ '--arch',
+ choices=['arm_64'],
+ required=True,
+ help='Arch for CTS tests.')
+ parser.add_argument(
+ '--platform',
+ choices=['L', 'M', 'N'],
+ required=True,
+ help='Android platform version for CTS tests.')
+ parser.add_argument(
+ '--skip-expected-failures',
+ action='store_true')
+
+ args, test_runner_args = parser.parse_known_args()
+ devil_chromium.Initialize()
+
+ return DownloadAndRunCTS(args, test_runner_args)
+
+
+if __name__ == '__main__':
+ sys.exit(main())
« 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