From b2de7d97deadc1f582fae6f1e5e74c7eb10a4367 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Wed, 10 Apr 2019 10:01:47 -0700 Subject: [PATCH] releasetools: Remove the name restriction in common.GetSparseImage. The function used to be serving system and vendor partitions only (as they were the only partitions using sparse image at the point). The code itself doesn't rely on anything specific to system/vendor. Test: python -m unittest test_common Change-Id: Ia4ecdeedb262f3d9db082128eaf9bab299983333 --- tools/releasetools/common.py | 4 +--- tools/releasetools/test_common.py | 8 +++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index 632c1e2c25..171c794566 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -834,7 +834,7 @@ def GetSparseImage(which, tmpdir, input_zip, allow_shared_blocks, reconstructed from the block list, for whom we should avoid applying imgdiff. Args: - which: The partition name, which must be "system" or "vendor". + which: The partition name, e.g. "system", "vendor". tmpdir: The directory that contains the prebuilt image and block map file. input_zip: The target-files ZIP archive. allow_shared_blocks: Whether having shared blocks is allowed. @@ -843,8 +843,6 @@ def GetSparseImage(which, tmpdir, input_zip, allow_shared_blocks, Returns: A SparseImage object, with file_map info loaded. """ - assert which in ("system", "vendor") - path = os.path.join(tmpdir, "IMAGES", which + ".img") mappath = os.path.join(tmpdir, "IMAGES", which + ".map") diff --git a/tools/releasetools/test_common.py b/tools/releasetools/test_common.py index d4fa5f3a59..dce27fe1c3 100644 --- a/tools/releasetools/test_common.py +++ b/tools/releasetools/test_common.py @@ -641,11 +641,13 @@ class CommonUtilsTest(test_utils.ReleaseToolsTestCase): }, sparse_image.file_map) - def test_GetSparseImage_invalidImageName(self): + def test_GetSparseImage_missingImageFile(self): self.assertRaises( - AssertionError, common.GetSparseImage, 'system2', None, None, False) + AssertionError, common.GetSparseImage, 'system2', self.testdata_dir, + None, False) self.assertRaises( - AssertionError, common.GetSparseImage, 'unknown', None, None, False) + AssertionError, common.GetSparseImage, 'unknown', self.testdata_dir, + None, False) def test_GetSparseImage_missingBlockMapFile(self): target_files = common.MakeTempFile(prefix='target_files-', suffix='.zip')