コード例 #1
0
 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)
コード例 #2
0
ファイル: start_emulator.py プロジェクト: yue/build-gn
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
コード例 #3
0
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
コード例 #4
0
ファイル: fvdl_target_test.py プロジェクト: ekmixon/chromium
 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())
コード例 #5
0
ファイル: fvdl_target_test.py プロジェクト: ekmixon/chromium
 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())
コード例 #6
0
ファイル: fvdl_target_test.py プロジェクト: ekmixon/chromium
 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())
コード例 #7
0
ファイル: fvdl_target_test.py プロジェクト: ekmixon/chromium
 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())
コード例 #8
0
 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())
コード例 #9
0
ファイル: fvdl_target_test.py プロジェクト: ekmixon/chromium
 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)
コード例 #10
0
 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)
コード例 #11
0
ファイル: fvdl_target_test.py プロジェクト: ekmixon/chromium
 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)
コード例 #12
0
 def testBuildCommandCheckIfWithNetworkSetTunTap(self):
     self.args.with_network = True
     with FvdlTarget.CreateFromArgs(self.args) as target:
         self.assertIn('-N', target._BuildCommand())
コード例 #13
0
 def testBuildCommandCheckIfHardwareGpuSetHostGPU(self):
     self.args.hardware_gpu = True
     with FvdlTarget.CreateFromArgs(self.args) as target:
         self.assertIn('--host-gpu', target._BuildCommand())
コード例 #14
0
ファイル: fvdl_target_test.py プロジェクト: yue/build-gn
 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()
コード例 #15
0
ファイル: fvdl_target_test.py プロジェクト: yue/build-gn
 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()
コード例 #16
0
ファイル: fvdl_target_test.py プロジェクト: yue/build-gn
 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()
コード例 #17
0
 def testBuildCommandCheckIfNotRequireKVMSetNoAcceleration(self):
     self.args.require_kvm = False
     with FvdlTarget.CreateFromArgs(self.args) as target:
         self.assertIn('--noacceleration', target._BuildCommand())
コード例 #18
0
ファイル: fvdl_target_test.py プロジェクト: yue/build-gn
 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()
コード例 #19
0
 def testBuildCommandCheckIfNotEnableGraphicsSetHeadless(self):
     self.args.enable_graphics = True
     with FvdlTarget.CreateFromArgs(self.args) as target:
         self.assertNotIn('--headless', target._BuildCommand())