Exemple #1
0
def main():
    OPTIONS.parse_configure_file()
    parser = argparse.ArgumentParser(
        description=__doc__, formatter_class=argparse.RawTextHelpFormatter)
    parser.add_argument('mode', choices=_TEST_CLASS_MAP.keys())
    parser.add_argument(
        '--iterations',
        default=20,
        type=int,
        help=('Number of iterations to run after warmup phase. '
              'The default is 20.'))
    parser.add_argument('--test-mode',
                        action='store_true',
                        help='Test mode. Parse %s and exit.' %
                        _OUTPUT_LOG_FILE)
    parser.add_argument('--verbose',
                        '-v',
                        action='store_true',
                        help='Verbose mode')

    remote_executor.add_remote_arguments(parser)

    args = parser.parse_args()
    remote_executor.maybe_detect_remote_host_type(args)
    logging_util.setup(
        level=logging.DEBUG if args.verbose else logging.WARNING)

    clazz = create_test_class(args.mode)
    clazz(args).main()
Exemple #2
0
def main():
  build_options.OPTIONS.parse_configure_file()

  description = 'Runs unit tests, verifying they pass.'
  parser = argparse.ArgumentParser(description=description)
  parser.add_argument('tests', metavar='test', nargs='*',
                      help=('The name of a unit test, such as libcommon_test.'
                            'If tests argument is not given, all unit tests '
                            'are run.'))
  parser.add_argument('--gdb', action='store_true', default=False,
                      help='Run the test under GDB.')
  parser.add_argument('-f', '--gtest-filter',
                      help='A \':\' separated list of googletest test filters')
  parser.add_argument('--gtest-list-tests', action='store_true', default=False,
                      help='Lists the test names to run')
  parser.add_argument('--list', action='store_true',
                      help='List the names of tests.')
  parser.add_argument('-v', '--verbose', action='store_true',
                      default=False, dest='verbose',
                      help=('Show verbose output, including commands run'))
  remote_executor.add_remote_arguments(parser)
  parsed_args = parser.parse_args()
  remote_executor.maybe_detect_remote_host_type(parsed_args)

  if parsed_args.list:
    for test_name in unittest_util.get_all_tests():
      print test_name
    return 0

  _check_args(parsed_args)

  if not parsed_args.tests:
    parsed_args.tests = unittest_util.get_all_tests()
    # Bionic fundamental tests are not supported on remote host.
    if parsed_args.remote:
      parsed_args.tests = [
          t for t in parsed_args.tests
          if not unittest_util.is_bionic_fundamental_test(t)]

  if parsed_args.gdb:
    # This script must not die by Ctrl-C while GDB is running. We simply
    # ignore SIGINT. Note that GDB will still handle Ctrl-C properly
    # because GDB sets its signal handler by itself.
    signal.signal(signal.SIGINT, signal.SIG_IGN)

  if parsed_args.remote:
    return remote_executor.run_remote_unittest(parsed_args)
  else:
    return _run_unittest(parsed_args.tests, parsed_args.verbose,
                         parsed_args.gdb, parsed_args.gtest_filter,
                         parsed_args.gtest_list_tests)
Exemple #3
0
def main():
  OPTIONS.parse_configure_file()
  parser = argparse.ArgumentParser(
      description=__doc__,
      formatter_class=argparse.RawTextHelpFormatter)
  parser.add_argument('mode', choices=_TEST_CLASS_MAP.keys())
  parser.add_argument('--iterations', default=20, type=int,
                      help=('Number of iterations to run after warmup phase. '
                            'The default is 20.'))
  parser.add_argument('--test-mode', action='store_true',
                      help='Test mode. Parse %s and exit.' % _OUTPUT_LOG_FILE)
  parser.add_argument('--verbose', '-v', action='store_true',
                      help='Verbose mode')

  remote_executor.add_remote_arguments(parser)

  args = parser.parse_args()
  remote_executor.maybe_detect_remote_host_type(args)
  logging_util.setup(level=logging.DEBUG if args.verbose else logging.WARNING)

  clazz = create_test_class(args.mode)
  clazz(args).main()
Exemple #4
0
def parse_args(argv):
  parser = argparse.ArgumentParser(
      prog='launch_chrome.py',
      fromfile_prefix_chars='@',
      usage='%(prog)s [options...] <command> [...]',
      description="""Commands:

  arcwelder
      Start Chrome and launch the ARC Welder packaging tool.

  atftest [path-to-apk]*
      Starts Chrome, and launches the first set of tests found which target the
      last APK given. Some APKs test themselves, but others might test what
      would otherwise be the full app. If you do have multiple APKs, list the
      one which contains the unit test code first, and the code being tested
      second.

      The output of Chrome will be examined for any test related messages, and
      the exit code of the script process will be set according to whether it
      passed or failed.

  run [path-to-apk]*
      Start Chrome with one or more Android APKs. Only the last one listed has
      its default activity launched.

      If no APKs are given, a sample set is used by default.

  system
      Starts Chrome with ARC system services, but no APK. AdbService is
      enabled so to accept adb commands through the network.

  perftest [path-to-apk]*
      Test that the given APKs can be started and print the time to boot.

      If no APKs are given, a sample set is used by default.

Native Client Debugging

  When debugging NativeClient, you can also increase logging output with
  these environment variables:
    NACL_DEBUG_ENABLE=1
    PPAPI_BROWSER_DEBUG=1
    NACL_PLUGIN_DEBUG=1
    NACL_PPAPI_PROXY_DEBUG=1
    NACL_SRPC_DEBUG=[1-255] (higher is more output)
    NACLVERBOSITY=[1-255] (higher is more output)

  When you need to debug a remote machine (e.g. Chromebook), add them
  to _REMOTE_ENV[] in util/remote_chromeos_executor.py.
""", formatter_class=argparse.RawTextHelpFormatter)

  parser.add_argument('mode',
                      choices=('arcwelder', 'atftest', 'run', 'system',
                               'perftest'),
                      help=argparse.SUPPRESS)

  parser.add_argument('--additional-android-permissions',
                      metavar='<permisions>',
                      help='A comma separated list of additional Android'
                      ' permissions the CRX should declare.',
                      default=None)

  parser.add_argument('--additional-metadata', '-m', default={},
                      type=json.loads,
                      help='Add additional metadata to the crx.')

  parser.add_argument('--arc-strace-output', metavar='<file>',
                      default='out/arc_strace.txt',
                      help='Output file for --enable-arc-strace (default: '
                      'out/arc_strace.txt). Use \'stderr\' to send results to '
                      'stderr.')

  parser.add_argument('--atf-gtest-filter',
                      help='A \':\' separated list of googletest test filters '
                      'for ATF based gtest suite runner. The delimiter of the '
                      'TestCase and TestMethodName is \'.\'.')

  parser.add_argument('--atf-gtest-list',
                      help='A \':\' separated list of all googletest test '
                      'cases contained in the testing binary (regardless '
                      'whether it will run or not based on the '
                      '--atf-gtest-filter ) for ATF based gtest suite runner. '
                      'The delimiter of the TestCase and TestMethodName is '
                      '\'.\'.')

  parser.add_argument('--app-template', metavar='<path>', default=None,
                      help='Path to an override app template for apk_to_crx '
                      'packaging.')

  parser.add_argument('--no-cache-warming', action='store_true',
                      help='Works with perftest command only. Not starts the '
                      'plugin page before --iterations start counting.')

  parser.add_argument('--chrome-binary', metavar='<path>', default=None,
                      help='The path to the Chrome binary on which ARC '
                      'runs. Note that the directory containing the binary '
                      'needs to contain other data/binaries to run Chrome '
                      '(for example, nacl_helper is needed to be contained). '
                      'Be careful. There can be PPAPI compatibility issues '
                      'when the version of your Chrome binary is very '
                      'different from src/build/DEPS.chrome.')

  parser.add_argument('--chrome-arg', metavar='<arg>', action='append',
                      dest='chrome_args',
                      help='The additional argument for launching the Chrome.')

  parser.add_argument('--chrome-flakiness-retry', default=0, type=int,
                      help='The max number of retry when Chrome looks flaky. '
                      'This is applied for each iteration. This flag cannot '
                      'be used with --jdb, --jdb_port or --gdb flags at a same '
                      'time. Note that this number does not contain the first '
                      'run, i.e., --chrome-flakiness-retry=2 means that '
                      'the subprocess would be launched at most 3 times '
                      '(first run + 2 retries (in worst case)).')

  parser.add_argument('--crx-name-override', metavar='<path>', default=None,
                      help='The name of the CRX which will be generated '
                      'by this script from an APK. This will be set by '
                      'run_integration_tests to isolate each test. '
                      'The basename of APK will be used if not specified.')

  parser.add_argument('--disable-nacl-sandbox', action='store_true',
                      help='Disable NaCl sandbox.')

  parser.add_argument('--display', help='Use given display for Chrome')

  # TODO(crbug.com/313551): Remove this option and make it the default
  # once we remove all individual metadata options and only specify
  # metadata via -m option.
  parser.add_argument('--dogfood-metadata', '-D', action='store_true',
                      help='Use dogfood metadata settings to start this app')

  parser.add_argument('--enable-fake-video-source', action='store_true',
                      help='Enable a fake video source for testing')

  parser.add_argument('--enable-nacl-list-mappings', action='store_true',
                      help='Enable the nacl_list_mappings call.')

  parser.add_argument('--enable-osmesa', action='store_true', default=None,
                      help='Enable GL emulation with OSMesa.')

  parser.add_argument('--gdb', metavar='<targets>', default=[],
                      type=_parse_gdb_targets,
                      help='A comma-seperated list of targets to debug. '
                      'Possible values include: plugin, gpu, browser, '
                      'renderer.')

  parser.add_argument('--gdb-type',
                      choices=('xterm', 'wait', 'screen', 'emacsclient'),
                      default='xterm',
                      help='Specifies how GDB is launched. By default, it is '
                      'launched under GDB. If you specify "wait", the plugin '
                      'will not run until you attach GDB by yourself. '
                      'Currently "wait" is supported only for NaCl plugins.')

  parser.add_argument('--iteration-lock-file', metavar='<path>',
                      help='If a filename is specified, launch_chrome.py '
                      'touches a file and waits for it to be removed before '
                      'every perftest iteration.')

  parser.add_argument('--iterations', type=int, metavar='<N>',
                      help='Works with perftest command only.  Starts the '
                      'plugin page <N> times and prints average stats. '
                      'Starts counting after warmup iterations.')

  parser.add_argument('--jdb', dest='jdb_port', action='store_const',
                      default=None, const=8000,
                      help='Wait for a JDWP compliant debugger (such as jdb '
                      'or Eclipse) to connect. Once the user resumes, '
                      'booting will resume.')

  parser.add_argument('--jdb-type', dest='jdb_type',
                      choices=('eclipse', 'emacsclient', 'none'),
                      default='eclipse',
                      help='Specifies which java debugger is launched. If you '
                      'specify "none" it is launched in mode which waits JDWP '
                      'compliant debugger (such as jdb) to connect. Once the '
                      'user resumes, booting will resume. If you specify '
                      '"eclipse" then the Eclipse framework will be launched '
                      'and it will be automatically connected to debugger. '
                      'Implies --jdb.')

  parser.add_argument('--logcat', dest='logcat', metavar='[filterspecs]',
                      type=str, nargs='+', default=None,
                      help='Execute adb logcat with given filtersepcs.')

  parser.add_argument('--nacl-helper-nonsfi-binary', metavar='<path>',
                      help='The path to nacl_helper_nonsfi binary. This '
                      'option is usable only when both --remote and '
                      '--gdb=plugin are specified. If this is not specified, '
                      'nacl_helper_nonsfi will be copied from the remote host '
                      'but symbols in nacl_helper_nonsfi may be unavailable.')

  parser.add_argument('--nocrxbuild', dest='build_crx', action='store_false',
                      help='Do not to rebuild the crx - just use what is '
                      'already there.')

  parser.add_argument('--noninja', dest='run_ninja', action='store_false',
                      help='Do not attempt build before running the above '
                      'command.')

  parser.add_argument('--obb-main', type=str, default=None, metavar='<path>',
                      help='The main expansion file, e.g. '
                      'main.123.com.example.app.obb.')

  parser.add_argument('--obb-patch', type=str, default=None, metavar='<path>',
                      help='The patch expansion file, e.g. '
                      'patch.123.com.example.app.obb.')

  parser.add_argument('--perfstartup', type=int, metavar='<N>',
                      help='Launch with perf and collect data for the first '
                      '<N> seconds. Plugin will be killed after this timeout.')

  parser.add_argument('--lang', help='Set language for the Chrome')

  # TODO(crbug.com/254164): Get rid of the fake ATF test concept used
  # by NDK tests currently.
  parser.add_argument('--run-test-as-app', action='store_true',
                      help='Runs a test as an application and not as '
                      'instrumentation.')

  parser.add_argument('--run-test-classes', metavar='<classes>',
                      help='Used by atftest to specify which test classes to '
                      'run.')

  parser.add_argument('--run-test-packages', metavar='<packages>',
                      help='Used by atftest to specify which test packages to '
                      'run.')

  parser.add_argument('--silent', '-s', action='store_true',
                      help='Sets the default filter spec to silent.')

  parser.add_argument('--start-test-component', metavar='<component>',
                      help='Used by atftest to indicate how to launch the '
                      'tests.')

  parser.add_argument('--timeout', type=int, default=_DEFAULT_TIMEOUT,
                      metavar='<T>',
                      help='Works with atftest, system and perftest commands '
                      'only.  Specifies timeout for running test in seconds. '
                      'Default is ' + str(_DEFAULT_TIMEOUT) + ' sec.')

  parser.add_argument('--tracestartup', type=int, metavar='<N>',
                      help='Trace from browser startup (the first <N> '
                      'seconds) to collect data for chrome://tracing. Output '
                      'file is chrometrace.log.')

  parser.add_argument('--use-temporary-data-dirs', action='store_true',
                      help='Use a temporary directory as the user data '
                      'directory of Chrome. The launched Chrome has empty '
                      'profile and HTML5 filesystem and they will be '
                      'removed when this script finishes. The ARC data '
                      'directory, which contains the unpacked CRX files, is '
                      'also removed.')

  parser.add_argument('--use-all-play-services', action='store_true',
                      help='Enable all available Play Services APIs')

  parser.add_argument('--use-test-app', action='store_true',
                      help='Use the ARC Test App ID with enabled APIs')

  parser.add_argument('--user-data-dir', metavar='<path>',
                      help='Specify user data dir for Chrome to run')

  parser.add_argument('--verbose', '-v', action='store_true',
                      help='Show verbose logging')

  remote_executor.add_remote_arguments(parser)

  _add_parser_arguments_for_metadata(parser)

  # We do not support '--use-high-dpi=yes/no' here since as of today Chrome's
  # device scale setting is almost always 1.0 at this point except on Pixel
  # where this script is not needed.

  args, opts = parser.parse_known_args(
      launch_chrome_util.remove_leading_launch_chrome_args(argv))

  remote_executor.maybe_detect_remote_host_type(args)

  if not args.dogfood_metadata:
    _set_default_args(args)

  # Inject a few additional attributes to the parsed args that we'll use
  # throughout the rest of this script.
  setattr(args, 'arc_data_dir', None)
  setattr(args, 'apk_path_list', [])
  if not _parse_mode_arguments(opts, args):
    parser.print_help()
    sys.exit(1)

  _validate_perftest_settings(parser, args)
  _validate_system_settings(parser, args)
  _validate_debug_modes(parser, args)
  _validate_timeout(parser, args)
  _validate_valgrind(parser, args)
  _validate_flakiness_retry(parser, args)

  _resolve_perf_test_mode(args)
  _setup_filterspec_from_args(args)
  return args
Exemple #5
0
def parse_args(argv):
    parser = argparse.ArgumentParser(
        prog='launch_chrome.py',
        fromfile_prefix_chars='@',
        usage='%(prog)s [options...] <command> [...]',
        description="""Commands:

  arcwelder
      Start Chrome and launch the ARC Welder packaging tool.

  atftest [path-to-apk]*
      Starts Chrome, and launches the first set of tests found which target the
      last APK given. Some APKs test themselves, but others might test what
      would otherwise be the full app. If you do have multiple APKs, list the
      one which contains the unit test code first, and the code being tested
      second.

      The output of Chrome will be examined for any test related messages, and
      the exit code of the script process will be set according to whether it
      passed or failed.

  run [path-to-apk]*
      Start Chrome with one or more Android APKs. Only the last one listed has
      its default activity launched.

      If no APKs are given, a sample set is used by default.

  system
      Starts Chrome with ARC system services, but no APK. AdbService is
      enabled so to accept adb commands through the network.

  perftest [path-to-apk]*
      Test that the given APKs can be started and print the time to boot.

      If no APKs are given, a sample set is used by default.

Native Client Debugging

  When debugging NativeClient, you can also increase logging output with
  these environment variables:
    NACL_DEBUG_ENABLE=1
    PPAPI_BROWSER_DEBUG=1
    NACL_PLUGIN_DEBUG=1
    NACL_PPAPI_PROXY_DEBUG=1
    NACL_SRPC_DEBUG=[1-255] (higher is more output)
    NACLVERBOSITY=[1-255] (higher is more output)

  When you need to debug a remote machine (e.g. Chromebook), add them
  to _REMOTE_ENV[] in util/remote_chromeos_executor.py.
""",
        formatter_class=argparse.RawTextHelpFormatter)

    parser.add_argument('mode',
                        choices=('arcwelder', 'atftest', 'run', 'system',
                                 'perftest'),
                        help=argparse.SUPPRESS)

    parser.add_argument('--additional-android-permissions',
                        metavar='<permisions>',
                        help='A comma separated list of additional Android'
                        ' permissions the CRX should declare.',
                        default=None)

    parser.add_argument('--additional-metadata',
                        '-m',
                        default={},
                        type=json.loads,
                        help='Add additional metadata to the crx.')

    parser.add_argument(
        '--arc-strace-output',
        metavar='<file>',
        default='out/arc_strace.txt',
        help='Output file for --enable-arc-strace (default: '
        'out/arc_strace.txt). Use \'stderr\' to send results to '
        'stderr.')

    parser.add_argument(
        '--atf-gtest-filter',
        help='A \':\' separated list of googletest test filters '
        'for ATF based gtest suite runner. The delimiter of the '
        'TestCase and TestMethodName is \'.\'.')

    parser.add_argument(
        '--atf-gtest-list',
        help='A \':\' separated list of all googletest test '
        'cases contained in the testing binary (regardless '
        'whether it will run or not based on the '
        '--atf-gtest-filter ) for ATF based gtest suite runner. '
        'The delimiter of the TestCase and TestMethodName is '
        '\'.\'.')

    parser.add_argument('--app-template',
                        metavar='<path>',
                        default=None,
                        help='Path to an override app template for apk_to_crx '
                        'packaging.')

    parser.add_argument(
        '--no-cache-warming',
        action='store_true',
        help='Works with perftest command only. Not starts the '
        'plugin page before --iterations start counting.')

    parser.add_argument(
        '--chrome-binary',
        metavar='<path>',
        default=None,
        help='The path to the Chrome binary on which ARC '
        'runs. Note that the directory containing the binary '
        'needs to contain other data/binaries to run Chrome '
        '(for example, nacl_helper is needed to be contained). '
        'Be careful. There can be PPAPI compatibility issues '
        'when the version of your Chrome binary is very '
        'different from src/build/DEPS.chrome.')

    parser.add_argument(
        '--chrome-arg',
        metavar='<arg>',
        action='append',
        dest='chrome_args',
        help='The additional argument for launching the Chrome.')

    parser.add_argument(
        '--chrome-flakiness-retry',
        default=0,
        type=int,
        help='The max number of retry when Chrome looks flaky. '
        'This is applied for each iteration. This flag cannot '
        'be used with --jdb, --jdb_port or --gdb flags at a same '
        'time. Note that this number does not contain the first '
        'run, i.e., --chrome-flakiness-retry=2 means that '
        'the subprocess would be launched at most 3 times '
        '(first run + 2 retries (in worst case)).')

    parser.add_argument('--crx-name-override',
                        metavar='<path>',
                        default=None,
                        help='The name of the CRX which will be generated '
                        'by this script from an APK. This will be set by '
                        'run_integration_tests to isolate each test. '
                        'The basename of APK will be used if not specified.')

    parser.add_argument('--disable-nacl-sandbox',
                        action='store_true',
                        help='Disable NaCl sandbox.')

    parser.add_argument('--display', help='Use given display for Chrome')

    # TODO(crbug.com/313551): Remove this option and make it the default
    # once we remove all individual metadata options and only specify
    # metadata via -m option.
    parser.add_argument('--dogfood-metadata',
                        '-D',
                        action='store_true',
                        help='Use dogfood metadata settings to start this app')

    parser.add_argument('--enable-fake-video-source',
                        action='store_true',
                        help='Enable a fake video source for testing')

    parser.add_argument('--enable-nacl-list-mappings',
                        action='store_true',
                        help='Enable the nacl_list_mappings call.')

    parser.add_argument('--enable-osmesa',
                        action='store_true',
                        default=None,
                        help='Enable GL emulation with OSMesa.')

    parser.add_argument('--gdb',
                        metavar='<targets>',
                        default=[],
                        type=_parse_gdb_targets,
                        help='A comma-seperated list of targets to debug. '
                        'Possible values include: plugin, gpu, browser, '
                        'renderer.')

    parser.add_argument(
        '--gdb-type',
        choices=('xterm', 'wait', 'screen', 'emacsclient'),
        default='xterm',
        help='Specifies how GDB is launched. By default, it is '
        'launched under GDB. If you specify "wait", the plugin '
        'will not run until you attach GDB by yourself. '
        'Currently "wait" is supported only for NaCl plugins.')

    parser.add_argument('--iteration-lock-file',
                        metavar='<path>',
                        help='If a filename is specified, launch_chrome.py '
                        'touches a file and waits for it to be removed before '
                        'every perftest iteration.')

    parser.add_argument('--iterations',
                        type=int,
                        metavar='<N>',
                        help='Works with perftest command only.  Starts the '
                        'plugin page <N> times and prints average stats. '
                        'Starts counting after warmup iterations.')

    parser.add_argument('--jdb',
                        dest='jdb_port',
                        action='store_const',
                        default=None,
                        const=8000,
                        help='Wait for a JDWP compliant debugger (such as jdb '
                        'or Eclipse) to connect. Once the user resumes, '
                        'booting will resume.')

    parser.add_argument(
        '--jdb-type',
        dest='jdb_type',
        choices=('eclipse', 'emacsclient', 'none'),
        default='eclipse',
        help='Specifies which java debugger is launched. If you '
        'specify "none" it is launched in mode which waits JDWP '
        'compliant debugger (such as jdb) to connect. Once the '
        'user resumes, booting will resume. If you specify '
        '"eclipse" then the Eclipse framework will be launched '
        'and it will be automatically connected to debugger. '
        'Implies --jdb.')

    parser.add_argument('--logcat',
                        dest='logcat',
                        metavar='[filterspecs]',
                        type=str,
                        nargs='+',
                        default=None,
                        help='Execute adb logcat with given filtersepcs.')

    parser.add_argument(
        '--nacl-helper-nonsfi-binary',
        metavar='<path>',
        help='The path to nacl_helper_nonsfi binary. This '
        'option is usable only when both --remote and '
        '--gdb=plugin are specified. If this is not specified, '
        'nacl_helper_nonsfi will be copied from the remote host '
        'but symbols in nacl_helper_nonsfi may be unavailable.')

    parser.add_argument('--nocrxbuild',
                        dest='build_crx',
                        action='store_false',
                        help='Do not to rebuild the crx - just use what is '
                        'already there.')

    parser.add_argument('--noninja',
                        dest='run_ninja',
                        action='store_false',
                        help='Do not attempt build before running the above '
                        'command.')

    parser.add_argument('--obb-main',
                        type=str,
                        default=None,
                        metavar='<path>',
                        help='The main expansion file, e.g. '
                        'main.123.com.example.app.obb.')

    parser.add_argument('--obb-patch',
                        type=str,
                        default=None,
                        metavar='<path>',
                        help='The patch expansion file, e.g. '
                        'patch.123.com.example.app.obb.')

    parser.add_argument(
        '--perfstartup',
        type=int,
        metavar='<N>',
        help='Launch with perf and collect data for the first '
        '<N> seconds. Plugin will be killed after this timeout.')

    parser.add_argument('--lang', help='Set language for the Chrome')

    # TODO(crbug.com/254164): Get rid of the fake ATF test concept used
    # by NDK tests currently.
    parser.add_argument('--run-test-as-app',
                        action='store_true',
                        help='Runs a test as an application and not as '
                        'instrumentation.')

    parser.add_argument(
        '--run-test-classes',
        metavar='<classes>',
        help='Used by atftest to specify which test classes to '
        'run.')

    parser.add_argument(
        '--run-test-packages',
        metavar='<packages>',
        help='Used by atftest to specify which test packages to '
        'run.')

    parser.add_argument('--silent',
                        '-s',
                        action='store_true',
                        help='Sets the default filter spec to silent.')

    parser.add_argument('--start-test-component',
                        metavar='<component>',
                        help='Used by atftest to indicate how to launch the '
                        'tests.')

    parser.add_argument(
        '--timeout',
        type=int,
        default=_DEFAULT_TIMEOUT,
        metavar='<T>',
        help='Works with atftest, system and perftest commands '
        'only.  Specifies timeout for running test in seconds. '
        'Default is ' + str(_DEFAULT_TIMEOUT) + ' sec.')

    parser.add_argument(
        '--tracestartup',
        type=int,
        metavar='<N>',
        help='Trace from browser startup (the first <N> '
        'seconds) to collect data for chrome://tracing. Output '
        'file is chrometrace.log.')

    parser.add_argument('--use-temporary-data-dirs',
                        action='store_true',
                        help='Use a temporary directory as the user data '
                        'directory of Chrome. The launched Chrome has empty '
                        'profile and HTML5 filesystem and they will be '
                        'removed when this script finishes. The ARC data '
                        'directory, which contains the unpacked CRX files, is '
                        'also removed.')

    parser.add_argument('--use-all-play-services',
                        action='store_true',
                        help='Enable all available Play Services APIs')

    parser.add_argument('--use-test-app',
                        action='store_true',
                        help='Use the ARC Test App ID with enabled APIs')

    parser.add_argument('--user-data-dir',
                        metavar='<path>',
                        help='Specify user data dir for Chrome to run')

    parser.add_argument('--verbose',
                        '-v',
                        action='store_true',
                        help='Show verbose logging')

    remote_executor.add_remote_arguments(parser)

    _add_parser_arguments_for_metadata(parser)

    # We do not support '--use-high-dpi=yes/no' here since as of today Chrome's
    # device scale setting is almost always 1.0 at this point except on Pixel
    # where this script is not needed.

    args, opts = parser.parse_known_args(
        launch_chrome_util.remove_leading_launch_chrome_args(argv))

    remote_executor.maybe_detect_remote_host_type(args)

    if not args.dogfood_metadata:
        _set_default_args(args)

    # Inject a few additional attributes to the parsed args that we'll use
    # throughout the rest of this script.
    setattr(args, 'arc_data_dir', None)
    setattr(args, 'apk_path_list', [])
    if not _parse_mode_arguments(opts, args):
        parser.print_help()
        sys.exit(1)

    _validate_perftest_settings(parser, args)
    _validate_system_settings(parser, args)
    _validate_debug_modes(parser, args)
    _validate_timeout(parser, args)
    _validate_valgrind(parser, args)
    _validate_flakiness_retry(parser, args)

    _resolve_perf_test_mode(args)
    _setup_filterspec_from_args(args)
    return args
Exemple #6
0
def parse_args(args):
    description = 'Runs integration tests, verifying they pass.'
    parser = argparse.ArgumentParser(description=description)
    parser.add_argument('--buildbot',
                        action='store_true',
                        help='Run tests '
                        'for the buildbot.')
    parser.add_argument('--tracing',
                        type=str,
                        metavar='TRACING_FILE',
                        help='Output the results in Chrome tracing format')
    parser.add_argument('--ansi',
                        action='store_true',
                        help='Color output using ansi escape sequence')
    parser.add_argument('--cts-bot',
                        action='store_true',
                        help='Run with CTS bot specific config.')
    parser.add_argument('--enable-osmesa',
                        action='store_true',
                        help=('This flag wlll be passed to launch_chome '
                              'to control GL emulation with OSMesa.'))
    parser.add_argument('--include-failing',
                        action='store_true',
                        help='Include tests which are expected to fail.')
    parser.add_argument(
        '--include-large',
        action='store_true',
        help=('Include large tests that may take a long time to '
              'run.'))
    parser.add_argument('--include-timeouts',
                        action='store_true',
                        help='Include tests which are expected to timeout.')
    parser.add_argument('-j',
                        '--jobs',
                        metavar='N',
                        type=int,
                        default=_default_number_of_jobs(),
                        help='Run N tests at once.')
    parser.add_argument(
        '--keep-running',
        action='store_true',
        help=('Attempt to recover from unclean failures. '
              'Sacrifices failing quickly for complete results. '
              ''))
    parser.add_argument(
        '--launch-chrome-opt',
        action='append',
        default=[],
        dest='launch_chrome_opts',
        metavar='OPTIONS',
        help=('An Option to pass on to launch_chrome. Repeat as '
              'needed for any options to pass on.'))
    parser.add_argument('--list',
                        action='store_true',
                        help=('List the fully qualified names of tests and '
                              'expectations. Can be used with -t and '
                              '--include-* flags.'))
    parser.add_argument('--max-deadline',
                        '--max-timeout',
                        metavar='T',
                        default=0,
                        type=int,
                        help=('Maximum deadline for browser tests. The test '
                              'configuration deadlines are used by default.'))
    parser.add_argument('--min-deadline',
                        '--min-timeout',
                        metavar='T',
                        default=0,
                        type=int,
                        help=('Minimum deadline for browser tests. The test '
                              'configuration deadlines are used by default.'))
    parser.add_argument('--noninja',
                        action='store_false',
                        dest='run_ninja',
                        help='Do not run ninja before running any tests.')
    parser.add_argument('--noprepare',
                        action='store_false',
                        dest='prepare',
                        help='Do not run the suite prepare step - useful for '
                        'running integration tests from an archived test '
                        'bundle.')
    parser.add_argument(
        '-o',
        '--output-dir',
        metavar='DIR',
        default='out/integration_tests',
        help='Specify the directory to store test ouput files.')
    parser.add_argument('--plan-report',
                        action='store_true',
                        help=('Generate a report of all tests based on their '
                              'currently configured expectation of success.'))
    parser.add_argument(
        '-q',
        '--quiet',
        action='store_true',
        help='Do not show passing tests and expected failures.')
    parser.add_argument('--stop',
                        action='store_true',
                        help=('Stops running tests immediately when a failure '
                              'is reported.'))
    parser.add_argument('-t',
                        '--include',
                        action='append',
                        dest='include_patterns',
                        default=[],
                        metavar='PATTERN',
                        help=('Identifies tests to include, using shell '
                              'style glob patterns. For example dalvik.*'))
    parser.add_argument('--times',
                        metavar='N',
                        default=1,
                        type=int,
                        dest='repeat_runs',
                        help='Runs each test N times.')
    parser.add_argument('--total-timeout',
                        metavar='T',
                        default=0,
                        type=int,
                        help=('If specified, this script stops after running '
                              'this seconds.'))
    parser.add_argument('--use-xvfb',
                        action='store_true',
                        help='Use xvfb-run '
                        'when launching tests.  Used by buildbots.')
    parser.add_argument('-v',
                        '--verbose',
                        action='store_const',
                        const='verbose',
                        dest='output',
                        help='Verbose output.')
    parser.add_argument('--warn-on-failure',
                        action='store_true',
                        help=('Indicates that failing tests should become '
                              'warnings rather than errors.'))
    parser.add_argument(
        '-x',
        '--exclude',
        action='append',
        dest='exclude_patterns',
        default=[],
        metavar='PATTERN',
        help=('Identifies tests to exclude, using shell '
              'style glob patterns. For example dalvik.tests.*'))

    remote_executor.add_remote_arguments(parser)

    args = parser.parse_args(args)
    remote_executor.maybe_detect_remote_host_type(args)
    return args
Exemple #7
0
def parse_args(args):
  description = 'Runs integration tests, verifying they pass.'
  parser = argparse.ArgumentParser(description=description)
  parser.add_argument('--buildbot', action='store_true', help='Run tests '
                      'for the buildbot.')
  parser.add_argument('--tracing', type=str, metavar='TRACING_FILE',
                      help='Output the results in Chrome tracing format')
  parser.add_argument('--ansi', action='store_true',
                      help='Color output using ansi escape sequence')
  parser.add_argument('--cts-bot', action='store_true',
                      help='Run with CTS bot specific config.')
  parser.add_argument('--enable-osmesa', action='store_true',
                      help=('This flag wlll be passed to launch_chome '
                            'to control GL emulation with OSMesa.'))
  parser.add_argument('--include-failing', action='store_true',
                      help='Include tests which are expected to fail.')
  parser.add_argument('--include-large', action='store_true',
                      help=('Include large tests that may take a long time to '
                            'run.'))
  parser.add_argument('--include-timeouts', action='store_true',
                      help='Include tests which are expected to timeout.')
  parser.add_argument('-j', '--jobs', metavar='N', type=int,
                      default=_default_number_of_jobs(),
                      help='Run N tests at once.')
  parser.add_argument('--keep-running', action='store_true',
                      help=('Attempt to recover from unclean failures. '
                            'Sacrifices failing quickly for complete results. '
                            ''))
  parser.add_argument('--launch-chrome-opt', action='append', default=[],
                      dest='launch_chrome_opts', metavar='OPTIONS',
                      help=('An Option to pass on to launch_chrome. Repeat as '
                            'needed for any options to pass on.'))
  parser.add_argument('--list', action='store_true',
                      help=('List the fully qualified names of tests and '
                            'expectations. Can be used with -t and '
                            '--include-* flags.'))
  parser.add_argument('--max-deadline', '--max-timeout',
                      metavar='T', default=0, type=int,
                      help=('Maximum deadline for browser tests. The test '
                            'configuration deadlines are used by default.'))
  parser.add_argument('--min-deadline', '--min-timeout',
                      metavar='T', default=0, type=int,
                      help=('Minimum deadline for browser tests. The test '
                            'configuration deadlines are used by default.'))
  parser.add_argument('--noninja', action='store_false', dest='run_ninja',
                      help='Do not run ninja before running any tests.')
  parser.add_argument('--noprepare', action='store_false', dest='prepare',
                      help='Do not run the suite prepare step - useful for '
                           'running integration tests from an archived test '
                           'bundle.')
  parser.add_argument('-o', '--output-dir', metavar='DIR',
                      default='out/integration_tests',
                      help='Specify the directory to store test ouput files.')
  parser.add_argument('--plan-report', action='store_true',
                      help=('Generate a report of all tests based on their '
                            'currently configured expectation of success.'))
  parser.add_argument('-q', '--quiet', action='store_true',
                      help='Do not show passing tests and expected failures.')
  parser.add_argument('--stop', action='store_true',
                      help=('Stops running tests immediately when a failure '
                            'is reported.'))
  parser.add_argument('-t', '--include', action='append',
                      dest='include_patterns', default=[], metavar='PATTERN',
                      help=('Identifies tests to include, using shell '
                            'style glob patterns. For example dalvik.*'))
  parser.add_argument('--times', metavar='N',
                      default=1, type=int, dest='repeat_runs',
                      help='Runs each test N times.')
  parser.add_argument('--total-timeout', metavar='T', default=0, type=int,
                      help=('If specified, this script stops after running '
                            'this seconds.'))
  parser.add_argument('--use-xvfb', action='store_true', help='Use xvfb-run '
                      'when launching tests.  Used by buildbots.')
  parser.add_argument('-v', '--verbose', action='store_const', const='verbose',
                      dest='output', help='Verbose output.')
  parser.add_argument('--warn-on-failure', action='store_true',
                      help=('Indicates that failing tests should become '
                            'warnings rather than errors.'))
  parser.add_argument('-x', '--exclude', action='append',
                      dest='exclude_patterns', default=[], metavar='PATTERN',
                      help=('Identifies tests to exclude, using shell '
                            'style glob patterns. For example dalvik.tests.*'))

  remote_executor.add_remote_arguments(parser)

  args = parser.parse_args(args)
  remote_executor.maybe_detect_remote_host_type(args)
  return args
Exemple #8
0
def main():
    build_options.OPTIONS.parse_configure_file()

    description = 'Runs unit tests, verifying they pass.'
    parser = argparse.ArgumentParser(description=description)
    parser.add_argument(
        'tests',
        metavar='test',
        nargs='*',
        help=('The name of a unit test, such as libcommon_test.'
              'If tests argument is not given, all unit tests '
              'are run.'))
    parser.add_argument('--gdb',
                        action='store_true',
                        default=False,
                        help='Run the test under GDB.')
    parser.add_argument(
        '-f',
        '--gtest-filter',
        help='A \':\' separated list of googletest test filters')
    parser.add_argument('--gtest-list-tests',
                        action='store_true',
                        default=False,
                        help='Lists the test names to run')
    parser.add_argument('--list',
                        action='store_true',
                        help='List the names of tests.')
    parser.add_argument('-v',
                        '--verbose',
                        action='store_true',
                        default=False,
                        dest='verbose',
                        help=('Show verbose output, including commands run'))
    remote_executor.add_remote_arguments(parser)
    parsed_args = parser.parse_args()
    remote_executor.maybe_detect_remote_host_type(parsed_args)

    if parsed_args.list:
        for test_name in unittest_util.get_all_tests():
            print test_name
        return 0

    _check_args(parsed_args)

    if not parsed_args.tests:
        parsed_args.tests = unittest_util.get_all_tests()
        # Bionic fundamental tests are not supported on remote host.
        if parsed_args.remote:
            parsed_args.tests = [
                t for t in parsed_args.tests
                if not unittest_util.is_bionic_fundamental_test(t)
            ]

    if parsed_args.gdb:
        # This script must not die by Ctrl-C while GDB is running. We simply
        # ignore SIGINT. Note that GDB will still handle Ctrl-C properly
        # because GDB sets its signal handler by itself.
        signal.signal(signal.SIGINT, signal.SIG_IGN)

    if parsed_args.remote:
        return remote_executor.run_remote_unittest(parsed_args)
    else:
        return _run_unittest(parsed_args.tests, parsed_args.verbose,
                             parsed_args.gdb, parsed_args.gtest_filter,
                             parsed_args.gtest_list_tests)