OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """Runs the Java tests. See more information on run_instrumentation_tests.py.""" | 5 """Runs the Java tests. See more information on run_instrumentation_tests.py.""" |
6 | 6 |
7 import fnmatch | 7 import fnmatch |
8 import logging | 8 import logging |
9 import os | 9 import os |
10 import re | 10 import re |
11 import shutil | 11 import shutil |
12 import sys | 12 import sys |
13 import time | 13 import time |
14 | 14 |
15 import android_commands | 15 import android_commands |
| 16 import apk_info |
16 from base_test_runner import BaseTestRunner | 17 from base_test_runner import BaseTestRunner |
17 from base_test_sharder import BaseTestSharder, SetTestsContainer | 18 from base_test_sharder import BaseTestSharder, SetTestsContainer |
18 import cmd_helper | 19 import cmd_helper |
19 import constants | 20 import constants |
20 import errors | 21 import errors |
21 from forwarder import Forwarder | 22 from forwarder import Forwarder |
22 from json_perf_parser import GetAverageRunInfoFromJSONString | 23 from json_perf_parser import GetAverageRunInfoFromJSONString |
23 from perf_tests_helper import PrintPerfResult | 24 from perf_tests_helper import PrintPerfResult |
24 import sharded_tests_queue | 25 import sharded_tests_queue |
25 from test_result import SingleTestResult, TestResults | 26 from test_result import SingleTestResult, TestResults |
26 from utils import apk_and_jar_info | |
27 from utils import jar_info | |
28 import valgrind_tools | 27 import valgrind_tools |
29 | 28 |
30 _PERF_TEST_ANNOTATION = 'PerfTest' | 29 _PERF_TEST_ANNOTATION = 'PerfTest' |
31 | 30 |
32 | 31 |
33 class FatalTestException(Exception): | 32 class FatalTestException(Exception): |
34 """A fatal test exception.""" | 33 """A fatal test exception.""" |
35 pass | 34 pass |
36 | 35 |
37 | 36 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 The default is ChromeTest.apk. | 106 The default is ChromeTest.apk. |
108 ports_to_forward: A list of port numbers for which to set up forwarders. | 107 ports_to_forward: A list of port numbers for which to set up forwarders. |
109 Can be optionally requested by a test case. | 108 Can be optionally requested by a test case. |
110 Raises: | 109 Raises: |
111 FatalTestException: if coverage metadata is not available. | 110 FatalTestException: if coverage metadata is not available. |
112 """ | 111 """ |
113 BaseTestRunner.__init__( | 112 BaseTestRunner.__init__( |
114 self, device, options.tool, shard_index, options.build_type) | 113 self, device, options.tool, shard_index, options.build_type) |
115 | 114 |
116 if not apks: | 115 if not apks: |
117 apks = [apk_and_jar_info.ApkAndJarInfo(options.test_apk_path, | 116 apks = [apk_info.ApkInfo(options.test_apk_path, |
118 options.test_apk_jar_path)] | 117 options.test_apk_jar_path)] |
119 | 118 |
120 self.build_type = options.build_type | 119 self.build_type = options.build_type |
121 self.install_apk = options.install_apk | 120 self.install_apk = options.install_apk |
122 self.test_data = options.test_data | 121 self.test_data = options.test_data |
123 self.save_perf_json = options.save_perf_json | 122 self.save_perf_json = options.save_perf_json |
124 self.screenshot_failures = options.screenshot_failures | 123 self.screenshot_failures = options.screenshot_failures |
125 self.wait_for_debugger = options.wait_for_debugger | 124 self.wait_for_debugger = options.wait_for_debugger |
126 self.disable_assertions = options.disable_assertions | 125 self.disable_assertions = options.disable_assertions |
127 | 126 |
128 self.tests_iter = tests_iter | 127 self.tests_iter = tests_iter |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 default_size_annotation = 'SmallTest' | 533 default_size_annotation = 'SmallTest' |
535 | 534 |
536 def _GetTestsMissingAnnotation(test_apk): | 535 def _GetTestsMissingAnnotation(test_apk): |
537 test_size_annotations = frozenset(['Smoke', 'SmallTest', 'MediumTest', | 536 test_size_annotations = frozenset(['Smoke', 'SmallTest', 'MediumTest', |
538 'LargeTest', 'EnormousTest', 'FlakyTest', | 537 'LargeTest', 'EnormousTest', 'FlakyTest', |
539 'DisabledTest', 'Manual', 'PerfTest']) | 538 'DisabledTest', 'Manual', 'PerfTest']) |
540 tests_missing_annotations = [] | 539 tests_missing_annotations = [] |
541 for test_method in test_apk.GetTestMethods(): | 540 for test_method in test_apk.GetTestMethods(): |
542 annotations = frozenset(test_apk.GetTestAnnotations(test_method)) | 541 annotations = frozenset(test_apk.GetTestAnnotations(test_method)) |
543 if (annotations.isdisjoint(test_size_annotations) and | 542 if (annotations.isdisjoint(test_size_annotations) and |
544 not jar_info.JarInfo.IsPythonDrivenTest(test_method)): | 543 not apk_info.ApkInfo.IsPythonDrivenTest(test_method)): |
545 tests_missing_annotations.append(test_method) | 544 tests_missing_annotations.append(test_method) |
546 return sorted(tests_missing_annotations) | 545 return sorted(tests_missing_annotations) |
547 | 546 |
548 if options.annotation: | 547 if options.annotation: |
549 available_tests = test_apk.GetAnnotatedTests(options.annotation) | 548 available_tests = test_apk.GetAnnotatedTests(options.annotation) |
550 if options.annotation.count(default_size_annotation) > 0: | 549 if options.annotation.count(default_size_annotation) > 0: |
551 tests_missing_annotations = _GetTestsMissingAnnotation(test_apk) | 550 tests_missing_annotations = _GetTestsMissingAnnotation(test_apk) |
552 if tests_missing_annotations: | 551 if tests_missing_annotations: |
553 logging.warning('The following tests do not contain any annotation. ' | 552 logging.warning('The following tests do not contain any annotation. ' |
554 'Assuming "%s":\n%s', | 553 'Assuming "%s":\n%s', |
555 default_size_annotation, | 554 default_size_annotation, |
556 '\n'.join(tests_missing_annotations)) | 555 '\n'.join(tests_missing_annotations)) |
557 available_tests += tests_missing_annotations | 556 available_tests += tests_missing_annotations |
558 else: | 557 else: |
559 available_tests = [m for m in test_apk.GetTestMethods() | 558 available_tests = [m for m in test_apk.GetTestMethods() |
560 if not jar_info.JarInfo.IsPythonDrivenTest(m)] | 559 if not apk_info.ApkInfo.IsPythonDrivenTest(m)] |
561 coverage = os.environ.get('EMMA_INSTRUMENT') == 'true' | 560 coverage = os.environ.get('EMMA_INSTRUMENT') == 'true' |
562 | 561 |
563 tests = [] | 562 tests = [] |
564 if options.test_filter: | 563 if options.test_filter: |
565 # |available_tests| are in adb instrument format: package.path.class#test. | 564 # |available_tests| are in adb instrument format: package.path.class#test. |
566 filter_without_hash = options.test_filter.replace('#', '.') | 565 filter_without_hash = options.test_filter.replace('#', '.') |
567 tests = [t for t in available_tests | 566 tests = [t for t in available_tests |
568 if filter_without_hash in t.replace('#', '.')] | 567 if filter_without_hash in t.replace('#', '.')] |
569 else: | 568 else: |
570 tests = available_tests | 569 tests = available_tests |
(...skipping 14 matching lines...) Expand all Loading... |
585 | 584 |
586 logging.info('Will run: %s', str(tests)) | 585 logging.info('Will run: %s', str(tests)) |
587 | 586 |
588 if len(attached_devices) > 1 and (coverage or options.wait_for_debugger): | 587 if len(attached_devices) > 1 and (coverage or options.wait_for_debugger): |
589 logging.warning('Coverage / debugger can not be sharded, ' | 588 logging.warning('Coverage / debugger can not be sharded, ' |
590 'using first available device') | 589 'using first available device') |
591 attached_devices = attached_devices[:1] | 590 attached_devices = attached_devices[:1] |
592 sharder = TestSharder(attached_devices, options, tests, apks) | 591 sharder = TestSharder(attached_devices, options, tests, apks) |
593 test_results = sharder.RunShardedTests() | 592 test_results = sharder.RunShardedTests() |
594 return test_results | 593 return test_results |
OLD | NEW |