def test_AddCareMapForAbOta_noFingerprint(self): """Tests the case for partitions without fingerprint.""" image_paths = self._test_AddCareMapForAbOta() OPTIONS.info_dict = { 'extfs_sparse_flag': '-s', 'system_image_size': 65536, 'vendor_image_size': 40960, 'system_verity_block_device': '/dev/block/system', 'vendor_verity_block_device': '/dev/block/vendor', } 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(), "unknown", "unknown", 'vendor', RangeSet("0-9").to_string_raw(), "unknown", "unknown" ] self._verifyCareMap(expected, care_map_file)
def test_AddCareMapForAbOta_withThumbprint(self): """Tests the case for partitions with thumbprint.""" image_paths = self._test_AddCareMapForAbOta() OPTIONS.info_dict = { 'extfs_sparse_flag': '-s', 'system_image_size': 65536, 'vendor_image_size': 40960, 'system_verity_block_device': '/dev/block/system', 'vendor_verity_block_device': '/dev/block/vendor', 'system.build.prop': common.PartitionBuildProps.FromDictionary('system', { 'ro.system.build.thumbprint': 'google/sailfish/123:user/dev-keys' }), 'vendor.build.prop': common.PartitionBuildProps.FromDictionary('vendor', { 'ro.vendor.build.thumbprint': 'google/sailfish/456:user/dev-keys' }), } 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.thumbprint", "google/sailfish/123:user/dev-keys", 'vendor', RangeSet("0-9").to_string_raw(), "ro.vendor.build.thumbprint", "google/sailfish/456:user/dev-keys" ] self._verifyCareMap(expected, care_map_file)
def test_AddCareMapForAbOta_zipOutput(self): """Tests the case with ZIP output.""" image_paths = self._test_AddCareMapForAbOta() output_file = common.MakeTempFile(suffix='.zip') with zipfile.ZipFile(output_file, 'w') as output_zip: AddCareMapForAbOta(output_zip, ['system', 'vendor'], image_paths) care_map_name = "META/care_map.pb" temp_dir = common.MakeTempDir() with zipfile.ZipFile(output_file, 'r') as verify_zip: self.assertTrue(care_map_name in verify_zip.namelist()) verify_zip.extract(care_map_name, path=temp_dir) expected = [ 'system', RangeSet("0-5 10-15").to_string_raw(), "ro.system.build.fingerprint", "google/sailfish/12345:user/dev-keys", 'vendor', RangeSet("0-9").to_string_raw(), "ro.vendor.build.fingerprint", "google/sailfish/678:user/dev-keys" ] self._verifyCareMap(expected, os.path.join(temp_dir, care_map_name))