OLD | NEW |
(Empty) | |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 """Runs content_browsertests.""" |
| 6 |
| 7 import logging |
| 8 import os |
| 9 import sys |
| 10 |
| 11 from pylib import android_commands |
| 12 from pylib import cmd_helper |
| 13 from pylib import constants |
| 14 from pylib import ports |
| 15 from pylib.base import base_test_result |
| 16 from pylib.gtest import setup as gtest_setup |
| 17 from pylib.gtest import test_runner |
| 18 from pylib.utils import report_results |
| 19 |
| 20 sys.path.insert(0, |
| 21 os.path.join(constants.DIR_SOURCE_ROOT, 'build', 'util', 'lib')) |
| 22 from common import unittest_util |
| 23 |
| 24 |
| 25 def Setup(test_arguments, timeout, cleanup_test_files, tool, build_type, |
| 26 webkit, push_deps, gtest_filter): |
| 27 """Create the test runner factory and tests. |
| 28 |
| 29 Args: |
| 30 test_arguments: Additional arguments to pass to the test binary. |
| 31 timeout: Timeout for each test. |
| 32 cleanup_test_files: Whether or not to cleanup test files on device. |
| 33 tool: Name of the Valgrind tool. |
| 34 build_type: 'Release' or 'Debug'. |
| 35 webkit: Whether the suite is being run from a WebKit checkout. |
| 36 push_deps: If True, push all dependencies to the device. |
| 37 gtest_filter: filter for tests. |
| 38 |
| 39 Returns: |
| 40 A tuple of (TestRunnerFactory, tests). |
| 41 """ |
| 42 |
| 43 test_suite_dir = os.path.join(cmd_helper.OutDirectory.get(), build_type) |
| 44 test_suite = os.path.join(test_suite_dir, 'apks', |
| 45 constants.BROWSERTEST_SUITE_NAME + '.apk') |
| 46 |
| 47 # Constructs a new TestRunner with the current options. |
| 48 def TestRunnerFactory(device, shard_index): |
| 49 return test_runner.TestRunner( |
| 50 device, |
| 51 test_suite, |
| 52 test_arguments, |
| 53 timeout, |
| 54 cleanup_test_files, |
| 55 tool, |
| 56 build_type, |
| 57 webkit, |
| 58 push_deps, |
| 59 constants.BROWSERTEST_TEST_PACKAGE_NAME, |
| 60 constants.BROWSERTEST_TEST_ACTIVITY_NAME, |
| 61 constants.BROWSERTEST_COMMAND_LINE_FILE) |
| 62 |
| 63 # TODO(gkanwar): This breaks the abstraction of having test_dispatcher.py deal |
| 64 # entirely with the devices. Can we do this another way? |
| 65 attached_devices = android_commands.GetAttachedDevices() |
| 66 # Get tests and split them up based on the number of devices. |
| 67 all_enabled = gtest_setup.GetAllEnabledTests(TestRunnerFactory, |
| 68 attached_devices) |
| 69 if gtest_filter: |
| 70 all_tests = unittest_util.FilterTestNames(all_enabled, |
| 71 gtest_filter) |
| 72 else: |
| 73 all_tests = _FilterTests(all_enabled) |
| 74 |
| 75 return (TestRunnerFactory, all_tests) |
| 76 |
| 77 |
| 78 def _FilterTests(all_enabled_tests): |
| 79 """Filters out tests and fixtures starting with PRE_ and MANUAL_.""" |
| 80 return [t for t in all_enabled_tests if _ShouldRunOnBot(t)] |
| 81 |
| 82 |
| 83 def _ShouldRunOnBot(test): |
| 84 fixture, case = test.split('.', 1) |
| 85 if _StartsWith(fixture, case, 'PRE_'): |
| 86 return False |
| 87 if _StartsWith(fixture, case, 'MANUAL_'): |
| 88 return False |
| 89 return True |
| 90 |
| 91 |
| 92 def _StartsWith(a, b, prefix): |
| 93 return a.startswith(prefix) or b.startswith(prefix) |
OLD | NEW |