Fix DataImage.ReadRangeSet()

It returns a list of one generator object, not a list
of strings.

Test: test_blockimgdiff
Change-Id: I8962c539c2ce3fae90d428b38c4b0e52c5a2cdad
This commit is contained in:
Yifan Hong 2019-04-09 16:49:33 -07:00
parent d7d6e9d671
commit 6f3eaeb84d
2 changed files with 9 additions and 2 deletions

View file

@ -174,7 +174,7 @@ class DataImage(Image):
return h.hexdigest() return h.hexdigest()
def ReadRangeSet(self, ranges): def ReadRangeSet(self, ranges):
return [self._GetRangeData(ranges)] return list(self._GetRangeData(ranges))
def TotalSha1(self, include_clobbered_blocks=False): def TotalSha1(self, include_clobbered_blocks=False):
if not include_clobbered_blocks: if not include_clobbered_blocks:

View file

@ -16,7 +16,7 @@
import common import common
from blockimgdiff import ( from blockimgdiff import (
BlockImageDiff, EmptyImage, HeapItem, ImgdiffStats, Transfer) BlockImageDiff, DataImage, EmptyImage, HeapItem, ImgdiffStats, Transfer)
from rangelib import RangeSet from rangelib import RangeSet
from test_utils import ReleaseToolsTestCase from test_utils import ReleaseToolsTestCase
@ -261,3 +261,10 @@ class ImgdiffStatsTest(ReleaseToolsTestCase):
self.assertRaises(AssertionError, imgdiff_stats.Log, "/system/app/app1.apk", self.assertRaises(AssertionError, imgdiff_stats.Log, "/system/app/app1.apk",
"invalid reason") "invalid reason")
class DataImageTest(ReleaseToolsTestCase):
def test_read_range_set(self):
data = "file" + ('\0' * 4092)
image = DataImage(data)
self.assertEqual(data, "".join(image.ReadRangeSet(image.care_map)))