def testDelayedRemoteDirs(self): """Tests the delayed creation of base_dir/work_dir.""" with remote_access.RemoteDeviceHandler('1.1.1.1', base_dir='/f') as device: # Make sure we didn't talk to the remote yet. self.assertEqual(self.rsh_mock.call_count, 0) # The work dir will get automatically created when we use it. self.rsh_mock.AddCmdResult(partial_mock.In('mktemp')) _ = device.work_dir self.assertEqual(self.rsh_mock.call_count, 1) # Add a mock for the clean up logic. self.rsh_mock.AddCmdResult(partial_mock.In('rm')) self.assertEqual(self.rsh_mock.call_count, 2)
def testMissingKernB(self): """Test the path where KERN-B fails to dump config""" self.keyset.keys['keyA_kernel_data_key'] = keys.KeyPair( 'keyA_kernel_data_key', self.keytempdir.tempdir) self.rc.AddCmdResult(partial_mock.InOrder( ['dump_kernel_config', '/dev/loop9999p2']), output=SAMPLE_KERNEL_CONFIG) self.rc.AddCmdResult(partial_mock.In('/dev/loop9999p4'), returncode=1) imagefile.UpdateRootfsHash(self.image, self.image.GetPartitionDevName('KERN-A'), self.keyset, 'keyA_') self.assertEqual(5, self.rc.call_count) expected_kernel_cmdline = kernel_cmdline.CommandLine( 'console= loglevel=7 init=/sbin/init cros_secure oops=panic panic=-1 ' 'root=/dev/dm-0 rootwait ro dm_verity.error_behavior=3 ' 'dm_verity.max_bios=-1 dm_verity.dev_wait=1 dm="1 vroot none ro 1,0 ' '800 verity alg=sha1" noinitrd cros_debug vt.global_cursor_default=0 ' 'kern_guid=%U add_efi_memmap boot=local noresume noswap ' 'i915.modeset=1 tpm_tis.force=1 tpm_tis.interrupts=0 ' 'nmi_watchdog=panic,lapic disablevmx=off') expected_calls = [ mock.call('/dev/loop9999p2', expected_kernel_cmdline, self.keyset.keys['keyA_kernel_data_key']), ] self.assertEqual(expected_calls, self.ukc.call_args_list)
def testUnmergeError(self): """Make sure random exit errors are not ignored""" self.rc.AddCmdResult(partial_mock.In('emerge'), returncode=123) with parallel_unittest.ParallelMock(): self.assertRaises(cros_build_lib.RunCommandError, cros_mark_as_stable.CleanStalePackages, '.', (), ['no/pkg'])
def testGSContextException(self): """GSContextException is raised properly.""" self.gs_mock.AddCmdResult( partial_mock.In('cp'), returncode=1, error=self.gs_mock.GSResponsePreconditionFailed) self.assertRaises(gs.GSContextException, self.Copy)
def testQemuVersion(self): """Verify that the correct QEMU version is identified.""" version_str = ('QEMU emulator version 2.8.0, Copyright (c) ' '2003-2008 Fabrice Bellard') self.rc.AddCmdResult(partial_mock.In('--version'), output=version_str) self._vm._SetQemuPath() self.assertEqual('2.8.0', self._vm.QemuVersion()) self.assertCommandContains([self._vm.qemu_path, '--version'])