diff options
author | Doug Zongker <dougz@google.com> | 2014-06-13 10:38:32 -0700 |
---|---|---|
committer | Doug Zongker <dougz@google.com> | 2014-06-13 10:38:32 -0700 |
commit | 1113e38195da957301e3077151a90c113c86289a (patch) | |
tree | f5efbdb18de4386725d73b9fab5feb16c3fefa6f /tools/releasetools/ota_from_target_files | |
parent | fd40d060d9b465629b9310ee7fd0aa3763b6c834 (diff) | |
download | build-1113e38195da957301e3077151a90c113c86289a.zip build-1113e38195da957301e3077151a90c113c86289a.tar.gz build-1113e38195da957301e3077151a90c113c86289a.tar.bz2 |
test block patch more realistically
Read and write the same file when testing block patches, which can
turn up errors that don't show up otherwise. (And will appear on the
device.)
Change-Id: Ic9b8d93ec980d13163b135f619af589f41433d7f
Diffstat (limited to 'tools/releasetools/ota_from_target_files')
-rwxr-xr-x | tools/releasetools/ota_from_target_files | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files index 9c10b68..87de2f6 100755 --- a/tools/releasetools/ota_from_target_files +++ b/tools/releasetools/ota_from_target_files @@ -837,7 +837,6 @@ def TestBlockPatch(src_muimg, src_map, patch_data, tgt_map, tgt_sha1): with tempfile.NamedTemporaryFile() as src_file,\ tempfile.NamedTemporaryFile() as patch_file,\ - tempfile.NamedTemporaryFile() as tgt_file,\ tempfile.NamedTemporaryFile() as src_map_file,\ tempfile.NamedTemporaryFile() as tgt_map_file: @@ -853,20 +852,16 @@ def TestBlockPatch(src_muimg, src_map, patch_data, tgt_map, tgt_sha1): patch_file.write(patch_data) - tgt_total = sum(tgt_regions) * tgt_blksize - tgt_file.truncate(tgt_total) - src_map_file.write(src_map) tgt_map_file.write(tgt_map) src_file.flush() src_map_file.flush() patch_file.flush() - tgt_file.flush() tgt_map_file.flush() p = common.Run(["syspatch_host", src_file.name, src_map_file.name, - patch_file.name, tgt_file.name, tgt_map_file.name], + patch_file.name, src_file.name, tgt_map_file.name], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) stdoutdata, _ = p.communicate() if p.returncode != 0: @@ -874,10 +869,11 @@ def TestBlockPatch(src_muimg, src_map, patch_data, tgt_map, tgt_sha1): raise ValueError("failed to reconstruct target system image from patch") h = sha1() + src_file.seek(0, 0) for i in range(0, len(tgt_regions), 2): c, dc = tgt_regions[i:i+2] - h.update(tgt_file.read(c*tgt_blksize)) - tgt_file.seek(dc*tgt_blksize, 1) + h.update(src_file.read(c*tgt_blksize)) + src_file.seek(dc*tgt_blksize, 1) if h.hexdigest() != tgt_sha1: raise ValueError("patch reconstructed incorrect target system image") |