Commit 7268f2d1 authored by Tom Anderson's avatar Tom Anderson Committed by Commit Bot

Move static initializer check to a testing script

R=thakis,dpranke

Bug: 110002
Change-Id: I8da8e50930e973bd4bfac261571a66b7bad92778
Cq-Include-Trybots: luci.chromium.try:linux_chromium_archive_rel_ng;luci.chromium.try:mac_chromium_archive_rel_ng;luci.chromium.try:win_archive;luci.chromium.try:win_x64_archive;master.tryserver.chromium.android:android_archive_rel_ng
Reviewed-on: https://chromium-review.googlesource.com/c/1351716
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612544}
parent 9d688e69
...@@ -34,27 +34,9 @@ SRC_DIR = os.path.abspath( ...@@ -34,27 +34,9 @@ SRC_DIR = os.path.abspath(
sys.path.append(os.path.join(SRC_DIR, 'third_party', 'catapult', 'tracing')) sys.path.append(os.path.join(SRC_DIR, 'third_party', 'catapult', 'tracing'))
from tracing.value import convert_chart_json from tracing.value import convert_chart_json
# If something adds a static initializer, revert it, don't increase these
# numbers. We don't accept regressions in static initializers.
#
# Note: Counts for chrome and nacl_helper are one higher in branded builds
# compared to release builds. This is due to a static initializer in
# WelsThreadPool.cpp (https://crbug.com/893594).
EXPECTED_LINUX_SI_COUNTS = {
'chrome': 5,
'nacl_helper': 5,
'nacl_helper_bootstrap': 0,
}
# If something adds a static initializer, revert it, don't increase these
# numbers. We don't accept regressions in static initializers.
EXPECTED_MAC_SI_COUNT = 1 # https://crbug.com/893594
class ResultsCollector(object): class ResultsCollector(object):
def __init__(self): def __init__(self):
self.results = {} self.results = {}
self.failures = []
def add_result(self, name, identifier, value, units): def add_result(self, name, identifier, value, units):
assert name not in self.results assert name not in self.results
...@@ -67,9 +49,6 @@ class ResultsCollector(object): ...@@ -67,9 +49,6 @@ class ResultsCollector(object):
# Legacy printing, previously used for parsing the text logs. # Legacy printing, previously used for parsing the text logs.
print 'RESULT %s: %s= %s %s' % (name, identifier, value, units) print 'RESULT %s: %s= %s %s' % (name, identifier, value, units)
def add_failure(self, failure):
self.failures.append(failure)
def get_size(filename): def get_size(filename):
return os.stat(filename)[stat.ST_SIZE] return os.stat(filename)[stat.ST_SIZE]
...@@ -104,12 +83,6 @@ def run_process(result, command): ...@@ -104,12 +83,6 @@ def run_process(result, command):
return result, stdout return result, stdout
def print_si_fail_hint(path_to_tool):
"""Print a hint regarding how to handle a static initializer failure."""
print '# HINT: To get this list, run %s' % path_to_tool
print '# HINT: diff against the log from the last run to see what changed'
def main_mac(options, args, results_collector): def main_mac(options, args, results_collector):
"""Print appropriate size information about built Mac targets. """Print appropriate size information about built Mac targets.
...@@ -173,55 +146,6 @@ def main_mac(options, args, results_collector): ...@@ -173,55 +146,6 @@ def main_mac(options, args, results_collector):
du_s = re.search(r'(\d+)', stdout).group(1) du_s = re.search(r'(\d+)', stdout).group(1)
print_dict['app_bundle_size'] = (int(du_s) * 1024) print_dict['app_bundle_size'] = (int(du_s) * 1024)
# Count the number of files with at least one static initializer.
si_count = 0
# Find the __DATA,__mod_init_func section.
result, stdout = run_process(result,
['otool', '-l', chromium_framework_executable])
section_index = stdout.find('sectname __mod_init_func')
if section_index != -1:
# If the section exists, the "size" line must follow it.
initializers_s = re.search('size 0x([0-9a-f]+)',
stdout[section_index:]).group(1)
word_size = 8 # Assume 64 bit
si_count = int(initializers_s, 16) / word_size
print_dict['initializers'] = si_count
# For Release builds only, use dump-static-initializers.py to print the
# list of static initializers.
if si_count > EXPECTED_MAC_SI_COUNT and options.target == 'Release':
result = 125
results_collector.add_failure(
'Expected 0 static initializers in %s, but found %d' %
(chromium_framework_executable, si_count))
print '\n# Static initializers in %s:' % chromium_framework_executable
# First look for a dSYM to get information about the initializers. If
# one is not present, check if there is an unstripped copy of the build
# output.
mac_tools_path = os.path.join(os.path.dirname(build_dir),
'tools', 'mac')
if os.path.exists(chromium_framework_dsym):
dump_static_initializers = os.path.join(
mac_tools_path, 'dump-static-initializers.py')
result, stdout = run_process(result, [dump_static_initializers,
chromium_framework_dsym])
print_si_fail_hint('tools/mac/dump-static-initializers.py')
print stdout
else:
show_mod_init_func = os.path.join(
mac_tools_path, 'show_mod_init_func.py')
args = [show_mod_init_func]
if os.path.exists(chromium_framework_unstripped):
args.append(chromium_framework_unstripped)
else:
print '# Warning: Falling back to potentially stripped output.'
args.append(chromium_framework_executable)
result, stdout = run_process(result, args)
print_si_fail_hint('tools/mac/show_mod_init_func.py')
print stdout
results_collector.add_result( results_collector.add_result(
print_dict['app_name'], print_dict['app_name'], print_dict['app_name'], print_dict['app_name'],
print_dict['app_size'], 'bytes') print_dict['app_size'], 'bytes')
...@@ -249,9 +173,6 @@ def main_mac(options, args, results_collector): ...@@ -249,9 +173,6 @@ def main_mac(options, args, results_collector):
results_collector.add_result( results_collector.add_result(
print_dict['app_bundle'], print_dict['app_bundle'], print_dict['app_bundle'], print_dict['app_bundle'],
print_dict['app_bundle_size'], 'bytes') print_dict['app_bundle_size'], 'bytes')
results_collector.add_result(
'chrome-si', 'initializers',
print_dict['initializers'], 'files')
# Found a match, don't check the other base_names. # Found a match, don't check the other base_names.
return result return result
...@@ -279,15 +200,6 @@ def check_linux_binary(target_dir, binary_name, options, results_collector): ...@@ -279,15 +200,6 @@ def check_linux_binary(target_dir, binary_name, options, results_collector):
result = 0 result = 0
sizes = [] sizes = []
def get_elf_section_size(readelf_stdout, section_name):
# Matches: .ctors PROGBITS 000000000516add0 5169dd0 000010 00 WA 0 0 8
match = re.search(r'\.%s.*$' % re.escape(section_name),
readelf_stdout, re.MULTILINE)
if not match:
return (False, -1)
size_str = re.split(r'\W+', match.group(0))[5]
return (True, int(size_str, 16))
sizes.append((binary_name, binary_name, 'size', sizes.append((binary_name, binary_name, 'size',
get_size(binary_file), 'bytes')) get_size(binary_file), 'bytes'))
...@@ -304,51 +216,6 @@ def check_linux_binary(target_dir, binary_name, options, results_collector): ...@@ -304,51 +216,6 @@ def check_linux_binary(target_dir, binary_name, options, results_collector):
(binary_name + '-bss', 'bss', '', bss, 'bytes'), (binary_name + '-bss', 'bss', '', bss, 'bytes'),
] ]
# Find the number of files with at least one static initializer.
# First determine if we're 32 or 64 bit
result, stdout = run_process(result, ['readelf', '-h', binary_file])
elf_class_line = re.search('Class:.*$', stdout, re.MULTILINE).group(0)
elf_class = re.split(r'\W+', elf_class_line)[1]
if elf_class == 'ELF32':
word_size = 4
else:
word_size = 8
# Then find the number of files with global static initializers.
# NOTE: this is very implementation-specific and makes assumptions
# about how compiler and linker implement global static initializers.
si_count = 0
result, stdout = run_process(result, ['readelf', '-SW', binary_file])
has_init_array, init_array_size = get_elf_section_size(stdout, 'init_array')
if has_init_array:
si_count = init_array_size / word_size
# In newer versions of gcc crtbegin.o inserts frame_dummy into .init_array
# but we don't want to count this entry, since its alwasys present and not
# related to our code.
si_count -= 1
si_count = max(si_count, 0)
sizes.append((binary_name + '-si', 'initializers', '', si_count, 'files'))
# For Release builds only, use dump-static-initializers.py to print the list
# of static initializers.
if options.target == 'Release':
if (binary_name in EXPECTED_LINUX_SI_COUNTS and
si_count > EXPECTED_LINUX_SI_COUNTS[binary_name]):
result = 125
results_collector.add_failure(
'Expected <= %d static initializers in %s, but found %d' %
(EXPECTED_LINUX_SI_COUNTS[binary_name], binary_name, si_count))
if si_count > 0:
build_dir = os.path.dirname(target_dir)
dump_static_initializers = os.path.join(os.path.dirname(build_dir),
'tools', 'linux',
'dump-static-initializers.py')
result, stdout = run_process(result, [dump_static_initializers,
'-d', binary_file])
print '\n# Static initializers in %s:' % binary_file
print_si_fail_hint('tools/linux/dump-static-initializers.py')
print stdout
# Determine if the binary has the DT_TEXTREL marker. # Determine if the binary has the DT_TEXTREL marker.
result, stdout = run_process(result, ['readelf', '-Wd', binary_file]) result, stdout = run_process(result, ['readelf', '-Wd', binary_file])
if re.search(r'\bTEXTREL\b', stdout) is None: if re.search(r'\bTEXTREL\b', stdout) is None:
...@@ -572,8 +439,6 @@ def main(): ...@@ -572,8 +439,6 @@ def main():
help='specify platform (%s) [default: %%default]' help='specify platform (%s) [default: %%default]'
% ', '.join(platforms)) % ', '.join(platforms))
option_parser.add_option('--json', help='Path to JSON output file') option_parser.add_option('--json', help='Path to JSON output file')
option_parser.add_option('--failures',
help='Path to JSON output file for failures')
# This needs to be --output-dir (and not something like --output-directory) in # This needs to be --output-dir (and not something like --output-directory) in
# order to work properly with the build-side runtest.py script that's # order to work properly with the build-side runtest.py script that's
# currently used for dashboard uploading results from this script. # currently used for dashboard uploading results from this script.
...@@ -619,10 +484,6 @@ def main(): ...@@ -619,10 +484,6 @@ def main():
with open(histogram_path, 'w') as f: with open(histogram_path, 'w') as f:
f.write(histogram_result.stdout) f.write(histogram_result.stdout)
if options.failures:
with open(options.failures, 'w') as f:
json.dump(results_collector.failures, f)
return rc return rc
......
...@@ -7454,6 +7454,10 @@ ...@@ -7454,6 +7454,10 @@
} }
], ],
"scripts": [ "scripts": [
{
"name": "check_static_initializers",
"script": "check_static_initializers.py"
},
{ {
"name": "checkdeps", "name": "checkdeps",
"script": "checkdeps.py" "script": "checkdeps.py"
......
...@@ -1542,6 +1542,18 @@ ...@@ -1542,6 +1542,18 @@
"shards": 2 "shards": 2
} }
} }
],
"scripts": [
{
"name": "check_static_initializers",
"script": "check_static_initializers.py",
"swarming": {}
},
{
"name": "webkit_lint",
"script": "webkit_lint.py",
"swarming": {}
}
] ]
}, },
"Mac Retina Debug (AMD)": { "Mac Retina Debug (AMD)": {
...@@ -2217,6 +2229,18 @@ ...@@ -2217,6 +2229,18 @@
"shards": 2 "shards": 2
} }
} }
],
"scripts": [
{
"name": "check_static_initializers",
"script": "check_static_initializers.py",
"swarming": {}
},
{
"name": "webkit_lint",
"script": "webkit_lint.py",
"swarming": {}
}
] ]
}, },
"Win10 Debug (NVIDIA)": { "Win10 Debug (NVIDIA)": {
......
...@@ -1648,6 +1648,10 @@ ...@@ -1648,6 +1648,10 @@
} }
], ],
"scripts": [ "scripts": [
{
"name": "check_static_initializers",
"script": "check_static_initializers.py"
},
{ {
"name": "checkdeps", "name": "checkdeps",
"script": "checkdeps.py" "script": "checkdeps.py"
...@@ -4281,6 +4285,10 @@ ...@@ -4281,6 +4285,10 @@
} }
], ],
"scripts": [ "scripts": [
{
"name": "check_static_initializers",
"script": "check_static_initializers.py"
},
{ {
"name": "checkdeps", "name": "checkdeps",
"script": "checkdeps.py" "script": "checkdeps.py"
......
...@@ -4531,6 +4531,11 @@ ...@@ -4531,6 +4531,11 @@
} }
], ],
"scripts": [ "scripts": [
{
"name": "check_static_initializers",
"script": "check_static_initializers.py",
"swarming": {}
},
{ {
"name": "webkit_lint", "name": "webkit_lint",
"script": "webkit_lint.py", "script": "webkit_lint.py",
......
...@@ -67,6 +67,9 @@ ...@@ -67,6 +67,9 @@
# The optional "script" field is used when "type" == "script", and # The optional "script" field is used when "type" == "script", and
# specifies the GN path to the corresponding python file, e.g. # specifies the GN path to the corresponding python file, e.g.
# "//testing/scripts/foo.py". # "//testing/scripts/foo.py".
#
# The optional "skip_usage_check" field indicates that we should skip the check
# that the target is used in at least one buildbot json file.
{ {
"All_syzygy": { "All_syzygy": {
...@@ -921,6 +924,16 @@ ...@@ -921,6 +924,16 @@
"../../tools/metrics/metrics_python_tests.py" "../../tools/metrics/metrics_python_tests.py"
] ]
}, },
"nacl_helper": {
"label": "//components/nacl/loader:nacl_helper",
"type": "additional_compile_target",
"skip_usage_check": True,
},
"nacl_helper_bootstrap": {
"label": "//native_client/src/trusted/service_runtime/linux:bootstrap",
"type": "additional_compile_target",
"skip_usage_check": True,
},
"nacl_helper_nonsfi_unittests": { "nacl_helper_nonsfi_unittests": {
"label": "//components/nacl/loader:nacl_helper_nonsfi_unittests", "label": "//components/nacl/loader:nacl_helper_nonsfi_unittests",
"type": "raw", "type": "raw",
......
...@@ -450,8 +450,10 @@ def main(): ...@@ -450,8 +450,10 @@ def main():
ninja_targets, ninja_targets_seen): ninja_targets, ninja_targets_seen):
result = 1 result = 1
extra_targets = (set(ninja_targets) - ninja_targets_seen - skip_targets = [k for k, v in gn_isolate_map.items() if
SKIP_GN_ISOLATE_MAP_TARGETS) ('skip_usage_check' in v and v['skip_usage_check'])]
extra_targets = (set(ninja_targets) - set(skip_targets) -
ninja_targets_seen - SKIP_GN_ISOLATE_MAP_TARGETS)
if extra_targets: if extra_targets:
if len(extra_targets) > 1: if len(extra_targets) > 1:
extra_targets_str = ', '.join(extra_targets) + ' are' extra_targets_str = ', '.join(extra_targets) + ' are'
......
...@@ -699,15 +699,27 @@ ...@@ -699,15 +699,27 @@
'checkperms': { 'checkperms': {
'script': 'checkperms.py', 'script': 'checkperms.py',
}, },
'check_static_initializers': {
'script': 'check_static_initializers.py',
},
'webkit_lint': { 'webkit_lint': {
'script': 'webkit_lint.py', 'script': 'webkit_lint.py',
} },
},
'chromium_mac_scripts': {
'check_static_initializers': {
'script': 'check_static_initializers.py',
},
'webkit_lint': {
'script': 'webkit_lint.py',
},
}, },
'chromium_scripts': { 'chromium_scripts': {
'webkit_lint': { 'webkit_lint': {
'script': 'webkit_lint.py', 'script': 'webkit_lint.py',
} },
}, },
'chromium_swarm_android_gtests': { 'chromium_swarm_android_gtests': {
......
...@@ -1801,6 +1801,7 @@ ...@@ -1801,6 +1801,7 @@
'test_suites': { 'test_suites': {
'gtest_tests': 'gpu_desktop_gtests', 'gtest_tests': 'gpu_desktop_gtests',
'gpu_telemetry_tests': 'gpu_common_telemetry_tests', 'gpu_telemetry_tests': 'gpu_common_telemetry_tests',
'scripts': 'chromium_mac_scripts',
}, },
}, },
'Mac Retina Debug (AMD)': { 'Mac Retina Debug (AMD)': {
...@@ -1823,6 +1824,7 @@ ...@@ -1823,6 +1824,7 @@
'test_suites': { 'test_suites': {
'gtest_tests': 'gpu_desktop_gtests', 'gtest_tests': 'gpu_desktop_gtests',
'gpu_telemetry_tests': 'gpu_common_telemetry_tests', 'gpu_telemetry_tests': 'gpu_common_telemetry_tests',
'scripts': 'chromium_mac_scripts',
}, },
}, },
'Win10 Debug (NVIDIA)': { 'Win10 Debug (NVIDIA)': {
...@@ -3058,7 +3060,7 @@ ...@@ -3058,7 +3060,7 @@
'test_suites': { 'test_suites': {
'gtest_tests': 'chromium_mac_gtests', 'gtest_tests': 'chromium_mac_gtests',
'isolated_scripts': 'chromium_rel_isolated_scripts', 'isolated_scripts': 'chromium_rel_isolated_scripts',
'scripts': 'chromium_scripts', 'scripts': 'chromium_mac_scripts',
}, },
}, },
'Mac10.13 Tests (dbg)': { 'Mac10.13 Tests (dbg)': {
......
#!/usr/bin/env python
# Copyright 2018 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.
import json
import os
import re
import subprocess
import sys
import common
# If something adds a static initializer, revert it, don't increase these
# numbers. We don't accept regressions in static initializers.
#
# Note: Counts for chrome and nacl_helper are one higher in branded builds
# compared to release builds. This is due to a static initializer in
# WelsThreadPool.cpp (https://crbug.com/893594).
EXPECTED_LINUX_SI_COUNTS = {
'chrome': 5,
'nacl_helper': 5,
'nacl_helper_bootstrap': 0,
}
EXPECTED_MAC_SI_COUNT = 1 # https://crbug.com/893594
def run_process(command):
p = subprocess.Popen(command, stdout=subprocess.PIPE)
stdout = p.communicate()[0]
if p.returncode != 0:
raise Exception(
'ERROR from command "%s": %d' % (' '.join(command), p.returncode))
return stdout
def main_mac(src_dir):
base_names = ('Chromium', 'Google Chrome')
ret = 0
for base_name in base_names:
app_bundle = base_name + '.app'
framework_name = base_name + ' Framework'
framework_bundle = framework_name + '.framework'
framework_dsym_bundle = framework_bundle + '.dSYM'
framework_unstripped_name = framework_name + '.unstripped'
chromium_executable = os.path.join(app_bundle, 'Contents', 'MacOS',
base_name)
chromium_framework_executable = os.path.join(framework_bundle,
framework_name)
chromium_framework_dsym = os.path.join(framework_dsym_bundle, 'Contents',
'Resources', 'DWARF', framework_name)
if os.path.exists(chromium_executable):
# Count the number of files with at least one static initializer.
si_count = 0
# Find the __DATA,__mod_init_func section.
stdout = run_process(['otool', '-l', chromium_framework_executable])
section_index = stdout.find('sectname __mod_init_func')
if section_index != -1:
# If the section exists, the "size" line must follow it.
initializers_s = re.search('size 0x([0-9a-f]+)',
stdout[section_index:]).group(1)
word_size = 8 # Assume 64 bit
si_count = int(initializers_s, 16) / word_size
# Print the list of static initializers.
if si_count > EXPECTED_MAC_SI_COUNT:
print('Expected <= %d static initializers in %s, but found %d' %
(EXPECTED_MAC_SI_COUNT, chromium_framework_executable, si_count))
ret = 1
# First look for a dSYM to get information about the initializers. If
# one is not present, check if there is an unstripped copy of the build
# output.
mac_tools_path = os.path.join(src_dir, 'tools', 'mac')
if os.path.exists(chromium_framework_dsym):
dump_static_initializers = os.path.join(
mac_tools_path, 'dump-static-initializers.py')
stdout = run_process(
[dump_static_initializers, chromium_framework_dsym])
print stdout
else:
show_mod_init_func = os.path.join(mac_tools_path,
'show_mod_init_func.py')
args = [show_mod_init_func]
if os.path.exists(framework_unstripped_name):
args.append(framework_unstripped_name)
else:
print '# Warning: Falling back to potentially stripped output.'
args.append(chromium_framework_executable)
stdout = run_process(args)
print stdout
return ret
def main_linux(src_dir):
def get_elf_section_size(readelf_stdout, section_name):
# Matches: .ctors PROGBITS 000000000516add0 5169dd0 000010 00 WA 0 0 8
match = re.search(r'\.%s.*$' % re.escape(section_name), readelf_stdout,
re.MULTILINE)
if not match:
return (False, -1)
size_str = re.split(r'\W+', match.group(0))[5]
return (True, int(size_str, 16))
def get_word_size(binary_name):
stdout = run_process(['readelf', '-h', binary_name])
elf_class_line = re.search('Class:.*$', stdout, re.MULTILINE).group(0)
elf_class = re.split(r'\W+', elf_class_line)[1]
if elf_class == 'ELF32':
return 4
elif elf_class == 'ELF64':
return 8
raise Exception('Unsupported architecture')
ret = 0
for binary_name in EXPECTED_LINUX_SI_COUNTS:
if not os.path.exists(binary_name):
continue
# NOTE: this is very implementation-specific and makes assumptions
# about how compiler and linker implement global static initializers.
si_count = 0
stdout = run_process(['readelf', '-SW', binary_name])
has_init_array, init_array_size = get_elf_section_size(stdout, 'init_array')
if has_init_array:
si_count = init_array_size / get_word_size(binary_name)
# In newer versions of gcc crtbegin.o inserts frame_dummy into .init_array
# but we don't want to count this entry, since its always present and not
# related to our code.
stdout = run_process(['objdump', '-t', binary_name, '-j' '.init_array'])
if '__frame_dummy_init_array_entry' in stdout:
si_count -= 1
# Print the list of static initializers.
if (binary_name in EXPECTED_LINUX_SI_COUNTS and
si_count > EXPECTED_LINUX_SI_COUNTS[binary_name]):
print('Expected <= %d static initializers in %s, but found %d' %
(EXPECTED_LINUX_SI_COUNTS[binary_name], binary_name, si_count))
ret = 1
if si_count > 0:
dump_static_initializers = os.path.join(src_dir, 'tools', 'linux',
'dump-static-initializers.py')
stdout = run_process([dump_static_initializers, '-d', binary_name])
print '\n# Static initializers in %s:' % binary_name
print stdout
return ret
def main_run(args):
if args.build_config_fs != 'Release':
raise Exception('Only release builds are supported')
src_dir = args.paths['checkout']
build_dir = os.path.join(src_dir, 'out', args.build_config_fs)
os.chdir(build_dir)
if sys.platform.startswith('darwin'):
rc = main_mac(src_dir)
elif sys.platform == 'linux2':
rc = main_linux(src_dir)
else:
sys.stderr.write('Unsupported platform %s.\n' % repr(sys.platform))
return 2
json.dump({
'valid': rc == 0,
'failures': [],
}, args.output)
return rc
def main_compile_targets(args):
if sys.platform.startswith('darwin'):
compile_targets = ['chrome']
elif sys.platform == 'linux2':
compile_targets = ['chrome', 'nacl_helper', 'nacl_helper_bootstrap']
else:
compile_targets = []
json.dump(compile_targets, args.output)
return 0
if __name__ == '__main__':
funcs = {
'run': main_run,
'compile_targets': main_compile_targets,
}
sys.exit(common.run_script(sys.argv[1:], funcs))
...@@ -8,10 +8,8 @@ import json ...@@ -8,10 +8,8 @@ import json
import os import os
import sys import sys
import common import common
PERF_DASHBOARD_URL = 'https://chromeperf.appspot.com' PERF_DASHBOARD_URL = 'https://chromeperf.appspot.com'
...@@ -28,33 +26,30 @@ def main_run(script_args): ...@@ -28,33 +26,30 @@ def main_run(script_args):
parser.add_argument('prefix') parser.add_argument('prefix')
args = parser.parse_args(script_args.args) args = parser.parse_args(script_args.args)
with common.temporary_file() as tempfile_path: runtest_args = [
runtest_args = [ '--test-type',
'--test-type', 'sizes', 'sizes',
'--run-python-script', '--run-python-script',
] ]
if args.perf_id: if args.perf_id:
runtest_args.extend([ runtest_args.extend([
'--perf-id', args.perf_id, '--perf-id',
'--results-url=%s' % args.results_url, args.perf_id,
'--perf-dashboard-id=sizes', '--results-url=%s' % args.results_url,
'--annotate=graphing', '--perf-dashboard-id=sizes',
]) '--annotate=graphing',
sizes_cmd = [ ])
os.path.join( sizes_cmd = [
common.SRC_DIR, 'infra', 'scripts', 'legacy', 'scripts', 'slave', os.path.join(common.SRC_DIR, 'infra', 'scripts', 'legacy', 'scripts',
'chromium', 'sizes.py'), 'slave', 'chromium', 'sizes.py')
'--failures', tempfile_path ]
] if args.platform:
if args.platform: sizes_cmd.extend(['--platform', args.platform])
sizes_cmd.extend(['--platform', args.platform]) rc = common.run_runtest(script_args, runtest_args + sizes_cmd)
rc = common.run_runtest(script_args, runtest_args + sizes_cmd)
with open(tempfile_path) as f:
failures = json.load(f)
json.dump({ json.dump({
'valid': (rc == 0 or rc == 125), 'valid': rc == 0,
'failures': failures, 'failures': [],
}, script_args.output) }, script_args.output)
return rc return rc
...@@ -65,17 +60,16 @@ def main_compile_targets(script_args): ...@@ -65,17 +60,16 @@ def main_compile_targets(script_args):
args = parser.parse_args(script_args.args) args = parser.parse_args(script_args.args)
_COMPILE_TARGETS = { _COMPILE_TARGETS = {
'android-cronet': ['cronet'], 'android-cronet': ['cronet'],
'android-webview': ['libwebviewchromium'], 'android-webview': ['libwebviewchromium'],
} }
json.dump(_COMPILE_TARGETS.get(args.platform, ['chrome']), json.dump(_COMPILE_TARGETS.get(args.platform, ['chrome']), script_args.output)
script_args.output)
if __name__ == '__main__': if __name__ == '__main__':
funcs = { funcs = {
'run': main_run, 'run': main_run,
'compile_targets': main_compile_targets, 'compile_targets': main_compile_targets,
} }
sys.exit(common.run_script(sys.argv[1:], funcs)) sys.exit(common.run_script(sys.argv[1:], funcs))
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