Files
build/tools/releasetools/test_check_partition_sizes.py
Yifan Hong 3a7c2ef7cc Reland "Move partition size checks to python script"
This reverts commit 0141e45b96.

Reason for revert: Fixed in follow-up CL
Test: forrest
Bug: 143734706

Change-Id: I007acf228d4fb4d6a16ae9089e3f04cf33a567bb
2019-11-01 11:41:26 -07:00

95 lines
3.1 KiB
Python

#
# Copyright (C) 2019 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import common
import test_utils
from check_partition_sizes import CheckPartitionSizes
class CheckPartitionSizesTest(test_utils.ReleaseToolsTestCase):
def setUp(self):
self.info_dict = common.LoadDictionaryFromLines("""
use_dynamic_partitions=true
ab_update=true
super_block_devices=super
dynamic_partition_list=system vendor product
super_partition_groups=group
super_group_partition_list=system vendor product
super_partition_size=200
super_super_device_size=200
super_group_group_size=100
system_image_size=50
vendor_image_size=20
product_image_size=20
""".split("\n"))
def test_ab(self):
CheckPartitionSizes(self.info_dict)
def test_non_ab(self):
self.info_dict.update(common.LoadDictionaryFromLines("""
ab_update=false
super_partition_size=100
super_super_device_size=100
""".split("\n")))
CheckPartitionSizes(self.info_dict)
def test_non_dap(self):
self.info_dict.update(common.LoadDictionaryFromLines("""
use_dynamic_partitions=false
""".split("\n")))
with self.assertRaises(RuntimeError):
CheckPartitionSizes(self.info_dict)
def test_retrofit_dap(self):
self.info_dict.update(common.LoadDictionaryFromLines("""
dynamic_partition_retrofit=true
super_block_devices=system vendor
super_system_device_size=75
super_vendor_device_size=25
super_partition_size=100
""".split("\n")))
CheckPartitionSizes(self.info_dict)
def test_ab_partition_too_big(self):
self.info_dict.update(common.LoadDictionaryFromLines("""
system_image_size=100
""".split("\n")))
with self.assertRaises(RuntimeError):
CheckPartitionSizes(self.info_dict)
def test_ab_group_too_big(self):
self.info_dict.update(common.LoadDictionaryFromLines("""
super_group_group_size=110
""".split("\n")))
with self.assertRaises(RuntimeError):
CheckPartitionSizes(self.info_dict)
def test_no_image(self):
del self.info_dict["system_image_size"]
with self.assertRaises(KeyError):
CheckPartitionSizes(self.info_dict)
def test_block_devices_not_match(self):
self.info_dict.update(common.LoadDictionaryFromLines("""
dynamic_partition_retrofit=true
super_block_devices=system vendor
super_system_device_size=80
super_vendor_device_size=25
super_partition_size=100
""".split("\n")))
with self.assertRaises(RuntimeError):
CheckPartitionSizes(self.info_dict)