Merge "releasetools: Skip on empty care_map."
This commit is contained in:
commit
65e41c4236
2 changed files with 36 additions and 3 deletions
|
@ -113,7 +113,7 @@ def GetCareMap(which, imgname):
|
|||
|
||||
Returns:
|
||||
(which, care_map_ranges): care_map_ranges is the raw string of the care_map
|
||||
RangeSet; or an empty list.
|
||||
RangeSet; or None.
|
||||
"""
|
||||
assert which in common.PARTITIONS_WITH_CARE_MAP
|
||||
|
||||
|
@ -123,7 +123,7 @@ def GetCareMap(which, imgname):
|
|||
# invalid reads.
|
||||
image_size = OPTIONS.info_dict.get(which + "_image_size")
|
||||
if not image_size:
|
||||
return []
|
||||
return None
|
||||
|
||||
image_blocks = int(image_size) / 4096 - 1
|
||||
assert image_blocks > 0, "blocks for {} must be positive".format(which)
|
||||
|
@ -592,7 +592,11 @@ def AddCareMapForAbOta(output_zip, ab_partitions, image_paths):
|
|||
OPTIONS.info_dict.get(avb_hashtree_enable) == "true"):
|
||||
image_path = image_paths[partition]
|
||||
assert os.path.exists(image_path)
|
||||
care_map_list += GetCareMap(partition, image_path)
|
||||
|
||||
care_map = GetCareMap(partition, image_path)
|
||||
if not care_map:
|
||||
continue
|
||||
care_map_list += care_map
|
||||
|
||||
# adds fingerprint field to the care_map
|
||||
build_props = OPTIONS.info_dict.get(partition + ".build.prop", {})
|
||||
|
|
|
@ -283,6 +283,35 @@ class AddImagesToTargetFilesTest(test_utils.ReleaseToolsTestCase):
|
|||
|
||||
self._verifyCareMap(expected, care_map_file)
|
||||
|
||||
@test_utils.SkipIfExternalToolsUnavailable()
|
||||
def test_AddCareMapForAbOta_skipPartition(self):
|
||||
image_paths = self._test_AddCareMapForAbOta()
|
||||
|
||||
# Remove vendor_image_size to invalidate the care_map for vendor.img.
|
||||
del OPTIONS.info_dict['vendor_image_size']
|
||||
|
||||
AddCareMapForAbOta(None, ['system', 'vendor'], image_paths)
|
||||
|
||||
care_map_file = os.path.join(OPTIONS.input_tmp, 'META', 'care_map.pb')
|
||||
expected = ['system', RangeSet("0-5 10-15").to_string_raw(),
|
||||
"ro.system.build.fingerprint",
|
||||
"google/sailfish/12345:user/dev-keys"]
|
||||
|
||||
self._verifyCareMap(expected, care_map_file)
|
||||
|
||||
@test_utils.SkipIfExternalToolsUnavailable()
|
||||
def test_AddCareMapForAbOta_skipAllPartitions(self):
|
||||
image_paths = self._test_AddCareMapForAbOta()
|
||||
|
||||
# Remove the image_size properties for all the partitions.
|
||||
del OPTIONS.info_dict['system_image_size']
|
||||
del OPTIONS.info_dict['vendor_image_size']
|
||||
|
||||
AddCareMapForAbOta(None, ['system', 'vendor'], image_paths)
|
||||
|
||||
self.assertFalse(
|
||||
os.path.exists(os.path.join(OPTIONS.input_tmp, 'META', 'care_map.pb')))
|
||||
|
||||
def test_AddCareMapForAbOta_verityNotEnabled(self):
|
||||
"""No care_map.pb should be generated if verity not enabled."""
|
||||
image_paths = self._test_AddCareMapForAbOta()
|
||||
|
|
Loading…
Reference in a new issue