diff options
author | Tao Bao | 2018-11-26 12:41:36 -0600 |
---|---|---|
committer | Gerrit Code Review | 2018-11-26 12:41:36 -0600 |
commit | f21a8f5376f18faf3654fe88266de37496853775 (patch) | |
tree | 1e0bddf974f923f3160206a62fe0e76592f0e30d /tools/releasetools | |
parent | 5d218a123f01aa47528fc05306b32dbae65ee50b (diff) | |
parent | 2764aee66429c6b197148120fbb2a6a7de5408db (diff) | |
download | platform-build-f21a8f5376f18faf3654fe88266de37496853775.tar.gz platform-build-f21a8f5376f18faf3654fe88266de37496853775.tar.xz platform-build-f21a8f5376f18faf3654fe88266de37496853775.zip |
Merge "Use common.RunAndCheckOutput() in add_img_to_target_files.py."
Diffstat (limited to 'tools/releasetools')
-rwxr-xr-x | tools/releasetools/add_img_to_target_files.py | 37 | ||||
-rw-r--r-- | tools/releasetools/test_add_img_to_target_files.py | 6 |
2 files changed, 9 insertions, 34 deletions
diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py index b0dd0f8de..2d91b60a1 100755 --- a/tools/releasetools/add_img_to_target_files.py +++ b/tools/releasetools/add_img_to_target_files.py | |||
@@ -260,11 +260,7 @@ def AddDtbo(output_zip): | |||
260 | args = OPTIONS.info_dict.get("avb_dtbo_add_hash_footer_args") | 260 | args = OPTIONS.info_dict.get("avb_dtbo_add_hash_footer_args") |
261 | if args and args.strip(): | 261 | if args and args.strip(): |
262 | cmd.extend(shlex.split(args)) | 262 | cmd.extend(shlex.split(args)) |
263 | proc = common.Run(cmd) | 263 | common.RunAndCheckOutput(cmd) |
264 | output, _ = proc.communicate() | ||
265 | assert proc.returncode == 0, \ | ||
266 | "Failed to call 'avbtool add_hash_footer' for {}:\n{}".format( | ||
267 | img.name, output) | ||
268 | 264 | ||
269 | img.Write() | 265 | img.Write() |
270 | return img.name | 266 | return img.name |
@@ -331,8 +327,8 @@ def CreateImage(input_dir, info_dict, what, output_file, block_list=None): | |||
331 | info_dict[image_blocks_key] = int(image_size) / 4096 - 1 | 327 | info_dict[image_blocks_key] = int(image_size) / 4096 - 1 |
332 | 328 | ||
333 | use_dynamic_size = ( | 329 | use_dynamic_size = ( |
334 | info_dict.get("use_dynamic_partition_size") == "true" and | 330 | info_dict.get("use_dynamic_partition_size") == "true" and |
335 | what in shlex.split(info_dict.get("dynamic_partition_list", "").strip())) | 331 | what in shlex.split(info_dict.get("dynamic_partition_list", "").strip())) |
336 | if use_dynamic_size: | 332 | if use_dynamic_size: |
337 | info_dict.update(build_image.GlobalDictFromImageProp(image_props, what)) | 333 | info_dict.update(build_image.GlobalDictFromImageProp(image_props, what)) |
338 | 334 | ||
@@ -463,10 +459,7 @@ def AddVBMeta(output_zip, partitions, name, needed_partitions): | |||
463 | assert found, 'Failed to find {}'.format(image_path) | 459 | assert found, 'Failed to find {}'.format(image_path) |
464 | cmd.extend(split_args) | 460 | cmd.extend(split_args) |
465 | 461 | ||
466 | proc = common.Run(cmd) | 462 | common.RunAndCheckOutput(cmd) |
467 | stdoutdata, _ = proc.communicate() | ||
468 | assert proc.returncode == 0, \ | ||
469 | "avbtool make_vbmeta_image failed:\n{}".format(stdoutdata) | ||
470 | img.Write() | 463 | img.Write() |
471 | return img.name | 464 | return img.name |
472 | 465 | ||
@@ -493,11 +486,7 @@ def AddPartitionTable(output_zip): | |||
493 | args = OPTIONS.info_dict.get("board_bpt_make_table_args") | 486 | args = OPTIONS.info_dict.get("board_bpt_make_table_args") |
494 | if args: | 487 | if args: |
495 | cmd.extend(shlex.split(args)) | 488 | cmd.extend(shlex.split(args)) |
496 | 489 | common.RunAndCheckOutput(cmd) | |
497 | proc = common.Run(cmd) | ||
498 | stdoutdata, _ = proc.communicate() | ||
499 | assert proc.returncode == 0, \ | ||
500 | "bpttool make_table failed:\n{}".format(stdoutdata) | ||
501 | 490 | ||
502 | img.Write() | 491 | img.Write() |
503 | bpt.Write() | 492 | bpt.Write() |
@@ -612,10 +601,7 @@ def AddCareMapForAbOta(output_zip, ab_partitions, image_paths): | |||
612 | 601 | ||
613 | temp_care_map = common.MakeTempFile(prefix="caremap-", suffix=".pb") | 602 | temp_care_map = common.MakeTempFile(prefix="caremap-", suffix=".pb") |
614 | care_map_gen_cmd = ["care_map_generator", temp_care_map_text, temp_care_map] | 603 | care_map_gen_cmd = ["care_map_generator", temp_care_map_text, temp_care_map] |
615 | proc = common.Run(care_map_gen_cmd) | 604 | common.RunAndCheckOutput(care_map_gen_cmd) |
616 | output, _ = proc.communicate() | ||
617 | assert proc.returncode == 0, \ | ||
618 | "Failed to generate the care_map proto message:\n{}".format(output) | ||
619 | 605 | ||
620 | care_map_path = "META/care_map.pb" | 606 | care_map_path = "META/care_map.pb" |
621 | if output_zip and care_map_path not in output_zip.namelist(): | 607 | if output_zip and care_map_path not in output_zip.namelist(): |
@@ -665,11 +651,7 @@ def AddSuperEmpty(output_zip): | |||
665 | cmd = [OPTIONS.info_dict['lpmake']] | 651 | cmd = [OPTIONS.info_dict['lpmake']] |
666 | cmd += shlex.split(OPTIONS.info_dict['lpmake_args'].strip()) | 652 | cmd += shlex.split(OPTIONS.info_dict['lpmake_args'].strip()) |
667 | cmd += ['--output', img.name] | 653 | cmd += ['--output', img.name] |
668 | 654 | common.RunAndCheckOutput(cmd) | |
669 | proc = common.Run(cmd) | ||
670 | stdoutdata, _ = proc.communicate() | ||
671 | assert proc.returncode == 0, \ | ||
672 | "lpmake tool failed:\n{}".format(stdoutdata) | ||
673 | 655 | ||
674 | img.Write() | 656 | img.Write() |
675 | 657 | ||
@@ -715,10 +697,7 @@ def AddSuperSplit(output_zip): | |||
715 | 697 | ||
716 | cmd += ['--output', outdir.name] | 698 | cmd += ['--output', outdir.name] |
717 | 699 | ||
718 | proc = common.Run(cmd) | 700 | common.RunAndCheckOutput(cmd) |
719 | stdoutdata, _ = proc.communicate() | ||
720 | assert proc.returncode == 0, \ | ||
721 | "lpmake tool failed:\n{}".format(stdoutdata) | ||
722 | 701 | ||
723 | for dev in OPTIONS.info_dict['super_block_devices'].strip().split(): | 702 | for dev in OPTIONS.info_dict['super_block_devices'].strip().split(): |
724 | img = OutputFile(output_zip, OPTIONS.input_tmp, "OTA", | 703 | img = OutputFile(output_zip, OPTIONS.input_tmp, "OTA", |
diff --git a/tools/releasetools/test_add_img_to_target_files.py b/tools/releasetools/test_add_img_to_target_files.py index ad22b7252..d2a274d34 100644 --- a/tools/releasetools/test_add_img_to_target_files.py +++ b/tools/releasetools/test_add_img_to_target_files.py | |||
@@ -40,11 +40,7 @@ class AddImagesToTargetFilesTest(test_utils.ReleaseToolsTestCase): | |||
40 | 40 | ||
41 | # Calls an external binary to convert the proto message. | 41 | # Calls an external binary to convert the proto message. |
42 | cmd = ["care_map_generator", "--parse_proto", file_name, text_file] | 42 | cmd = ["care_map_generator", "--parse_proto", file_name, text_file] |
43 | proc = common.Run(cmd) | 43 | common.RunAndCheckOutput(cmd) |
44 | output, _ = proc.communicate() | ||
45 | self.assertEqual( | ||
46 | 0, proc.returncode, | ||
47 | "Failed to run care_map_generator:\n{}".format(output)) | ||
48 | 44 | ||
49 | with open(text_file, 'r') as verify_fp: | 45 | with open(text_file, 'r') as verify_fp: |
50 | plain_text = verify_fp.read() | 46 | plain_text = verify_fp.read() |