Пример #1
0
def main():
    parser = optparse.OptionParser()
    parser.add_option('--output-format',
                      default='html',
                      help='The output format of the results file.')
    parser.add_option(
        '--output-dir',
        default=None,
        help='The directory for the output file. Default value is '
        'the base directory of this script.')
    options, _ = parser.parse_args()
    constants.SetBuildType(perf_test_utils.BUILD_TYPE)
    # Install APK
    device = GetDevice()
    device.EnableRoot()
    device.Install(perf_test_utils.APP_APK)
    # Start USB reverse tethering.
    android_rndis_forwarder.AndroidRndisForwarder(
        device, perf_test_utils.GetAndroidRndisConfig(device))
    # Start HTTP server.
    http_server_doc_root = perf_test_utils.GenerateHttpTestResources()
    config_file = tempfile.NamedTemporaryFile()
    http_server = lighttpd_server.LighttpdServer(
        http_server_doc_root,
        port=perf_test_utils.HTTP_PORT,
        base_config_path=config_file.name)
    perf_test_utils.GenerateLighttpdConfig(config_file, http_server_doc_root,
                                           http_server)
    assert http_server.StartupHttpServer()
    config_file.close()
    # Start QUIC server.
    quic_server_doc_root = perf_test_utils.GenerateQuicTestResources(device)
    quic_server = perf_test_utils.QuicServer(quic_server_doc_root)
    quic_server.StartupQuicServer(device)
    # Launch Telemetry's benchmark_runner on CronetPerfTestBenchmark.
    # By specifying this file's directory as the benchmark directory, it will
    # allow benchmark_runner to in turn open this file up and find the
    # CronetPerfTestBenchmark class to run the benchmark.
    top_level_dir = os.path.dirname(os.path.realpath(__file__))
    expectations_files = [os.path.join(top_level_dir, 'expectations.config')]
    runner_config = chromium_config.ChromiumConfig(
        top_level_dir=top_level_dir,
        benchmark_dirs=[top_level_dir],
        expectations_files=expectations_files)
    sys.argv.insert(1, 'run')
    sys.argv.insert(2, 'run.CronetPerfTestBenchmark')
    sys.argv.insert(3, '--browser=android-system-chrome')
    sys.argv.insert(4, '--output-format=' + options.output_format)
    if options.output_dir:
        sys.argv.insert(5, '--output-dir=' + options.output_dir)
    benchmark_runner.main(runner_config)
    # Shutdown.
    quic_server.ShutdownQuicServer()
    shutil.rmtree(quic_server_doc_root)
    http_server.ShutdownHttpServer()
    shutil.rmtree(http_server_doc_root)
Пример #2
0
def main():
    config = chromium_config.ChromiumConfig(
        benchmark_dirs=[
            path_util.GetOfficialBenchmarksDir(),
            path_util.GetContribDir()
        ],
        top_level_dir=path_util.GetPerfDir(),
        expectations_files=[path_util.GetExpectationsPath()])
    return benchmark_runner.main(config)
Пример #3
0
  def testMain_ReturnCode(self):
    """Test that benchmark_runner.main() respects return code from Telemetry."""
    config = mock.Mock()
    with mock.patch('core.benchmark_runner.command_line') as telemetry_cli:
      telemetry_cli.ParseArgs.side_effect = _FakeParseArgs
      telemetry_cli.RunCommand.return_value = 42

      # Note: We pass `--output-format none` and a non-existent output
      # dir to prevent the results processor from processing any results.
      return_code = benchmark_runner.main(config, [
          'run', 'some.benchmark', '--browser', 'stable',
          '--output-dir', '/does/not/exist', '--output-format', 'none'])
      self.assertEqual(return_code, 42)
Пример #4
0
    def testMain_returnCode(self):
        """Test that benchmark_runner.main() respects return code from Telemetry."""
        # TODO(crbug.com/985712): Ideally we should write a more "integration" kind
        # of test, where we don't mock out the Telemetry command line. This is
        # hard to do now, however, because we need a way to convert the browser
        # selection done by the test runner, back to a suitable --browser arg for
        # the command line below. Namely, we need an equivalent of
        # options_for_unittests.GetCopy() that returns a list of string args
        # rather than the parsed options object.
        config = mock.Mock()
        with mock.patch('core.benchmark_runner.command_line') as telemetry_cli:
            telemetry_cli.ParseArgs.side_effect = _FakeParseArgs
            telemetry_cli.RunCommand.return_value = 42

            # Note: For now we pass `--output-format none` and a non-existent output
            # dir to prevent the results processor from processing any results.
            return_code = benchmark_runner.main(config, [
                'run', 'some.benchmark', '--browser', 'stable', '--output-dir',
                '/does/not/exist', '--output-format', 'none'
            ])
            self.assertEqual(return_code, 42)
Пример #5
0
def main():
    return benchmark_runner.main(media_router_config.Config(['benchmarks']))