Chromium Code Reviews| Index: build/android/pylib/browsertests/setup.py |
| diff --git a/build/android/pylib/browsertests/setup.py b/build/android/pylib/browsertests/setup.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7db8933312551f1e87d07bb7bfb778b28e11d99f |
| --- /dev/null |
| +++ b/build/android/pylib/browsertests/setup.py |
| @@ -0,0 +1,93 @@ |
| +# Copyright (c) 2013 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. |
| + |
| +"""Runs content_browsertests.""" |
|
frankf
2013/07/16 00:02:18
Update these.
gkanwar
2013/07/16 00:47:03
Done.
|
| + |
| +import logging |
| +import os |
| +import sys |
| + |
| +from pylib import android_commands |
| +from pylib import cmd_helper |
| +from pylib import constants |
| +from pylib import ports |
| +from pylib.base import base_test_result |
| +from pylib.gtest import setup as gtest_setup |
| +from pylib.gtest import test_runner |
| +from pylib.utils import report_results |
| + |
| +sys.path.insert(0, |
| + os.path.join(constants.DIR_SOURCE_ROOT, 'build', 'util', 'lib')) |
| +from common import unittest_util |
| + |
| + |
| +def Setup(test_arguments, timeout, cleanup_test_files, tool, build_type, |
| + webkit, push_deps, gtest_filter): |
| + """Create the test runner factory and tests. |
| + |
| + Args: |
| + test_arguments: Additional arguments to pass to the test binary. |
| + timeout: Timeout for each test. |
| + cleanup_test_files: Whether or not to cleanup test files on device. |
| + tool: Name of the Valgrind tool. |
| + build_type: 'Release' or 'Debug'. |
| + webkit: Whether the suite is being run from a WebKit checkout. |
| + push_deps: If True, push all dependencies to the device. |
| + gtest_filter: filter for tests. |
| + |
| + Returns: |
| + A tuple of (TestRunnerFactory, tests). |
| + """ |
| + |
| + test_suite_dir = os.path.join(cmd_helper.OutDirectory.get(), build_type) |
| + test_suite = os.path.join(test_suite_dir, 'apks', |
| + constants.BROWSERTEST_SUITE_NAME + '.apk') |
|
frankf
2013/07/16 00:02:18
indent issue
gkanwar
2013/07/16 00:47:03
Done.
|
| + |
| + # Constructs a new TestRunner with the current options. |
| + def TestRunnerFactory(device, shard_index): |
| + return test_runner.TestRunner( |
| + device, |
| + test_suite, |
| + test_arguments, |
| + timeout, |
| + cleanup_test_files, |
| + tool, |
| + build_type, |
| + webkit, |
| + push_deps, |
| + constants.BROWSERTEST_TEST_PACKAGE_NAME, |
| + constants.BROWSERTEST_TEST_ACTIVITY_NAME, |
| + constants.BROWSERTEST_COMMAND_LINE_FILE) |
| + |
| + # TODO(gkanwar): This breaks the abstraction of having dispatch.Dispatch deal |
| + # entirely with the devices. Can we do this another way? |
| + attached_devices = android_commands.GetAttachedDevices() |
| + # Get tests and split them up based on the number of devices. |
| + all_enabled = gtest_setup.GetAllEnabledTests(TestRunnerFactory, |
| + attached_devices) |
| + if gtest_filter: |
| + all_tests = unittest_util.FilterTestNames(all_enabled, |
| + gtest_filter) |
| + else: |
| + all_tests = _FilterTests(all_enabled) |
| + |
| + return (TestRunnerFactory, all_tests) |
| + |
| + |
| +def _FilterTests(all_enabled_tests): |
| + """Filters out tests and fixtures starting with PRE_ and MANUAL_.""" |
| + return [t for t in all_enabled_tests if _ShouldRunOnBot(t)] |
| + |
| + |
| +def _ShouldRunOnBot(test): |
| + fixture, case = test.split('.', 1) |
| + if _StartsWith(fixture, case, 'PRE_'): |
| + return False |
| + if _StartsWith(fixture, case, 'MANUAL_'): |
| + return False |
| + return True |
| + |
| + |
| +def _StartsWith(a, b, prefix): |
| + return a.startswith(prefix) or b.startswith(prefix) |