예제 #1
0
    def __init__(self,
                 device,
                 test_suite,
                 test_arguments,
                 timeout,
                 cleanup_test_files,
                 tool_name,
                 build_type,
                 in_webkit_checkout,
                 test_apk_package_name=None,
                 test_activity_name=None,
                 command_line_file=None):
        super(TestRunner, self).__init__(device, tool_name, build_type)
        self._running_on_emulator = self.device.startswith('emulator')
        self._test_arguments = test_arguments
        self.in_webkit_checkout = in_webkit_checkout
        self._cleanup_test_files = cleanup_test_files

        logging.warning('Test suite: ' + test_suite)
        if os.path.splitext(test_suite)[1] == '.apk':
            self.test_package = test_package_apk.TestPackageApk(
                self.adb, device, test_suite, timeout,
                self._cleanup_test_files, self.tool, test_apk_package_name,
                test_activity_name, command_line_file)
        else:
            # Put a copy into the android out/target directory, to allow stack trace
            # generation.
            symbols_dir = os.path.join(constants.CHROME_DIR, 'out', build_type,
                                       'lib.target')
            self.test_package = test_package_executable.TestPackageExecutable(
                self.adb, device, test_suite, timeout,
                self._cleanup_test_files, self.tool, symbols_dir)
예제 #2
0
def Setup(test_options, devices):
    """Create the test runner factory and tests.

  Args:
    test_options: A GTestOptions object.
    devices: A list of attached devices.

  Returns:
    A tuple of (TestRunnerFactory, tests).
  """

    if not ports.ResetTestServerPortAllocation():
        raise Exception('Failed to reset test server port.')

    test_package = test_package_apk.TestPackageApk(test_options.suite_name)
    if not os.path.exists(test_package.suite_path):
        test_package = test_package_exe.TestPackageExecutable(
            test_options.suite_name)
        if not os.path.exists(test_package.suite_path):
            raise Exception(
                'Did not find %s target. Ensure it has been built.' %
                test_options.suite_name)
    logging.warning('Found target %s', test_package.suite_path)

    _GenerateDepsDirUsingIsolate(test_options.suite_name)

    # Constructs a new TestRunner with the current options.
    def TestRunnerFactory(device, shard_index):
        return test_runner.TestRunner(test_options, device, test_package)

    tests = _GetTestsFromDevice(TestRunnerFactory, devices)
    if test_options.run_disabled:
        test_options = test_options._replace(
            test_arguments=('%s --gtest_also_run_disabled_tests' %
                            test_options.test_arguments))
    else:
        tests = _FilterDisabledTests(tests, test_options.suite_name,
                                     bool(test_options.gtest_filter))
    if test_options.gtest_filter:
        tests = unittest_util.FilterTestNames(tests, test_options.gtest_filter)

    # Coalesce unit tests into a single test per device
    if test_options.suite_name != 'content_browsertests':
        num_devices = len(devices)
        tests = [':'.join(tests[i::num_devices]) for i in xrange(num_devices)]
        tests = [t for t in tests if t]

    return (TestRunnerFactory, tests)
예제 #3
0
def Setup(test_options):
    """Create the test runner factory and tests.

  Args:
    test_options: A GTestOptions object.

  Returns:
    A tuple of (TestRunnerFactory, tests).
  """

    if not ports.ResetTestServerPortAllocation():
        raise Exception('Failed to reset test server port.')

    test_package = test_package_apk.TestPackageApk(test_options.suite_name,
                                                   test_options.build_type)
    if not os.path.exists(test_package.suite_path):
        test_package = test_package_exe.TestPackageExecutable(
            test_options.suite_name, test_options.build_type)
        if not os.path.exists(test_package.suite_path):
            raise Exception(
                'Did not find %s target. Ensure it has been built.' %
                test_options.suite_name)
    logging.warning('Found target %s', test_package.suite_path)

    _GenerateDepsDirUsingIsolate(test_options.suite_name,
                                 test_options.build_type)

    # Constructs a new TestRunner with the current options.
    def TestRunnerFactory(device, shard_index):
        return test_runner.TestRunner(test_options, device, test_package)

    attached_devices = android_commands.GetAttachedDevices()
    tests = _GetTestsFiltered(test_options.suite_name,
                              test_options.gtest_filter, TestRunnerFactory,
                              attached_devices)
    # Coalesce unit tests into a single test per device
    if test_options.suite_name != 'content_browsertests':
        num_devices = len(attached_devices)
        tests = [':'.join(tests[i::num_devices]) for i in xrange(num_devices)]
        tests = [t for t in tests if t]

    return (TestRunnerFactory, tests)