Esempio n. 1
0
def main():
  logging.basicConfig()

  parser = argparse.ArgumentParser(usage=USAGE)

  debug_group = parser.add_mutually_exclusive_group()
  debug_group.add_argument('--debug', help='Debug build (default)',
                           default=True, action='store_true')
  debug_group.add_argument('--release', help='Release build', default=False,
                           dest='debug', action='store_false')
  parser.add_argument('--target-cpu', help='CPU architecture to run for.',
                      choices=['x64', 'x86', 'arm'], default='arm')
  parser.add_argument('--device', help='Serial number of the target device.')
  parser.add_argument('--gdb', help='Run gdb',
                      default=False, action='store_true')
  runner_args, args = parser.parse_known_args()

  config = Config(target_os=Config.OS_ANDROID,
                  target_cpu=runner_args.target_cpu,
                  is_debug=runner_args.debug,
                  apk_name="Mandoline.apk")
  shell = AndroidShell(config)
  shell.InitShell(None, runner_args.device)
  p = shell.ShowLogs()
  shell.StartActivity('MandolineActivity',
                      args,
                      sys.stdout,
                      p.terminate,
                      runner_args.gdb)
  return 0
Esempio n. 2
0
def main():
    logging.basicConfig()

    parser = argparse.ArgumentParser(usage=USAGE)

    debug_group = parser.add_mutually_exclusive_group()
    debug_group.add_argument('--debug',
                             help='Debug build (default)',
                             default=True,
                             action='store_true')
    debug_group.add_argument('--release',
                             help='Release build',
                             default=False,
                             dest='debug',
                             action='store_false')
    parser.add_argument('--build-dir', help='Build directory')
    parser.add_argument('--target-cpu',
                        help='CPU architecture to run for.',
                        choices=['x64', 'x86', 'arm'],
                        default='arm')
    parser.add_argument('--device', help='Serial number of the target device.')
    runner_args, args = parser.parse_known_args()

    config = Config(build_dir=runner_args.build_dir,
                    target_os=Config.OS_ANDROID,
                    target_cpu=runner_args.target_cpu,
                    is_debug=runner_args.debug,
                    apk_name='Mandoline.apk')
    shell = AndroidShell(config)
    shell.InitShell(runner_args.device)
    return 0
Esempio n. 3
0
def main():
    logging.basicConfig()

    parser = argparse.ArgumentParser(usage=USAGE)

    debug_group = parser.add_mutually_exclusive_group()
    debug_group.add_argument('--debug',
                             help='Debug build (default)',
                             default=True,
                             action='store_true')
    debug_group.add_argument('--release',
                             help='Release build',
                             default=False,
                             dest='debug',
                             action='store_false')
    parser.add_argument('--build-dir', help='Build directory')
    parser.add_argument('--target-cpu',
                        help='CPU architecture to run for.',
                        choices=['x64', 'x86', 'arm'],
                        default='arm')
    parser.add_argument('--device', help='Serial number of the target device.')
    parser.add_argument('--gdb',
                        help='Run gdb',
                        default=False,
                        action='store_true')
    runner_args, args = parser.parse_known_args()

    config = Config(build_dir=runner_args.build_dir,
                    target_os=Config.OS_ANDROID,
                    target_cpu=runner_args.target_cpu,
                    is_debug=runner_args.debug,
                    apk_name='Mandoline.apk')
    shell = AndroidShell(config)
    shell.InitShell(runner_args.device)
    p = shell.ShowLogs()

    temp_gdb_dir = None
    if runner_args.gdb:
        temp_gdb_dir = tempfile.mkdtemp()
        atexit.register(shutil.rmtree, temp_gdb_dir, True)
        _CreateSOLinks(temp_gdb_dir)

    shell.StartActivity('MandolineActivity', args, sys.stdout, p.terminate,
                        temp_gdb_dir)
    return 0
Esempio n. 4
0
def main():
    logging.basicConfig()

    parser = argparse.ArgumentParser(usage=USAGE)

    debug_group = parser.add_mutually_exclusive_group()
    debug_group.add_argument('--debug',
                             help='Debug build (default)',
                             default=True,
                             action='store_true')
    debug_group.add_argument('--release',
                             help='Release build',
                             default=False,
                             dest='debug',
                             action='store_false')
    parser.add_argument('--target-cpu',
                        help='CPU architecture to run for.',
                        choices=['x64', 'x86', 'arm'],
                        default='arm')
    parser.add_argument('--device', help='Serial number of the target device.')
    parser.add_argument('--verbose', default=False, action='store_true')
    parser.add_argument('--apk',
                        help='Name of the APK to run.',
                        default='MojoRunner.apk')
    runner_args, args = parser.parse_known_args()

    logger = logging.getLogger()
    logging.basicConfig(stream=sys.stdout, format='%(levelname)s:%(message)s')
    logger.setLevel(logging.DEBUG if runner_args.verbose else logging.WARNING)
    logger.debug('Initialized logging: level=%s' % logger.level)

    config = Config(target_os=Config.OS_ANDROID,
                    target_cpu=runner_args.target_cpu,
                    is_debug=runner_args.debug,
                    is_verbose=runner_args.verbose,
                    apk_name=runner_args.apk)
    shell = AndroidShell(config)
    shell.InitShell(runner_args.device)
    p = shell.ShowLogs()
    shell.StartActivity('MojoShellActivity', args, sys.stdout, p.terminate)
    return 0
Esempio n. 5
0
def main():
  logging.basicConfig()

  parser = argparse.ArgumentParser(usage=USAGE)

  debug_group = parser.add_mutually_exclusive_group()
  debug_group.add_argument('--debug', help='Debug build (default)',
                           default=True, action='store_true')
  debug_group.add_argument('--release', help='Release build', default=False,
                           dest='debug', action='store_false')
  parser.add_argument('--target-cpu', help='CPU architecture to run for.',
                      choices=['x64', 'x86', 'arm'])
  parser.add_argument('--origin', help='Origin for mojo: URLs.',
                      default='localhost')
  parser.add_argument('--target-device', help='Device to run on.')
  launcher_args, args = parser.parse_known_args()

  config = Config(target_os=Config.OS_ANDROID,
                  target_cpu=launcher_args.target_cpu,
                  is_debug=launcher_args.debug,
                  apk_name="MojoRunner.apk")
  paths = Paths(config)
  shell = AndroidShell(paths.target_mojo_shell_path, paths.build_dir,
                       paths.adb_path, launcher_args.target_device)

  extra_shell_args = shell.PrepareShellRun(launcher_args.origin)
  args.extend(extra_shell_args)

  shell.CleanLogs()
  p = shell.ShowLogs()
  shell.StartShell(args, sys.stdout, p.terminate)
  return 0
def main():
    parser = argparse.ArgumentParser(description="An application test runner.")
    parser.add_argument("build_dir",
                        type=str,
                        help="The build output directory.")
    parser.add_argument("--verbose",
                        default=False,
                        action='store_true',
                        help="Print additional logging information.")
    parser.add_argument('--repeat-count',
                        default=1,
                        metavar='INT',
                        action='store',
                        type=int,
                        help="The number of times to repeat the set of tests.")
    parser.add_argument(
        '--write-full-results-to',
        metavar='FILENAME',
        help='The path to write the JSON list of full results.')
    parser.add_argument("--test-list-file",
                        metavar='FILENAME',
                        type=file,
                        default=os.path.abspath(
                            os.path.join(__file__, os.pardir, "data",
                                         "apptests")),
                        help="The file listing apptests to run.")
    args = parser.parse_args()

    gtest.set_color()
    logger = logging.getLogger()
    logging.basicConfig(stream=sys.stdout, format="%(levelname)s:%(message)s")
    logger.setLevel(logging.DEBUG if args.verbose else logging.WARNING)
    logger.debug("Initialized logging: level=%s" % logger.level)

    logger.debug("Test list file: %s", args.test_list_file)
    config = Config(args.build_dir)
    execution_globals = {"config": config}
    exec args.test_list_file in execution_globals
    test_list = execution_globals["tests"]
    logger.debug("Test list: %s" % test_list)

    shell = None
    if config.target_os == Config.OS_ANDROID:
        from mopy.android import AndroidShell
        shell = AndroidShell(config)
        result = shell.InitShell()
        if result != 0:
            return result

    tests = []
    failed = []
    failed_suites = 0
    for _ in range(args.repeat_count):
        for test_dict in test_list:
            test = test_dict["test"]
            test_name = test_dict.get("name", test)
            test_type = test_dict.get("type", "gtest")
            test_args = test_dict.get("args", [])

            print "Running %s...%s" % (test_name,
                                       ("\n" if args.verbose else "")),
            sys.stdout.flush()

            assert test_type in ("gtest", "gtest_isolated")
            isolate = test_type == "gtest_isolated"
            (test, fail) = gtest.run_apptest(config, shell, test_args, test,
                                             isolate)
            tests.extend(test)
            failed.extend(fail)
            result = test and not fail
            print "[  PASSED  ]" if result else "[  FAILED  ]",
            print test_name if args.verbose or not result else ""
            # Abort when 3 apptest suites, or a tenth of all, have failed.
            # base::TestLauncher does this for timeouts and unknown results.
            failed_suites += 0 if result else 1
            if failed_suites >= max(3, len(test_list) / 10):
                print "Too many failing suites (%d), exiting now." % failed_suites
                failed.append("Test runner aborted for excessive failures.")
                break

        if failed:
            break

    print "[==========] %d tests ran." % len(tests)
    print "[  PASSED  ] %d tests." % (len(tests) - len(failed))
    if failed:
        print "[  FAILED  ] %d tests, listed below:" % len(failed)
        for failure in failed:
            print "[  FAILED  ] %s" % failure

    if args.write_full_results_to:
        _WriteJSONResults(tests, failed, args.write_full_results_to)

    return 1 if failed else 0
Esempio n. 7
0
def main():
    parser = argparse.ArgumentParser(description='An application test runner.')
    parser.add_argument('build_dir',
                        type=str,
                        help='The build output directory.')
    parser.add_argument('--verbose',
                        default=False,
                        action='store_true',
                        help='Print additional logging information.')
    parser.add_argument('--repeat-count',
                        default=1,
                        metavar='INT',
                        action='store',
                        type=int,
                        help='The number of times to repeat the set of tests.')
    parser.add_argument(
        '--write-full-results-to',
        metavar='FILENAME',
        help='The path to write the JSON list of full results.')
    parser.add_argument('--test-list-file',
                        metavar='FILENAME',
                        type=file,
                        default=APPTESTS,
                        help='The file listing tests to run.')
    parser.add_argument('--apptest-filter',
                        default='',
                        help='A comma-separated list of mojo:apptests to run.')
    args, commandline_args = parser.parse_known_args()

    logger = logging.getLogger()
    logging.basicConfig(stream=sys.stdout, format='%(levelname)s:%(message)s')
    logger.setLevel(logging.DEBUG if args.verbose else logging.WARNING)
    logger.debug('Initialized logging: level=%s' % logger.level)

    logger.debug('Test list file: %s', args.test_list_file)
    config = Config(args.build_dir,
                    is_verbose=args.verbose,
                    apk_name='MojoRunnerApptests.apk')
    execution_globals = {'config': config}
    exec args.test_list_file in execution_globals
    test_list = execution_globals['tests']
    logger.debug('Test list: %s' % test_list)

    shell = None
    if config.target_os == Config.OS_ANDROID:
        from mopy.android import AndroidShell
        shell = AndroidShell(config)
        result = shell.InitShell()
        if result != 0:
            return result

    tests = []
    failed = []
    failed_suites = 0
    apptest_filter = [a for a in string.split(args.apptest_filter, ',') if a]
    gtest_filter = [
        a for a in commandline_args if a.startswith('--gtest_filter')
    ]
    for _ in range(args.repeat_count):
        for test_dict in test_list:
            test = test_dict['test']
            test_name = test_dict.get('name', test)
            test_type = test_dict.get('type', 'gtest')
            test_args = test_dict.get('args', []) + commandline_args
            if apptest_filter and not set(apptest_filter) & set(
                [test, test_name]):
                continue

            print 'Running %s...%s' % (test_name,
                                       ('\n' if args.verbose else '')),
            sys.stdout.flush()

            assert test_type in ('gtest', 'gtest_isolated')
            if test_type == 'gtest':
                print(
                    'WARNING: tests are forced to gtest_isolated until '
                    'http://crbug.com/529487 is fixed')
                test_type = 'gtest_isolated'
            isolate = test_type == 'gtest_isolated'
            (ran, fail) = gtest.run_apptest(config, shell, test_args, test,
                                            isolate)
            # Ignore empty fixture lists when the commandline has a gtest filter flag.
            if gtest_filter and not ran and not fail:
                print '[ NO TESTS ] ' + (test_name if args.verbose else '')
                continue
            result = (not ran) or (ran and not fail)
            # Use the apptest name if the whole suite failed.
            fail = [test_name] if (not result and fail == [test]) else fail
            tests.extend(ran)
            failed.extend(fail)
            print '[  PASSED  ]' if result else '[  FAILED  ]',
            print test_name if args.verbose or not result else ''
            # Abort when 3 apptest suites, or a tenth of all, have failed.
            # base::TestLauncher does this for timeouts and unknown results.
            failed_suites += 0 if result else 1
            if failed_suites >= max(3, len(test_list) / 10):
                print 'Too many failing suites (%d), exiting now.' % failed_suites
                failed.append('Test runner aborted for excessive failures.')
                break

        if failed:
            break

    print '[==========] %d tests ran.' % len(tests)
    print '[  PASSED  ] %d tests.' % (len(tests) - len(failed))
    if failed:
        print '[  FAILED  ] %d tests, listed below:' % len(failed)
        for failure in failed:
            print '[  FAILED  ] %s' % failure

    if args.write_full_results_to:
        _WriteJSONResults(tests, failed, args.write_full_results_to)

    return 1 if failed else 0
Esempio n. 8
0
def main():
    parser = argparse.ArgumentParser(
        description="A test runner for application "
        "tests.")

    parser.add_argument("--verbose",
                        help="be verbose (multiple times for more)",
                        default=0,
                        dest="verbose_count",
                        action="count")
    parser.add_argument("test_list_file",
                        type=file,
                        help="a file listing apptests to run")
    parser.add_argument("build_dir",
                        type=str,
                        help="the build output directory")
    args = parser.parse_args()

    InitLogging(args.verbose_count)
    config = ConfigForGNArgs(ParseGNConfig(args.build_dir))

    _logger.debug("Test list file: %s", args.test_list_file)
    execution_globals = {"config": config}
    exec args.test_list_file in execution_globals
    test_list = execution_globals["tests"]
    _logger.debug("Test list: %s" % test_list)

    extra_args = []
    if config.target_os == Config.OS_ANDROID:
        paths = Paths(config)
        shell = AndroidShell(paths.target_mojo_shell_path, paths.build_dir,
                             paths.adb_path)
        extra_args.extend(shell.PrepareShellRun('localhost'))
    else:
        shell = None

    gtest.set_color()

    exit_code = 0
    for test_dict in test_list:
        test = test_dict["test"]
        test_name = test_dict.get("name", test)
        test_type = test_dict.get("type", "gtest")
        test_args = test_dict.get("test-args", [])
        shell_args = test_dict.get("shell-args", []) + extra_args

        _logger.info("Will start: %s" % test_name)
        print "Running %s...." % test_name,
        sys.stdout.flush()

        if test_type == "dart":
            apptest_result = dart_apptest.run_test(config, shell, test_dict,
                                                   shell_args,
                                                   {test: test_args})
        elif test_type == "gtest":
            apptest_result = gtest.run_fixtures(config, shell, test_dict, test,
                                                False, test_args, shell_args)
        elif test_type == "gtest_isolated":
            apptest_result = gtest.run_fixtures(config, shell, test_dict, test,
                                                True, test_args, shell_args)
        else:
            apptest_result = "Invalid test type in %r" % test_dict

        if apptest_result != "Succeeded":
            exit_code = 1
        print apptest_result
        _logger.info("Completed: %s" % test_name)

    return exit_code