| 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..5c948c8fde4cd4d1479ac4dad326c978c8f32571
|
| --- /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."""
|
| +
|
| +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')
|
| +
|
| + # 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 test_dispatcher.py 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)
|
|
|