コード例 #1
0
ファイル: run_unittest.py プロジェクト: epowers/arc
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)
コード例 #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)))
コード例 #3
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)
        )
    )
コード例 #4
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)