Esempio n. 1
0
def main():
    SetupDefaultLoggingConfig()
    parser = command_line.CreateParser()
    parser.add_argument("-t",
                        "--target_name",
                        required=True,
                        help="Name of executable target.")
    args = parser.parse_args()

    target_params = []
    if args.target_params:
        target_params = args.target_params.split(" ")

    launcher = abstract_launcher.LauncherFactory(
        args.platform,
        args.target_name,
        args.config,
        device_id=args.device_id,
        target_params=target_params,
        out_directory=args.out_directory)

    def Abort(signum, frame):
        del signum, frame  # Unused.
        sys.stderr.write("Killing thread\n")
        launcher.Kill()
        sys.exit(1)

    signal.signal(signal.SIGINT, Abort)

    return launcher.Run()
Esempio n. 2
0
def GetDeviceParamsFromCommandLine():
    """Provide a commanline parser for all CobaltRunner inputs."""

    arg_parser = command_line.CreateParser()

    args, _ = arg_parser.parse_known_args()

    device_params = CobaltRunner.DeviceParams()
    device_params.platform = args.platform
    device_params.config = args.config
    device_params.device_id = args.device_id
    device_params.out_directory = args.out_directory
    if args.target_params == None:
        device_params.target_params = []
    else:
        device_params.target_params = [args.target_params]

    return device_params
Esempio n. 3
0
 def testDefaultsRainyDayBadConfig(self):
     _SetEnviron('badconfig', _A_PLATFORM)
     parser = command_line.CreateParser()
     with self.assertRaises(SystemExit):
         parser.parse_args([])
Esempio n. 4
0
 def testDefaultsSunnyDay(self):
     _SetEnviron(_A_CONFIG, _A_PLATFORM)
     parser = command_line.CreateParser()
     args = parser.parse_args([])
     self.assertEqual(_A_CONFIG, args.config)
     self.assertEqual(_A_PLATFORM, args.platform)
Esempio n. 5
0
 def testNoEnvironmentSunnyDay(self):
     parser = command_line.CreateParser()
     args = parser.parse_args(['-c', _A_CONFIG, '-p', _A_PLATFORM])
     self.assertEqual(_A_CONFIG, args.config)
     self.assertEqual(_A_PLATFORM, args.platform)
Esempio n. 6
0
 def testNoEnvironmentRainyDayNoPlatform(self):
     parser = command_line.CreateParser()
     with self.assertRaises(SystemExit):
         parser.parse_args(['-c', _A_CONFIG])
Esempio n. 7
0
 def testNoEnvironmentRainyDayNoConfig(self):
     parser = command_line.CreateParser()
     with self.assertRaises(SystemExit):
         parser.parse_args(['-p', _A_PLATFORM])
Esempio n. 8
0
 def testNoEnvironmentRainyDayNoArgs(self):
     parser = command_line.CreateParser()
     with self.assertRaises(SystemExit):
         parser.parse_args([])
Esempio n. 9
0
 def testInconsistentEnvironmentSunnyDay(self):
     _SetEnvironBuildConfiguration(_A_CONFIG, _A_PLATFORM)
     parser = command_line.CreateParser()
     args = parser.parse_args([])
     self.assertEqual(_A_CONFIG, args.config)
     self.assertEqual(_A_PLATFORM, args.platform)
Esempio n. 10
0
 def testDefaultsRainyDayBadPlatform(self):
     _SetEnviron(_A_CONFIG, 'badplatform')
     parser = command_line.CreateParser()
     with self.assertRaises(SystemExit):
         parser.parse_args([])
def main():
  SetupDefaultLoggingConfig()
  arg_parser = command_line.CreateParser()
  arg_parser.add_argument(
      "-b",
      "--build",
      action="store_true",
      help="Specifies whether to build the tests.")
  arg_parser.add_argument(
      "-r",
      "--run",
      action="store_true",
      help="Specifies whether to run the tests."
      " If both the \"--build\" and \"--run\" flags are not"
      " provided, this is the default.")
  arg_parser.add_argument(
      "-n",
      "--dry_run",
      action="store_true",
      help="Specifies to show what would be done without actually doing it.")
  arg_parser.add_argument(
      "-t",
      "--target_name",
      action="append",
      help="Name of executable target. Repeatable for multiple targets.")
  arg_parser.add_argument(
      "--platform_tests_only",
      action="store_true",
      help="Runs only a small set of tests involved testing the platform.")
  arg_parser.add_argument(
      "-a",
      "--application_name",
      default="cobalt",  # TODO: Pass this in explicitly.
      help="Name of the application to run tests under, e.g. 'cobalt'.")
  arg_parser.add_argument(
      "--ninja_flags",
      help="Flags to pass to the ninja build system. Provide them exactly"
      " as you would on the command line between a set of double quotation"
      " marks.")
  arg_parser.add_argument(
      "-x",
      "--xml_output_dir",
      help="If defined, results will be saved as xml files in given directory."
      " Output for each test suite will be in it's own subdirectory and file:"
      " <xml_output_dir>/<test_suite_name>/sponge_log.xml")
  arg_parser.add_argument(
      "-l",
      "--log_xml_results",
      action="store_true",
      help="If set, results will be logged in xml format after all tests are"
      " complete. --xml_output_dir will be ignored.")
  args = arg_parser.parse_args()

  # Extra arguments for the test target
  target_params = []
  if args.target_params:
    target_params = args.target_params.split(" ")

  runner = TestRunner(args.platform, args.config, args.device_id,
                      args.target_name, target_params, args.out_directory,
                      args.platform_tests_only, args.application_name,
                      args.dry_run, args.xml_output_dir, args.log_xml_results)

  def Abort(signum, frame):
    del signum, frame  # Unused.
    sys.stderr.write("Killing threads\n")
    for active_thread in runner.threads:
      active_thread.Kill()
    sys.exit(1)

  signal.signal(signal.SIGINT, Abort)
  # If neither build nor run has been specified, assume the client
  # just wants to run.
  if not args.build and not args.run:
    args.run = True

  build_success = True
  run_success = True

  if args.dry_run:
    sys.stderr.write("=== Dry run ===\n")

  if args.build:
    build_success = runner.BuildAllTests(args.ninja_flags)
    # If the build fails, don't try to run the tests.
    if not build_success:
      return 1

  if args.run:
    run_success = runner.RunAllTests()

  # If either step has failed, count the whole test run as failed.
  if not build_success or not run_success:
    return 1
  else:
    return 0