def testBuildCommandCheckEmulatorLogSetup(self): with tempfile.TemporaryDirectory() as logs_dir: self.args.logs_dir = logs_dir with FvdlTarget.CreateFromArgs(self.args) as target: build_command = target._BuildCommand() self.assertIn('--emulator-log', build_command) self.assertIn('--envs', build_command)
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 testBuildCommandCheckIfNotRequireKVMSetNoAcceleration(self): self.args.require_kvm = False with FvdlTarget.CreateFromArgs(self.args) as target: target.Shutdown = mock.MagicMock() common.EnsurePathExists = mock.MagicMock(return_value='image') with mock.patch.object(boot_data, 'ProvisionSSH') as provision_mock: self.assertIn('--noacceleration', target._BuildCommand())
def testBuildCommandCheckIfWithNetworkSetTunTap(self): self.args.with_network = True with FvdlTarget.CreateFromArgs(self.args) as target: target.Shutdown = mock.MagicMock() common.EnsurePathExists = mock.MagicMock(return_value='image') with mock.patch.object(boot_data, 'ProvisionSSH') as provision_mock: self.assertIn('-N', target._BuildCommand())
def testBuildCommandCheckIfHardwareGpuSetHostGPU(self): self.args.hardware_gpu = True with FvdlTarget.CreateFromArgs(self.args) as target: target.Shutdown = mock.MagicMock() common.EnsurePathExists = mock.MagicMock(return_value='image') with mock.patch.object(boot_data, 'ProvisionSSH') as provision_mock: self.assertIn('--host-gpu', target._BuildCommand())
def testBuildCommandCheckIfNotEnableGraphicsSetHeadless(self): self.args.enable_graphics = True with FvdlTarget.CreateFromArgs(self.args) as target: target.Shutdown = mock.MagicMock() common.EnsurePathExists = mock.MagicMock(return_value='image') with mock.patch.object(boot_data, 'ProvisionSSH') as provision_mock: self.assertNotIn('--headless', target._BuildCommand())
def testBuildCommandCheckRamSizeNot8192SetRamSize(self): custom_ram_size = 4096 self.args.ram_size_mb = custom_ram_size with FvdlTarget.CreateFromArgs(self.args) as target: self.assertIn('--device-proto', target._BuildCommand()) self.assertTrue(os.path.exists(target._device_proto_file.name)) correct_ram_amount = False with open(target._device_proto_file.name, 'r') as f: self.assertTrue( ' ram: {}\n'.format(custom_ram_size) in f.readlines())
def testBuildCommandCheckRamSizeNot8192SetRamSize(self): self.args.ram_size_mb = 4096 with FvdlTarget.CreateFromArgs(self.args) as target: target.Shutdown = mock.MagicMock() common.EnsurePathExists = mock.MagicMock(return_value='image') with mock.patch.object(boot_data, 'ProvisionSSH') as provision_mock: self.assertIn('--device-proto', target._BuildCommand()) self.assertTrue(os.path.exists(target._device_proto_file.name)) correct_ram_amount = False with open(target._device_proto_file.name) as file: for line in file: if line.strip() == 'ram: 4096': correct_ram_amount = True break self.assertTrue(correct_ram_amount)
def testBasicEmuCommand(self): with FvdlTarget.CreateFromArgs(self.args) as target: build_command = target._BuildCommand() self.assertIn(target._FVDL_PATH, build_command) self.assertIn('--sdk', build_command) self.assertIn('start', build_command) self.assertNotIn('--noacceleration', build_command) self.assertIn('--headless', build_command) self.assertNotIn('--host-gpu', build_command) self.assertNotIn('-N', build_command) self.assertIn('--device-proto', build_command) self.assertNotIn('--emulator-log', build_command) self.assertNotIn('--envs', build_command) self.assertTrue(os.path.exists(target._device_proto_file.name)) correct_ram_amount = False with open(target._device_proto_file.name) as file: for line in file: if line.strip() == 'ram: 8192': correct_ram_amount = True break self.assertTrue(correct_ram_amount)
def testBasicEmuCommand(self): with FvdlTarget.CreateFromArgs(self.args) as target: target.Shutdown = mock.MagicMock() common.EnsurePathExists = mock.MagicMock(return_value='image') with mock.patch.object(boot_data, 'ProvisionSSH') as provision_mock: build_command = target._BuildCommand() self.assertIn(target._FVDL_PATH, build_command) self.assertIn('--sdk', build_command) self.assertIn('start', build_command) self.assertNotIn('--noacceleration', target._BuildCommand()) self.assertIn('--headless', target._BuildCommand()) self.assertNotIn('--host-gpu', target._BuildCommand()) self.assertNotIn('-N', target._BuildCommand()) self.assertIn('--device-proto', target._BuildCommand()) self.assertTrue(os.path.exists(target._device_proto_file.name)) correct_ram_amount = False with open(target._device_proto_file.name) as file: for line in file: if line.strip() == 'ram: 8192': correct_ram_amount = True break self.assertTrue(correct_ram_amount)
def testBuildCommandCheckIfWithNetworkSetTunTap(self): self.args.with_network = True with FvdlTarget.CreateFromArgs(self.args) as target: self.assertIn('-N', target._BuildCommand())
def testBuildCommandCheckIfHardwareGpuSetHostGPU(self): self.args.hardware_gpu = True with FvdlTarget.CreateFromArgs(self.args) as target: self.assertIn('--host-gpu', target._BuildCommand())
def testBuildCommandCheckIfHardwareGpuSetHostGPU(self, mock_daemon_stop): self.args.hardware_gpu = True with FvdlTarget.CreateFromArgs(self.args) as target: self.assertIn('--host-gpu', target._BuildCommand()) mock_daemon_stop.assert_called_once()
def testBuildCommandCheckIfNotRequireKVMSetNoAcceleration( self, mock_daemon_stop): self.args.require_kvm = False with FvdlTarget.CreateFromArgs(self.args) as target: self.assertIn('--noacceleration', target._BuildCommand()) mock_daemon_stop.assert_called_once()
def testBuildCommandCheckIfNotEnableGraphicsSetHeadless( self, mock_daemon_stop): self.args.enable_graphics = True with FvdlTarget.CreateFromArgs(self.args) as target: self.assertNotIn('--headless', target._BuildCommand()) mock_daemon_stop.assert_called_once()
def testBuildCommandCheckIfNotRequireKVMSetNoAcceleration(self): self.args.require_kvm = False with FvdlTarget.CreateFromArgs(self.args) as target: self.assertIn('--noacceleration', target._BuildCommand())
def testBuildCommandCheckIfWithNetworkSetTunTap(self, mock_daemon_stop): self.args.with_network = True with FvdlTarget.CreateFromArgs(self.args) as target: self.assertIn('-N', target._BuildCommand()) mock_daemon_stop.assert_called_once()
def testBuildCommandCheckIfNotEnableGraphicsSetHeadless(self): self.args.enable_graphics = True with FvdlTarget.CreateFromArgs(self.args) as target: self.assertNotIn('--headless', target._BuildCommand())