releasetools: Stop copying images from RADIO/ to IMAGES/.

We've added support in brillo_update_payload that allows additionally
looking for images under RADIO/ in the given target_files zips [1]. This
avoids having duplicate radio images in target_files zips.

Also adjust the unittest in test_ota_from_target_files.py to cover this
path.

As a result of this CL, the radio images will no longer appear in the
image archive (i.e. <target>-img.zip) as well - they are less useful
anyway because we have packed only the _updatable_ pieces that are part
of full bootloader/radio images.

Bug: 77218220
Test: `python -m unittest test_ota_from_target_files`
Test: `python -m unittest test_add_img_to_target_files`
Test: `m dist` produces the same full OTA package
Test: Build marlin-userdebug in internal branch. Check the image zip.
Change-Id: I05579480f0bb9ab90aaeecf75969ee29b6904ad6
This commit is contained in:
Tao Bao
2018-04-17 23:47:21 -07:00
parent f4b893165d
commit 5277d1015f
3 changed files with 46 additions and 74 deletions

View File

@@ -22,8 +22,7 @@ import zipfile
import common
import test_utils
from add_img_to_target_files import (
AddCareMapTxtForAbOta, AddPackRadioImages, AddRadioImagesForAbOta,
GetCareMap)
AddCareMapTxtForAbOta, AddPackRadioImages, CheckAbOtaImages, GetCareMap)
from rangelib import RangeSet
@@ -55,49 +54,25 @@ class AddImagesToTargetFilesTest(unittest.TestCase):
os.mkdir(images_path)
return images, images_path
def test_AddRadioImagesForAbOta_imageExists(self):
def test_CheckAbOtaImages_imageExistsUnderImages(self):
"""Tests the case with existing images under IMAGES/."""
images, images_path = self._create_images(['aboot', 'xbl'], 'IMAGES')
AddRadioImagesForAbOta(None, images)
images, _ = self._create_images(['aboot', 'xbl'], 'IMAGES')
CheckAbOtaImages(None, images)
for image in images:
self.assertTrue(
os.path.exists(os.path.join(images_path, image + '.img')))
def test_CheckAbOtaImages_imageExistsUnderRadio(self):
"""Tests the case with some image under RADIO/."""
images, _ = self._create_images(['system', 'vendor'], 'IMAGES')
radio_path = os.path.join(OPTIONS.input_tmp, 'RADIO')
if not os.path.exists(radio_path):
os.mkdir(radio_path)
with open(os.path.join(radio_path, 'modem.img'), 'wb') as image_fp:
image_fp.write('modem'.encode())
CheckAbOtaImages(None, images + ['modem'])
def test_AddRadioImagesForAbOta_copyFromRadio(self):
"""Tests the case that copies images from RADIO/."""
images, images_path = self._create_images(['aboot', 'xbl'], 'RADIO')
AddRadioImagesForAbOta(None, images)
for image in images:
self.assertTrue(
os.path.exists(os.path.join(images_path, image + '.img')))
def test_AddRadioImagesForAbOta_copyFromRadio_zipOutput(self):
def test_CheckAbOtaImages_missingImages(self):
images, _ = self._create_images(['aboot', 'xbl'], 'RADIO')
# Set up the output zip.
output_file = common.MakeTempFile(suffix='.zip')
with zipfile.ZipFile(output_file, 'w') as output_zip:
AddRadioImagesForAbOta(output_zip, images)
with zipfile.ZipFile(output_file, 'r') as verify_zip:
for image in images:
self.assertIn('IMAGES/' + image + '.img', verify_zip.namelist())
def test_AddRadioImagesForAbOta_missingImages(self):
images, _ = self._create_images(['aboot', 'xbl'], 'RADIO')
self.assertRaises(AssertionError, AddRadioImagesForAbOta, None,
images + ['baz'])
def test_AddRadioImagesForAbOta_missingImages_zipOutput(self):
images, _ = self._create_images(['aboot', 'xbl'], 'RADIO')
# Set up the output zip.
output_file = common.MakeTempFile(suffix='.zip')
with zipfile.ZipFile(output_file, 'w') as output_zip:
self.assertRaises(AssertionError, AddRadioImagesForAbOta, output_zip,
images + ['baz'])
self.assertRaises(
AssertionError, CheckAbOtaImages, None, images + ['baz'])
def test_AddPackRadioImages(self):
images, images_path = self._create_images(['foo', 'bar'], 'RADIO')