Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import re | 5 import re |
| 6 import string | 6 import string |
| 7 | 7 |
| 8 | 8 |
| 9 class Test(object): | 9 class Test(object): |
| 10 """ | 10 """ |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 340 gtest_results = self._test_runs[suffix].test_utils.gtest_results | 340 gtest_results = self._test_runs[suffix].test_utils.gtest_results |
| 341 if not gtest_results.valid: # pragma: no cover | 341 if not gtest_results.valid: # pragma: no cover |
| 342 return False | 342 return False |
| 343 global_tags = gtest_results.raw.get('global_tags', []) | 343 global_tags = gtest_results.raw.get('global_tags', []) |
| 344 return 'UNRELIABLE_RESULTS' not in global_tags | 344 return 'UNRELIABLE_RESULTS' not in global_tags |
| 345 | 345 |
| 346 def failures(self, api, suffix): | 346 def failures(self, api, suffix): |
| 347 return self._test_runs[suffix].test_utils.gtest_results.failures | 347 return self._test_runs[suffix].test_utils.gtest_results.failures |
| 348 | 348 |
| 349 | 349 |
| 350 def generate_gtest(api, mastername, buildername, test_spec, | 350 def get_args_for_test(api, chromium_tests_api, test_spec, bot_update_step): |
| 351 enable_swarming=False, scripts_compile_targets=None): | 351 """Gets the argument list for a dynamically generated test, as |
| 352 provided by the JSON files in src/testing/buildbot/ in the Chromium | |
| 353 workspace. This function provides the following build properties in | |
| 354 the form of variable substitutions in the tests' argument lists: | |
| 355 | |
| 356 buildername | |
| 357 got_revision | |
| 358 | |
| 359 so, for example, a test can declare the argument: | |
| 360 | |
| 361 --test-machine-name=\"${buildername}\" | |
| 362 | |
| 363 and ${buildername} will be replaced with the associated build | |
| 364 property. In this example, it will also be double-quoted, to handle | |
| 365 the case where the machine name contains contains spaces. | |
| 366 | |
| 367 This function also supports trybot-only and waterfall-only | |
| 368 arguments, so that a test can pass a different argument lists on the | |
| 369 continuous builders compared to tryjobs. This is useful when the | |
| 370 waterfall bots generate some reference data that is tested against | |
| 371 during tryjobs. | |
| 372 """ | |
| 373 | |
| 374 args = test_spec.get('args', []) | |
| 375 if chromium_tests_api.is_precommit_mode(): | |
| 376 args = args + test_spec.get('precommit_args', []) | |
| 377 else: | |
| 378 args = args + test_spec.get('non_precommit_args', []) | |
| 379 # Perform substitution of known variables. | |
| 380 substitutions = { | |
| 381 'buildername': api.properties.get('buildername'), | |
| 382 'got_revision': bot_update_step.presentation.properties['got_revision'] | |
| 383 } | |
| 384 return [string.Template(arg).safe_substitute(substitutions) for arg in args] | |
| 385 | |
| 386 | |
| 387 def generate_gtest(api, chromium_tests_api, mastername, buildername, test_spec, | |
| 388 bot_update_step, enable_swarming=False, | |
| 389 scripts_compile_targets=None): | |
| 352 def canonicalize_test(test): | 390 def canonicalize_test(test): |
| 353 if isinstance(test, basestring): | 391 if isinstance(test, basestring): |
| 354 canonical_test = {'test': test} | 392 canonical_test = {'test': test} |
| 355 else: | 393 else: |
| 356 canonical_test = test.copy() | 394 canonical_test = test.copy() |
| 357 | 395 |
| 358 canonical_test.setdefault('shard_index', 0) | 396 canonical_test.setdefault('shard_index', 0) |
| 359 canonical_test.setdefault('total_shards', 1) | 397 canonical_test.setdefault('total_shards', 1) |
| 360 return canonical_test | 398 return canonical_test |
| 361 | 399 |
| 362 def get_tests(api): | 400 def get_tests(api): |
| 363 return [canonicalize_test(t) for t in | 401 return [canonicalize_test(t) for t in |
| 364 test_spec.get(buildername, {}).get('gtest_tests', [])] | 402 test_spec.get(buildername, {}).get('gtest_tests', [])] |
| 365 | 403 |
| 366 for test in get_tests(api): | 404 for test in get_tests(api): |
| 367 args = test.get('args', []) | 405 args = get_args_for_test(api, chromium_tests_api, test, bot_update_step) |
| 368 if test['shard_index'] != 0 or test['total_shards'] != 1: | 406 if test['shard_index'] != 0 or test['total_shards'] != 1: |
| 369 args.extend(['--test-launcher-shard-index=%d' % test['shard_index'], | 407 args.extend(['--test-launcher-shard-index=%d' % test['shard_index'], |
| 370 '--test-launcher-total-shards=%d' % test['total_shards']]) | 408 '--test-launcher-total-shards=%d' % test['total_shards']]) |
| 371 use_swarming = False | 409 use_swarming = False |
| 372 swarming_shards = 1 | 410 swarming_shards = 1 |
| 373 swarming_dimension_sets = None | 411 swarming_dimension_sets = None |
| 374 if enable_swarming: | 412 if enable_swarming: |
| 375 swarming_spec = test.get('swarming', {}) | 413 swarming_spec = test.get('swarming', {}) |
| 376 if swarming_spec.get('can_use_on_swarming_builders'): | 414 if swarming_spec.get('can_use_on_swarming_builders'): |
| 377 use_swarming = True | 415 use_swarming = True |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 391 swarming_dimensions=dimensions, | 429 swarming_dimensions=dimensions, |
| 392 override_compile_targets=override_compile_targets) | 430 override_compile_targets=override_compile_targets) |
| 393 else: | 431 else: |
| 394 yield GTestTest(name, args=args, target_name=target_name, | 432 yield GTestTest(name, args=args, target_name=target_name, |
| 395 flakiness_dash=True, | 433 flakiness_dash=True, |
| 396 enable_swarming=use_swarming, | 434 enable_swarming=use_swarming, |
| 397 swarming_shards=swarming_shards, | 435 swarming_shards=swarming_shards, |
| 398 override_compile_targets=override_compile_targets) | 436 override_compile_targets=override_compile_targets) |
| 399 | 437 |
| 400 | 438 |
| 401 def generate_script(api, mastername, buildername, test_spec, | 439 def generate_script(api, chromium_tests_api, mastername, buildername, test_spec, |
| 402 enable_swarming=False, scripts_compile_targets=None): | 440 bot_update_step, enable_swarming=False, |
| 441 scripts_compile_targets=None): | |
| 403 for script_spec in test_spec.get(buildername, {}).get('scripts', []): | 442 for script_spec in test_spec.get(buildername, {}).get('scripts', []): |
| 404 yield ScriptTest( | 443 yield ScriptTest( |
| 405 str(script_spec['name']), | 444 str(script_spec['name']), |
| 406 script_spec['script'], | 445 script_spec['script'], |
| 407 scripts_compile_targets, # pragma: no cover | 446 scripts_compile_targets, # pragma: no cover |
| 408 script_spec.get('args', [])) | 447 get_args_for_test( |
| 448 api, chromium_tests_api, script_spec, bot_update_step)) | |
| 409 | 449 |
| 410 | 450 |
| 411 class DynamicPerfTests(Test): | 451 class DynamicPerfTests(Test): |
| 412 def __init__(self, perf_id, platform, target_bits, max_battery_temp=None, | 452 def __init__(self, perf_id, platform, target_bits, max_battery_temp=None, |
| 413 num_device_shards=1, num_host_shards=1, shard_index=0): | 453 num_device_shards=1, num_host_shards=1, shard_index=0): |
| 414 self._perf_id = perf_id | 454 self._perf_id = perf_id |
| 415 self._platform = platform | 455 self._platform = platform |
| 416 self._target_bits = target_bits | 456 self._target_bits = target_bits |
| 417 | 457 |
| 418 self._max_battery_temp = max_battery_temp | 458 self._max_battery_temp = max_battery_temp |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1113 step_result.presentation.logs['invalid_results_exc'] = [str(e)] | 1153 step_result.presentation.logs['invalid_results_exc'] = [str(e)] |
| 1114 valid = False | 1154 valid = False |
| 1115 failures = None | 1155 failures = None |
| 1116 if valid: | 1156 if valid: |
| 1117 step_result.presentation.step_text += api.test_utils.format_step_text([ | 1157 step_result.presentation.step_text += api.test_utils.format_step_text([ |
| 1118 ['failures:', failures] | 1158 ['failures:', failures] |
| 1119 ]) | 1159 ]) |
| 1120 return valid, failures | 1160 return valid, failures |
| 1121 | 1161 |
| 1122 | 1162 |
| 1123 def generate_isolated_script(api, mastername, buildername, test_spec, | 1163 def generate_isolated_script(api, chromium_tests_api, mastername, buildername, |
| 1124 enable_swarming=False, | 1164 test_spec, bot_update_step, enable_swarming=False, |
| 1125 scripts_compile_targets=None): | 1165 scripts_compile_targets=None): |
| 1126 for spec in test_spec.get(buildername, {}).get('isolated_scripts', []): | 1166 for spec in test_spec.get(buildername, {}).get('isolated_scripts', []): |
| 1127 use_swarming = False | 1167 use_swarming = False |
| 1128 swarming_shards = 1 | 1168 swarming_shards = 1 |
| 1129 swarming_dimension_sets = None | 1169 swarming_dimension_sets = None |
| 1130 if enable_swarming: | 1170 if enable_swarming: |
| 1131 swarming_spec = spec.get('swarming', {}) | 1171 swarming_spec = spec.get('swarming', {}) |
| 1132 if swarming_spec.get('can_use_on_swarming_builders', False): | 1172 if swarming_spec.get('can_use_on_swarming_builders', False): |
| 1133 use_swarming = True | 1173 use_swarming = True |
| 1134 swarming_shards = swarming_spec.get('shards', 1) | 1174 swarming_shards = swarming_spec.get('shards', 1) |
| 1135 swarming_dimension_sets = swarming_spec.get('dimension_sets') | 1175 swarming_dimension_sets = swarming_spec.get('dimension_sets') |
| 1136 name = str(spec['name']) | 1176 name = str(spec['name']) |
| 1137 args = args=spec.get('args', []) | 1177 args = get_args_for_test(api, chromium_tests_api, spec, bot_update_step) |
|
Paweł Hajdan Jr.
2016/01/20 15:10:38
If the support is intended for isolated script tes
Ken Russell (switch to Gerrit)
2016/01/21 01:29:27
Done and tests updated.
| |
| 1138 target_name = spec['isolate_name'] | 1178 target_name = spec['isolate_name'] |
| 1139 # This features is only needed for the cases in which the *_run compile | 1179 # This features is only needed for the cases in which the *_run compile |
| 1140 # target is needed to generate isolate files that contains dynamically libs. | 1180 # target is needed to generate isolate files that contains dynamically libs. |
| 1141 # TODO(nednguyen, kbr): Remove this once all the GYP builds are converted | 1181 # TODO(nednguyen, kbr): Remove this once all the GYP builds are converted |
| 1142 # to GN. | 1182 # to GN. |
| 1143 override_compile_targets = spec.get('override_compile_targets', None) | 1183 override_compile_targets = spec.get('override_compile_targets', None) |
| 1144 if use_swarming: | 1184 if use_swarming: |
| 1145 if swarming_dimension_sets: | 1185 if swarming_dimension_sets: |
| 1146 for dimensions in swarming_dimension_sets: | 1186 for dimensions in swarming_dimension_sets: |
| 1147 # Yield potentially multiple invocations of the same test, | 1187 # Yield potentially multiple invocations of the same test, |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1715 def run(self, api, suffix, test_filter=None): | 1755 def run(self, api, suffix, test_filter=None): |
| 1716 api.chromium_android.coverage_report(upload=False) | 1756 api.chromium_android.coverage_report(upload=False) |
| 1717 api.chromium_android.get_changed_lines_for_revision() | 1757 api.chromium_android.get_changed_lines_for_revision() |
| 1718 api.chromium_android.incremental_coverage_report() | 1758 api.chromium_android.incremental_coverage_report() |
| 1719 | 1759 |
| 1720 | 1760 |
| 1721 GOMA_TESTS = [ | 1761 GOMA_TESTS = [ |
| 1722 GTestTest('base_unittests'), | 1762 GTestTest('base_unittests'), |
| 1723 GTestTest('content_unittests'), | 1763 GTestTest('content_unittests'), |
| 1724 ] | 1764 ] |
| OLD | NEW |