media/webrtc/trunk/build/android/run_instrumentation_tests.py

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rwxr-xr-x

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 #!/usr/bin/env python
     2 #
     3 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
     4 # Use of this source code is governed by a BSD-style license that can be
     5 # found in the LICENSE file.
     7 """Runs both the Python and Java tests."""
     9 import optparse
    10 import sys
    11 import time
    13 from pylib import apk_info
    14 from pylib import buildbot_report
    15 from pylib import ports
    16 from pylib import run_java_tests
    17 from pylib import run_python_tests
    18 from pylib import run_tests_helper
    19 from pylib import test_options_parser
    20 from pylib.test_result import TestResults
    23 def SummarizeResults(java_results, python_results, annotation, build_type):
    24   """Summarize the results from the various test types.
    26   Args:
    27     java_results: a TestResults object with java test case results.
    28     python_results: a TestResults object with python test case results.
    29     annotation: the annotation used for these results.
    30     build_type: 'Release' or 'Debug'.
    32   Returns:
    33     A tuple (all_results, summary_string, num_failing)
    34   """
    35   all_results = TestResults.FromTestResults([java_results, python_results])
    36   summary_string = all_results.LogFull('Instrumentation', annotation,
    37                                        build_type)
    38   num_failing = (len(all_results.failed) + len(all_results.crashed) +
    39                  len(all_results.unknown))
    40   return all_results, summary_string, num_failing
    43 def DispatchInstrumentationTests(options):
    44   """Dispatches the Java and Python instrumentation tests, sharding if possible.
    46   Uses the logging module to print the combined final results and
    47   summary of the Java and Python tests. If the java_only option is set, only
    48   the Java tests run. If the python_only option is set, only the python tests
    49   run. If neither are set, run both Java and Python tests.
    51   Args:
    52     options: command-line options for running the Java and Python tests.
    54   Returns:
    55     An integer representing the number of failing tests.
    56   """
    57   # Reset the test port allocation. It's important to do it before starting
    58   # to dispatch any tests.
    59   if not ports.ResetTestServerPortAllocation():
    60     raise Exception('Failed to reset test server port.')
    61   start_date = int(time.time() * 1000)
    62   java_results = TestResults()
    63   python_results = TestResults()
    65   if options.run_java_tests:
    66     java_results = run_java_tests.DispatchJavaTests(
    67         options,
    68         [apk_info.ApkInfo(options.test_apk_path, options.test_apk_jar_path)])
    69   if options.run_python_tests:
    70     python_results = run_python_tests.DispatchPythonTests(options)
    72   all_results, summary_string, num_failing = SummarizeResults(
    73       java_results, python_results, options.annotation, options.build_type)
    74   return num_failing
    77 def main(argv):
    78   option_parser = optparse.OptionParser()
    79   test_options_parser.AddInstrumentationOptions(option_parser)
    80   options, args = option_parser.parse_args(argv)
    81   test_options_parser.ValidateInstrumentationOptions(option_parser, options,
    82                                                      args)
    84   run_tests_helper.SetLogLevel(options.verbose_count)
    85   buildbot_report.PrintNamedStep(
    86       'Instrumentation tests: %s - %s' % (', '.join(options.annotation),
    87                                           options.test_apk))
    88   return DispatchInstrumentationTests(options)
    91 if __name__ == '__main__':
    92   sys.exit(main(sys.argv))

mercurial