Beispiel #1
0
def RunTestsCommand(args):  # pylint: disable=too-many-return-statements
    """Checks test type and dispatches to the appropriate function.

  Args:
    args: argparse.Namespace object.

  Returns:
    Integer indicated exit code.

  Raises:
    Exception: Unknown command name passed in, or an exception from an
        individual test runner.
  """
    command = args.command

    ProcessCommonOptions(args)
    logging.info('command: %s', ' '.join(sys.argv))
    if args.enable_platform_mode or command in _DEFAULT_PLATFORM_MODE_TESTS:
        return RunTestsInPlatformMode(args)

    forwarder.Forwarder.RemoveHostLog()
    if not ports.ResetTestServerPortAllocation():
        raise Exception('Failed to reset test server port.')

    # pylint: disable=protected-access
    if os.path.exists(ports._TEST_SERVER_PORT_LOCKFILE):
        os.unlink(ports._TEST_SERVER_PORT_LOCKFILE)
    # pylint: enable=protected-access

    if command == 'python':
        return _RunPythonTests(args)
    else:
        raise Exception('Unknown test type.')
def RunTestsCommand(args, parser):  # pylint: disable=too-many-return-statements
    """Checks test type and dispatches to the appropriate function.

  Args:
    args: argparse.Namespace object.
    parser: argparse.ArgumentParser object.

  Returns:
    Integer indicated exit code.

  Raises:
    Exception: Unknown command name passed in, or an exception from an
        individual test runner.
  """
    command = args.command

    ProcessCommonOptions(args)

    if args.enable_platform_mode:
        return RunTestsInPlatformMode(args, parser)

    if command in constants.LOCAL_MACHINE_TESTS:
        devices = []
    else:
        devices = _GetAttachedDevices(args.blacklist_file, args.test_device)

    forwarder.Forwarder.RemoveHostLog()
    if not ports.ResetTestServerPortAllocation():
        raise Exception('Failed to reset test server port.')

    if command == 'gtest':
        return RunTestsInPlatformMode(args, parser)
    elif command == 'linker':
        return _RunLinkerTests(args, devices)
    elif command == 'instrumentation':
        return _RunInstrumentationTests(args, devices)
    elif command == 'uiautomator':
        return _RunUIAutomatorTests(args, devices)
    elif command == 'junit':
        return _RunJUnitTests(args)
    elif command == 'monkey':
        return _RunMonkeyTests(args, devices)
    elif command == 'perf':
        return _RunPerfTests(args, devices)
    elif command == 'python':
        return _RunPythonTests(args)
    else:
        raise Exception('Unknown test type.')
def RunTestsCommand(args):  # pylint: disable=too-many-return-statements
    """Checks test type and dispatches to the appropriate function.

  Args:
    args: argparse.Namespace object.

  Returns:
    Integer indicated exit code.

  Raises:
    Exception: Unknown command name passed in, or an exception from an
        individual test runner.
  """
    command = args.command

    ProcessCommonOptions(args)
    logging.info('command: %s', ' '.join(sys.argv))

    if args.enable_platform_mode:
        return RunTestsInPlatformMode(args)

    forwarder.Forwarder.RemoveHostLog()
    if not ports.ResetTestServerPortAllocation():
        raise Exception('Failed to reset test server port.')

    def get_devices():
        return _GetAttachedDevices(args.blacklist_file, args.test_device,
                                   args.enable_device_cache)

    if command == 'gtest':
        return RunTestsInPlatformMode(args)
    elif command == 'linker':
        return _RunLinkerTests(args, get_devices())
    elif command == 'instrumentation':
        return _RunInstrumentationTests(args, get_devices())
    elif command == 'junit':
        return _RunJUnitTests(args)
    elif command == 'monkey':
        return _RunMonkeyTests(args, get_devices())
    elif command == 'perf':
        return _RunPerfTests(args, get_devices())
    elif command == 'python':
        return _RunPythonTests(args)
    else:
        raise Exception('Unknown test type.')