def main(): parser = argparse.ArgumentParser( description='Launches a long-running emulator that can ' 'be re-used for multiple test runs.') AddLongRunningArgs(parser) FvdlTarget.RegisterArgs(parser) AemuTarget.RegisterArgs(parser) common_args.AddCommonArgs(parser) args = parser.parse_args() args.out_dir = None args.device = 'fvdl' args.cpu_cores = 4 common_args.ConfigureLogging(args) with ExitOnSigTerm(), \ common_args.GetDeploymentTargetForArgs(args) as fvdl_target: if fvdl_target._with_network: logging.info('If you haven\'t set up tuntap, you may be prompted ' 'for your sudo password to set up tuntap.') fvdl_target.Start() logging.info( 'Emulator successfully started. You can now run Chrome ' 'Fuchsia tests with "%s" to target this emulator.', fvdl_target.GetFfxTarget().format_runner_options()) logging.info('Type Ctrl-C in this terminal to shut down the emulator.') try: while fvdl_target._IsEmuStillRunning(): time.sleep(10) except KeyboardInterrupt: logging.info('Ctrl-C received; shutting down the emulator.') pass # Silently shut down the emulator except SystemExit: logging.info('SIGTERM received; shutting down the emulator.') pass # Silently shut down the emulator
def main(): parser = argparse.ArgumentParser( description='Launches a long-running emulator that can ' 'be re-used for multiple test runs.') AddLongRunningArgs(parser) FvdlTarget.RegisterArgs(parser) AemuTarget.RegisterArgs(parser) common_args.AddCommonArgs(parser) args = parser.parse_args() args.out_dir = None args.device = 'fvdl' args.cpu_cores = 4 common_args.ConfigureLogging(args) with common_args.GetDeploymentTargetForArgs(args) as fvdl_target: if fvdl_target._with_network: logging.info('If you haven\'t set up tuntap, you may be prompted ' 'for your sudo password to set up tuntap.') fvdl_target.Start() logging.info( 'Emulator successfully started up! If you are running ' 'multiple fuchsia devices, specify the port the ip address ' 'via the --host flag.') if fvdl_target._with_network: logging.info('You can now use the "-d" flag when running ' 'Chrome Fuchsia tests to target this emulator.') while fvdl_target._IsEmuStillRunning(): time.sleep(10) pass
def GetDeploymentTargetForArgs(args, require_kvm=False): """Constructs a deployment target object using parameters taken from command line arguments.""" if args.system_log_file == '-': system_log_file = sys.stdout elif args.system_log_file: system_log_file = open(args.system_log_file, 'w') else: system_log_file = None # Allow fuchsia to run on emulator if device not explicitly chosen. # AEMU is the default emulator for x64 Fuchsia, and QEMU for others. if not args.device: if args.target_cpu == 'x64': args.device = 'aemu' else: args.device = 'qemu' target_args = { 'output_dir': args.output_directory, 'target_cpu': args.target_cpu, 'system_log_file': system_log_file } if args.device == 'device': target_args.update({ 'host': args.host, 'node_name': args.node_name, 'port': args.port, 'ssh_config': args.ssh_config, 'fuchsia_out_dir': args.fuchsia_out_dir, 'os_check': args.os_check }) return DeviceTarget(**target_args) else: target_args.update({ 'cpu_cores': args.qemu_cpu_cores, 'require_kvm': not args.no_kvm, 'emu_type': args.device, 'ram_size_mb': args.memory }) if args.device == 'qemu': return QemuTarget(**target_args) else: target_args.update({ 'enable_graphics': args.enable_graphics, 'hardware_gpu': args.hardware_gpu }) return AemuTarget(**target_args)