示例#1
0
def Dispatch(options):
    attached_devices = []
    if options.test_device:
        attached_devices = [options.test_device]
    else:
        attached_devices = android_commands.GetAttachedDevices()

    if not attached_devices:
        logging.critical('A device must be attached and online.')
        return 1

    # Reset the test port allocation. It's important to do it before starting
    # to dispatch any tests.
    if not ports.ResetTestServerPortAllocation():
        raise Exception('Failed to reset test server port.')

    test_suite_dir = os.path.join(cmd_helper.OutDirectory.get(),
                                  options.build_type)
    options.test_suite = os.path.join(
        test_suite_dir, 'apks', constants.BROWSERTEST_SUITE_NAME + '.apk')

    # Constructs a new TestRunner with the current options.
    def RunnerFactory(device, shard_index):
        return test_runner.TestRunner(device, options.test_suite,
                                      options.test_arguments, options.timeout,
                                      options.cleanup_test_files, options.tool,
                                      options.build_type, options.webkit,
                                      constants.BROWSERTEST_TEST_PACKAGE_NAME,
                                      constants.BROWSERTEST_TEST_ACTIVITY_NAME,
                                      constants.BROWSERTEST_COMMAND_LINE_FILE)

        # Get tests and split them up based on the number of devices.

    if options.gtest_filter:
        all_tests = [t for t in options.gtest_filter.split(':') if t]
    else:
        all_enabled = gtest_dispatch.GetAllEnabledTests(
            RunnerFactory, attached_devices)
        all_tests = _FilterTests(all_enabled)

    # Run tests.
    # TODO(nileshagrawal): remove this abnormally long setup timeout once fewer
    # files are pushed to the devices for content_browsertests: crbug.com/138275
    setup_timeout = 20 * 60  # 20 minutes
    test_results = shard.ShardAndRunTests(RunnerFactory,
                                          attached_devices,
                                          all_tests,
                                          options.build_type,
                                          setup_timeout=setup_timeout,
                                          test_timeout=None,
                                          num_retries=options.num_retries)
    report_results.LogFull(results=test_results,
                           test_type='Unit test',
                           test_package=constants.BROWSERTEST_SUITE_NAME,
                           build_type=options.build_type,
                           flakiness_server=options.flakiness_dashboard_server)
    report_results.PrintAnnotation(test_results)
示例#2
0
def Dispatch(options):
    attached_devices = []
    if options.test_device:
        attached_devices = [options.test_device]
    else:
        attached_devices = android_commands.GetAttachedDevices()

    if not attached_devices:
        logging.critical('A device must be attached and online.')
        return 1

    # Reset the test port allocation. It's important to do it before starting
    # to dispatch any tests.
    if not ports.ResetTestServerPortAllocation():
        raise Exception('Failed to reset test server port.')

    test_suite_dir = os.path.join(cmd_helper.OutDirectory.get(),
                                  options.build_type)
    options.test_suite = os.path.join(test_suite_dir, 'apks',
                                      CONTENT_BROWSERTEST_SUITENAME + '.apk')

    options.test_arguments = '--single_process %s' % options.test_arguments

    # Constructs a new TestRunner with the current options.
    def RunnerFactory(device):
        return test_runner.TestRunner(device, options.test_suite,
                                      options.test_arguments, options.timeout,
                                      options.cleanup_test_files, options.tool,
                                      options.build_type, options.webkit,
                                      constants.BROWSERTEST_TEST_PACKAGE_NAME,
                                      constants.BROWSERTEST_TEST_ACTIVITY_NAME,
                                      constants.BROWSERTEST_COMMAND_LINE_FILE)

        # Get tests and split them up based on the number of devices.

    if options.gtest_filter:
        all_tests = [t for t in options.gtest_filter.split(':') if t]
    else:
        all_tests = gtest_dispatch.GetAllEnabledTests(RunnerFactory,
                                                      attached_devices)

    # Run tests.
    test_results = shard.ShardAndRunTests(RunnerFactory, attached_devices,
                                          all_tests, options.build_type)
    test_results.LogFull(test_type='Unit test',
                         test_package=CONTENT_BROWSERTEST_SUITENAME,
                         build_type=options.build_type,
                         flakiness_server=options.flakiness_dashboard_server)
    test_results.PrintAnnotation()