Commit 6a84e612 authored by Andrew Luo's avatar Andrew Luo Committed by Commit Bot

Improve webview_cts_gcs_path.json format

Bug: 902958
Change-Id: I1c8a6fbc21c871ced824c2b387196d2eae856728
Reviewed-on: https://chromium-review.googlesource.com/c/1324991Reviewed-by: default avatarBo <boliu@chromium.org>
Commit-Queue: Andrew Luo <aluo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606346}
parent 058dced8
{ {
"_usage":
{
" The format of this file is as follows. The excludes and includes lists under test_runs are mutually exclusive, if not specified, all tests in apk will run.":
{
"<arch>": {
"<android SDK Code, such as L, M, N, ...>": {
"filename": "<relative path to cts_archive_dir of cts zip>",
"_origin": "<branch@buildid>",
"unzip_dir": "<relative path to work directory where cts should be unzipped to>",
"test_runs": [
{
"apk": "location of the test apk in the cts zip file",
"excludes": [
{
"match": "<class#testcase (wildcard supported) expression of test to skip>",
"_bug_id": "<bug reference comment, optional>"
}]
},
{
"apk": "location of the test apk in the cts zip file",
"includes": [
{
"match": "<class#testcase (wildcard supported) expression of test to run>"
}]
}]
}
}
}
},
"arm64": { "arm64": {
"L": { "L": {
"filename": "arm64/L/android-cts-arm_64-4607260.zip", "filename": "arm64/L/android-cts-arm_64-4607260.zip",
"apkdir": "arm64/L/4607260/", "_origin": "aosp-lollipop-mr1-cts-dev@4607260",
"tests": [ "unzip_dir": "arm64/L/4607260/",
{"android-cts/repository/testcases/CtsWebkitTestCases.apk": ""}, "test_runs": [
{"android-cts/repository/testcases/CtsWidgetTestCases.apk": "android.widget.cts.RemoteViewsActivityTest#testWebView"} {
], "apk": "android-cts/repository/testcases/CtsWebkitTestCases.apk"
"_origin": "aosp-lollipop-mr1-cts-dev@4607260" },
{
"apk": "android-cts/repository/testcases/CtsWidgetTestCases.apk",
"includes": [
{
"match": "android.widget.cts.RemoteViewsActivityTest#testWebView"
}]
}]
}, },
"M": { "M": {
"filename": "arm64/M/android-cts-arm_64-4607285.zip", "filename": "arm64/M/android-cts-arm_64-4607285.zip",
"apkdir": "arm64/M/4607285/", "_origin": "aosp-marshmallow-cts-dev@4607285",
"tests": [ "unzip_dir": "arm64/M/4607285/",
{"android-cts/repository/testcases/CtsWebkitTestCases.apk": ""}, "test_runs": [
{"android-cts/repository/testcases/CtsWidgetTestCases.apk": "android.widget.cts.RemoteViewsActivityTest#testWebView"} {
], "apk": "android-cts/repository/testcases/CtsWebkitTestCases.apk"
"_origin": "aosp-marshmallow-cts-dev@4607285" },
{
"apk": "android-cts/repository/testcases/CtsWidgetTestCases.apk",
"includes": [
{
"match": "android.widget.cts.RemoteViewsActivityTest#testWebView"
}]
}]
}, },
"N": { "N": {
"filename": "arm64/N/android-cts-arm_64-4606956.zip", "filename": "arm64/N/android-cts-arm_64-4606956.zip",
"apkdir": "arm64/N/4606956/", "_origin": "aosp-nougat-cts-release@4606956",
"tests": [ "unzip_dir": "arm64/N/4606956/",
{"android-cts/testcases/CtsWebkitTestCases.apk": ""}, "test_runs": [
{"android-cts/testcases/CtsWidgetTestCases.apk": "android.widget.cts.RemoteViewsActivityTest#testWebView"} {
], "apk": "android-cts/testcases/CtsWebkitTestCases.apk"
"_origin": "aosp-nougat-cts-release@4606956" },
{
"apk": "android-cts/testcases/CtsWidgetTestCases.apk",
"includes": [
{
"match": "android.widget.cts.RemoteViewsActivityTest#testWebView"
}]
}]
}, },
"O": { "O": {
"filename": "arm64/O/android-cts-arm_64-4666824.zip", "filename": "arm64/O/android-cts-arm_64-4666824.zip",
"apkdir": "arm64/O/4666824/", "_origin": "aosp-oreo-cts-release@4666824",
"tests": [ "unzip_dir": "arm64/O/4666824/",
{"android-cts/testcases/CtsWebkitTestCases.apk": ""}, "test_runs": [
{"android-cts/testcases/CtsWebViewStartupApp.apk": ""} {
], "apk": "android-cts/testcases/CtsWebkitTestCases.apk"
"_origin": "aosp-oreo-cts-release@4666824" },
{
"apk": "android-cts/testcases/CtsWebViewStartupApp.apk"
}]
} }
} }
} }
...@@ -75,8 +75,24 @@ def GetExpectedFailures(): ...@@ -75,8 +75,24 @@ def GetExpectedFailures():
for m in methods]) for m in methods])
return expected_failures return expected_failures
def GetTestRunFilterArg(test_run, skip_expected_failures):
skips = []
if skip_expected_failures:
skips = GetExpectedFailures()
excludes = test_run.get("excludes", [])
includes = test_run.get("includes", [])
assert len(excludes) == 0 or len(includes) == 0, \
"test_runs error, can't have both includes and excludes: %s" % test_run
if len(includes) > 0:
return ['-f=' + ':'.join([i["match"] for i in includes])]
else:
skips.extend([i["match"] for i in excludes])
if len(skips) > 0:
return ['-f=' + "-" + ':'.join(skips)]
return []
def RunCTS(test_runner_args, local_cts_dir, apk, test_filter, def RunCTS(test_runner_args, local_cts_dir, test_run,
skip_expected_failures=True, json_results_file=None): skip_expected_failures=True, json_results_file=None):
"""Run tests in apk using test_runner script at _TEST_RUNNER_PATH. """Run tests in apk using test_runner script at _TEST_RUNNER_PATH.
...@@ -85,20 +101,22 @@ def RunCTS(test_runner_args, local_cts_dir, apk, test_filter, ...@@ -85,20 +101,22 @@ def RunCTS(test_runner_args, local_cts_dir, apk, test_filter,
is set to False, test results will be stored in is set to False, test results will be stored in
the json_results_file file if specified the json_results_file file if specified
""" """
apk = test_run['apk']
local_test_runner_args = test_runner_args + ['--test-apk', local_test_runner_args = test_runner_args + ['--test-apk',
os.path.join(local_cts_dir, apk)] os.path.join(local_cts_dir, apk)]
# TODO(mikecase): This doesn't work at all with the # TODO(mikecase): This doesn't work at all with the
# --gtest-filter test runner option currently. The # --gtest-filter test runner option currently. The
# filter options will just override eachother. # filter options will just override eachother.
if skip_expected_failures:
local_test_runner_args += ['-f=-%s' % ':'.join(GetExpectedFailures())]
# The preferred method is to specify test filters per release in # The preferred method is to specify test filters per release in
# the CTS_GCS path file. It will override any # the CTS_GCS path file. It will override any
# previous filters, including ones in expected failures # previous filters, including ones in expected failures
# file. # file.
if test_filter: local_test_runner_args.extend(GetTestRunFilterArg(test_run,
local_test_runner_args += ['-f=' + test_filter] skip_expected_failures))
if json_results_file: if json_results_file:
local_test_runner_args += ['--json-results-file=%s' % local_test_runner_args += ['--json-results-file=%s' %
json_results_file] json_results_file]
...@@ -150,7 +168,9 @@ def ExtractCTSZip(args): ...@@ -150,7 +168,9 @@ def ExtractCTSZip(args):
cts_zip_path = os.path.join(_CTS_ARCHIVE_DIR, relative_cts_zip_path) cts_zip_path = os.path.join(_CTS_ARCHIVE_DIR, relative_cts_zip_path)
local_cts_dir = os.path.join(base_cts_dir, local_cts_dir = os.path.join(base_cts_dir,
GetCtsInfo(args.arch, args.platform, 'apkdir')) GetCtsInfo(args.arch, args.platform,
'unzip_dir')
)
zf = zipfile.ZipFile(cts_zip_path, 'r') zf = zipfile.ZipFile(cts_zip_path, 'r')
zf.extractall(local_cts_dir) zf.extractall(local_cts_dir)
return (local_cts_dir, base_cts_dir, delete_cts_dir) return (local_cts_dir, base_cts_dir, delete_cts_dir)
...@@ -170,26 +190,25 @@ def RunAllCTSTests(args, test_runner_args): ...@@ -170,26 +190,25 @@ def RunAllCTSTests(args, test_runner_args):
cts_result = 0 cts_result = 0
json_results_file = args.json_results_file json_results_file = args.json_results_file
try: try:
cts_tests_info = GetCtsInfo(args.arch, args.platform, 'tests') cts_test_runs = GetCtsInfo(args.arch, args.platform, 'test_runs')
cts_results_json = {} cts_results_json = {}
for cts_tests_item in cts_tests_info: for cts_test_run in cts_test_runs:
for relative_apk_path, test_filter in cts_tests_item.iteritems(): iteration_cts_result = 0
iteration_cts_result = 0 if json_results_file:
if json_results_file: with tempfile.NamedTemporaryFile() as iteration_json_file:
with tempfile.NamedTemporaryFile() as iteration_json_file:
iteration_cts_result = RunCTS(test_runner_args, local_cts_dir,
relative_apk_path, test_filter,
args.skip_expected_failures,
iteration_json_file.name)
with open(iteration_json_file.name) as f:
additional_results_json = json.load(f)
MergeTestResults(cts_results_json, additional_results_json)
else:
iteration_cts_result = RunCTS(test_runner_args, local_cts_dir, iteration_cts_result = RunCTS(test_runner_args, local_cts_dir,
relative_apk_path, test_filter, cts_test_run,
args.skip_expected_failures) args.skip_expected_failures,
if iteration_cts_result: iteration_json_file.name)
cts_result = iteration_cts_result with open(iteration_json_file.name) as f:
additional_results_json = json.load(f)
MergeTestResults(cts_results_json, additional_results_json)
else:
iteration_cts_result = RunCTS(test_runner_args, local_cts_dir,
cts_test_run,
args.skip_expected_failures)
if iteration_cts_result:
cts_result = iteration_cts_result
if json_results_file: if json_results_file:
with open(json_results_file, 'w') as f: with open(json_results_file, 'w') as f:
json.dump(cts_results_json, f, indent=2) json.dump(cts_results_json, f, indent=2)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment