def __init__(self, payload, cache, work_dir, sign, verify, au_generator_uri_override, dry_run=False): """Init for _PaygenPayload. Args: payload: An instance of gspaths.Payload describing the payload to generate. cache: An instance of DownloadCache for retrieving files. work_dir: A working directory for output files. Can NOT be shared. sign: Boolean saying if the payload should be signed (normally, you do). verify: whether the payload should be verified after being generated au_generator_uri_override: URI to override standard au_generator.zip rules. dry_run: do not do any actual work """ self.payload = payload self.cache = cache self.work_dir = work_dir self._verify = verify self._au_generator_uri_override = au_generator_uri_override self._drm = dryrun_lib.DryRunMgr(dry_run) self.generator_dir = os.path.join(work_dir, 'au-generator') self.src_image_file = os.path.join(work_dir, 'src_image.bin') self.tgt_image_file = os.path.join(work_dir, 'tgt_image.bin') self.payload_file = os.path.join(work_dir, 'delta.bin') self.log_file = os.path.join(work_dir, 'delta.log') self.description_file = os.path.join(work_dir, 'delta.json') self.metadata_size_file = os.path.join(work_dir, 'metadata_size.txt') self.metadata_size = 0 self.signer = None # Names to pass to cros_generate_update_payload for extracting old/new # kernel/rootfs partitions. self.partition_names = (self._KERNEL, self._ROOTFS) self.tgt_partitions = {} self.src_partitions = {} for part_name in self.partition_names: self.tgt_partitions[part_name] = os.path.join( self.work_dir, 'new_' + part_name + '.dat') self.src_partitions[part_name] = os.path.join( self.work_dir, 'old_' + part_name + '.dat') if sign: self.signed_payload_file = self.payload_file + '.signed' self.metadata_signature_file = self._MetadataUri( self.signed_payload_file) self.signer = signer_payloads_client.SignerPayloadsClientGoogleStorage( payload.tgt_image.channel, payload.tgt_image.board, payload.tgt_image.version, payload.tgt_image.bucket)
def testSkip(self): self.mox.StubOutWithMock(FuncClass, 'Func') drm = dryrun_lib.DryRunMgr(True) # Set up the test replay script. self.mox.ReplayAll() # Run the test verification. drm._Skip(FuncClass.Func, 'arg1', 'arg2', keya='arga') self.mox.VerifyAll()
def __init__(self, payload, cache, work_dir, sign, verify, au_generator_uri_override, dry_run=False): """Init for _PaygenPayload. Args: payload: An instance of gspaths.Payload describing the payload to generate. cache: An instance of DownloadCache for retrieving files. work_dir: A working directory for output files. Can NOT be shared. sign: Boolean saying if the payload should be signed (normally, you do). verify: whether the payload should be verified after being generated au_generator_uri_override: URI to override standard au_generator.zip rules. dry_run: do not do any actual work """ self.payload = payload self.cache = cache self.work_dir = work_dir self._verify = verify self._au_generator_uri_override = au_generator_uri_override self._drm = dryrun_lib.DryRunMgr(dry_run) self.generator_dir = os.path.join(work_dir, 'au-generator') self.src_image_file = os.path.join(work_dir, 'src_image.bin') self.tgt_image_file = os.path.join(work_dir, 'tgt_image.bin') self.payload_file = os.path.join(work_dir, 'delta.bin') self.delta_log_file = os.path.join(work_dir, 'delta.log') self.description_file = os.path.join(work_dir, 'delta.json') self.signer = None # If we are a bootstrap environment, this import will fail, so don't # perform it until we need it. from dev.host.lib import update_payload self._update_payload = update_payload if sign: self.signed_payload_file = self.payload_file + '.signed' self.metadata_signature_file = self._MetadataUri( self.signed_payload_file) self.signer = signer_payloads_client.SignerPayloadsClientGoogleStorage( payload.tgt_image.channel, payload.tgt_image.board, payload.tgt_image.version, payload.tgt_image.bucket)
def __init__(self, build, work_dir, site_config, dry_run=False, skip_delta_payloads=False, skip_duts_check=False): """Initializer.""" self._build = build self._work_dir = work_dir self._site_config = site_config self._drm = dryrun_lib.DryRunMgr(dry_run) self._skip_delta_payloads = skip_delta_payloads self._archive_board = None self._archive_build = None self._archive_build_uri = None self._skip_duts_check = skip_duts_check
def testNonzero(self): self.assertTrue(dryrun_lib.DryRunMgr(True)) self.assertFalse(dryrun_lib.DryRunMgr(False))