예제 #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
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
 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
 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
 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
 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
 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
 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
 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
 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
 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
 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())