Esempio n. 1
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)
Esempio n. 2
0
def _get_exec_paths():
    """Returns the list of paths for executable files and directories.

  On ChromeOS, most files are copied to the directories that are mounted with
  noexec option, but the files in the list returned by this function, or
  contained in a directory in the list, are copied to the directory mounted
  without noexec option, so that executables can be executed directly for
  testing.
  """
    return sorted([
        build_common.expand_path_placeholder(path) for path in _EXEC_PATTERNS
    ] + [toolchain.get_adb_path_for_chromeos()] +
                  unittest_util.get_nacl_tools() +
                  unittest_util.get_test_executables(
                      test for test in unittest_util.get_all_tests()
                      if not unittest_util.is_bionic_fundamental_test(test)))
def _get_exec_paths():
    """Returns the list of paths for executable files and directories.

  On ChromeOS, most files are copied to the directories that are mounted with
  noexec option, but the files in the list returned by this function, or
  contained in a directory in the list, are copied to the directory mounted
  without noexec option, so that executables can be executed directly for
  testing.
  """
    return sorted(
        [build_common.expand_path_placeholder(path) for path in _EXEC_PATTERNS]
        + [toolchain.get_adb_path_for_chromeos()]
        + unittest_util.get_nacl_tools()
        + unittest_util.get_test_executables(
            test for test in unittest_util.get_all_tests() if not unittest_util.is_bionic_fundamental_test(test)
        )
    )
Esempio n. 4
0
def get_integration_test_deps():
  """Returns a list of paths needed to run ./run_integration_tests.

  The returned path may be a directory. In that case, all its descendants are
  needed.
  """
  # Note: integration test depends on ./launch_chrome. Also, we run unittests
  # as a part of integration test on ChromeOS.
  glob_template_list = (
      _COMMON_GLOB_TEMPLATE_LIST + _LAUNCH_CHROME_GLOB_TEMPLATE_LIST +
      _INTEGRATION_TEST_GLOB_TEMPLATE_LIST + _UNITTEST_GLOB_TEMPLATE_LIST +
      _get_gms_core_apitest_data_roots_glob_template())
  patterns = (
      map(build_common.expand_path_placeholder, glob_template_list) +
      [toolchain.get_adb_path_for_chromeos()] +
      unittest_util.get_nacl_tools() +
      unittest_util.get_test_executables(unittest_util.get_all_tests()))
  return file_util.glob(*patterns)
Esempio n. 5
0
def get_integration_test_deps():
    """Returns a list of paths needed to run ./run_integration_tests.

  The returned path may be a directory. In that case, all its descendants are
  needed.
  """
    # Note: integration test depends on ./launch_chrome. Also, we run unittests
    # as a part of integration test on ChromeOS.
    glob_template_list = (_COMMON_GLOB_TEMPLATE_LIST +
                          _LAUNCH_CHROME_GLOB_TEMPLATE_LIST +
                          _INTEGRATION_TEST_GLOB_TEMPLATE_LIST +
                          _UNITTEST_GLOB_TEMPLATE_LIST +
                          _get_gms_core_apitest_data_roots_glob_template())
    patterns = (
        map(build_common.expand_path_placeholder, glob_template_list) +
        [toolchain.get_adb_path_for_chromeos()] +
        unittest_util.get_nacl_tools() +
        unittest_util.get_test_executables(unittest_util.get_all_tests()))
    return file_util.glob(*patterns)
Esempio n. 6
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)